Problems with CameraNode

Ops, I put a wrong link, this is the right.

OK, what I want in my game is the illusion that the center object(targeted by the ChaseCamera) is rotating according the player drag the mouse. So, if I make a spatial background behind the targeted spatial

Did you try creating a normal ChaseCam and then just creating a CameraNode, set its mode to Cam->Spatial after you corrected your double-controller setup? It should work.

Yes, I tried, but is like if the cube (a simple test) was attached to the rootNode, it does not move and I can see it :cry:

Here are the methods where I create the CameraNode, ChaseCam and attach the cube to camNode:

[java] public void initCam() {

camNode = new CameraNode("Camera Node", cam);




chaseCam = new ChaseCamera(cam, objeto, inputManager);




chaseCam.setToggleRotationTrigger(new MouseButtonTrigger(mouseInput.BUTTON_LEFT),

new KeyTrigger(KeyInput.KEY_SPACE));

chaseCam.setMinVerticalRotation(-FastMath.PI / 2);






public void initFundo() {

TextureKey key = new TextureKey("Textures/Fundos/2.jpg");


Texture tex = assetManager.loadTexture(key);


Box b = new Box(Vector3f.ZERO, 1, 1, 1);

cube = new Geometry("blue cube", b);

Material matCom = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");

matCom.setColor("m_Color", ColorRGBA.Blue);

cube.setLocalTranslation(new Vector3f(5f, 5f, 5f));








Here is the video showing the blue cube attached with the up code.

Any comentary? :roll:

Ok you want a fixed background behind your camera isn’t it?

don’t use a geometry.

look at this post,

i posted a way to have a fixed gradient in the background.

You can adapt this to have a texture or anything easily


I’m new to jMonkeyEngine (and 3d graphics engines in general) so I may be wrong. But from my own messing with CameraNode (jME 3 alpha 4) it looks like what prevents it from being translated/rotated according to camera (direction is ControlDirection.CameraToSpatial) is a bug in the code of it’s CameraControl.

If you look at controlUpdate(float) method of CameraControl, you can see that although the code adjusts translation and rotation of the CameraNode spatial, it does it internally in the vectors (lines 142 & 146, addLocal()). That way the CameraNode’s refreshFlags aren’t touched and won’t reflect the fact that it’s world transform need to be recalculated. Simply, the node is not set dirty, so it’s world transform won’t be altered according to changed local transform.

Simple check is to add another control to CameraNode that extends AbstractControl and does nothing more than just


protected void controlUpdate(float tpf) {



setLocalTransform() method takes care of setting CameraNode’s refreshFlags right. This worked as expected for me.

Again, I’m new to jME, so I may be wrong. It would be gr8 if someone evaluated it.

Hi @redeemer

I just took a quick look at CameraControl and I believe this issue you mention has been fixed. You will need to check out the latest nightly build or the head version from SVN, alpha 4 doesn’t have this fix.


Vector3f vecDiff = vars.vect1.set(camera.getLocation()).subtractLocal(spatial.getWorldTranslation());


// Rotation:

Quaternion worldDiff = vars.quat1.set(camera.getRotation()).subtractLocal(spatial.getWorldRotation());