Camera and Quad location problems

Hello all,

I just finished my StarField texture generator. So now I need to test it. To this end, I setup a Quad and added the texture:

Moving the quad with setLocalTranslation(0,0,-500) should put it in the X-Y plane at Z=-500, as far as I can tell.

But when I setup a camera with location 0,0,0 and lookAt 0,0,-500, I don’t seen anything.

The only thing I can figure out is that the Quad isn’t in the X-Y plane for some reason, but I can’t come up with a good reason why this should be so.

When I remove the lookAt from my camera, I DO see the Quad.

might be looking at the back of it, or at the edge.

The thing is, if I remove the lookAt(0,0,-500) altogether, I’m looking straight at it, or so it seems anyways. I’ll see if I can fix something with setLocalRotation tomorrow, force it to be in the X-Y plane that way.

Default camera lookat is (0,0,0) and the default camera position is (0,0,10); so in a sense looking down the -Z axis. It should be looking at your quad. Unless your code is lying :slight_smile:

One thing you can do is not move it to -500 (maybe -5 or so), and set a rotation on it to rotate slowly in the update loop.

ok, so if the camera is looking down the Z axis, why is setting a localTranslation of 0,0,-100 to my model moving it not only along the Z but also the Y?

gonna have to post yer code

will do that in the morning, on my phone atm, so no code available

Ok, here’s the complete JMP project in a Zip, I’ll put the interesting parts in here to point them out.

The problem can be spotted in the com.ractoc.fs.invasion.GameClient class combined with the com.ractoc.fs.invasion.appstates.StarFieldAppState class.

In the StarFieldAppState you can see I put 2 quads with a generated texture at Z=-500.

In the GameClient, you can see I create the camera and put it at 0,0,0.

After that, I put the ship at 0, 0, -100. So it’s only translated backwards on the Z axis. For some reason however, I can see the stars, but not the ship.



private void setupShip() {

Cylinder n = new Cylinder(30, 30, 0.25f, 1f);

Geometry nose = new Geometry(“Nose”, n);

Material mat = new Material(assetManager,


mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Gray);

mat.setColor(“Diffuse”, ColorRGBA.Blue);

mat.setColor(“Specular”, ColorRGBA.White);

mat.setFloat(“Shininess”, 1);


Sphere b = new Sphere(30, 30, 1f, true, false);

Geometry body = new Geometry(“Body”, b);


body.setLocalTranslation(0, -0.5f, 0);

ship = new Node(“Ship”);



ship.getChild(“Nose”).setLocalTranslation(0, 0, 1);

ship.getChild(“Body”).setLocalTranslation(0, 0, 0);

ship.setLocalTranslation(0, 0, -100);

System.out.println(“setting radius to: 1.0”);

ship.setUserData(“radius”, new Float(1f));


vel = new Vector3f(0, 0, 0);

accel = new Vector3f(0, 0, 0);



public final void initialize(final AppStateManager stateManager,

final Application app) {

super.initialize(stateManager, app);

this.gameClient = (GameClient) app;

StarField sf1 = new StarField(width, height, density, Color.white);


StarField sf2 = new StarField(width, height, density, Color.white);

Quad starQ1 = new Quad(width, height);

starGeom1 = new Geometry(“starField1”, starQ1);

Material mat1 = new Material(gameClient.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);

mat1.setTexture(“ColorMap”, sf1.generate());



starGeom1.setLocalTranslation(-width / 2, -height / 2, -500);


Quad starQ2 = new Quad(width, height);

starGeom2 = new Geometry(“starField2”, starQ2);

Material mat2 = new Material(gameClient.getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);

mat2.setTexture(“ColorMap”, sf2.generate());



starGeom2.setLocalTranslation(-width / 2, -height / 2, -500);




I don’t see anything obvious in your code. Please post a simple test case illustrating the problem.

See, the thing is, most people aren’t going to download and compile your whole application because in a complete example we might have easily spotted the issue without downloading anything. Plus 9 times of 10 (yes 9!) your simpler test case will work just fine and then you can figure out why your full example doesn’t work.

When stumped, creating a simple test case is as much for you as for the community. It helps you pinpoint exactly what elements are necessary to recreate the issue… if you can even recreate it at all.


Ok I found the problem. Turns out I rotated the entire gameworld along the X-axis. This didn’t come up as a problem anywhere else, which is why I didn’t spot it earlier. I removed the x-axis rotation and now it works like a charm.