Deformed skybox

Hi,

I use the pure BasicGame template and added a sykbox:

[java]
Texture north = assetManager.loadTexture(“Textures/blue_512.jpg”);
Texture south = assetManager.loadTexture(“Textures/yellow_512.jpg”);
Texture up = assetManager.loadTexture(“Textures/green_512.jpg”);
Texture down = assetManager.loadTexture(“Textures/cyan_512.jpg”);
Texture west = assetManager.loadTexture(“Textures/red_512.jpg”);
Texture east = assetManager.loadTexture(“Textures/magenta_512.jpg”);
Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
rootNode.attachChild(sky);
[/java]

The result is:

It is far away from what I expected. My problems / questions:

1.) Why does the skybox and the blue square mesh are so deformed when I move the camera
2.) How do I prevent zooming out of the skybox (the black background on the image)

looks like your camera is in parallel projection. It can’t work
Your camera needs perspective.

I added to my code

[java]
cam.setParallelProjection(false);
cam.update();
[/java]

But the result is the same.

did you change the camera setup in the first place?
do you somehow change the render bucket of the sky at some point?
Post your entire code please.

[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;

public class Main extends SimpleApplication {

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    Geometry geom = new Geometry("Box", b);

    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    geom.setMaterial(mat);

    Texture north = assetManager.loadTexture("Textures/blue_512.jpg");
    Texture south = assetManager.loadTexture("Textures/yellow_512.jpg");
    Texture up = assetManager.loadTexture("Textures/green_512.jpg");
    Texture down = assetManager.loadTexture("Textures/cyan_512.jpg");
    Texture west = assetManager.loadTexture("Textures/red_512.jpg");
    Texture east = assetManager.loadTexture("Textures/magenta_512.jpg");
    Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
    rootNode.attachChild(sky);

    cam.setParallelProjection(false);
    cam.update();

    flyCam.setZoomSpeed(50f);

    rootNode.attachChild(geom);
}

@Override
public void simpleUpdate(float tpf) {
    //TODO: add update code
}

@Override
public void simpleRender(RenderManager rm) {
    //TODO: add render code
}

}
[/java]

ok so you zoom with the mouse wheel.
The flyCam zoom is not a zoom as you would expect because it changes the fov of the camera, and at some extend it flips the view and can give weird results.
you should use the “S” key to get the camera away from the scene.
and instead of setting the zoomSpeed se the moveSpeed.

Thx. I see what you mean. So my question as a noob is how can I control my camera the way I do with “S” ?

You could implement your own camera based on FlyByCamera and change it as you need it.

Nehon said the FlyCam Zoom changes the fov of the camera. I guess implementing an instance of it does not work.

@Tareq said: Nehon said the FlyCam Zoom changes the fov of the camera. I guess implementing an instance of it does not work.

He also said move the camera instead of change the fov… so… take fly cam and make it move the camera instead of change the fov.

I’m actually not entirely sure what you want, though. Do you still want the camera to move around freely and then also have zoom? You may need to implement your own camera control from scratch, in that case.

I am totally new to game engines and want to understand how things work.

I case of my camera problem using FlyCam is ok but ZOOM changes the fov while MOVE changes the … camera location(?)

Think of it like a physical camera. You can move it through space, or you can twist the lens to make what it is looking at look bigger in the picture.

The results may look similar (if moving the camera forwards/backwards as opposed to zooming in/out) but they are not the same.