Camera Paradigma to Node Paradigma


I have got following problem. I needed quite a while to find out that cameras and lights are positioned using the setPosition and setLocation method and that there is no local associated with these objects. Of course, there is a CameraNode which acts through a CameraControl class. However, this seems strange to me. I do not find any reason why a camera should not be a spatial. Everything could be calculated correctly. Now, I have created my own CameraNode which continuously sets the location and direction of my camera object.



public void update(float f) {





This works, as expected, perfectly. Now, I wrote a Listener class which is nearly totally equal to the FlyByCamera example. I do not (and can not) use the direct camera methods (the reason, by the way ist that I control all JME3.0 methods and properties from my wrapper classes, so the JME3.0 classes are wrapped inside my framework model). Everything has to be written and read by my classes and is delegated to the JME3.0 instances saved within my wrapper classes.

I only have one problem left I do not understand and this is how to apply the FlyByCamera example to my code. Making the explaination simple, you could imagine, that you do not want to control a camera object using the FlyByCamera but to rotate any spatial. What do I have to read and write? The localRotations or the globalRotations? My code currently looks something like this…


protected void rotateCamera(PraxitelesMapping mapping, float value, Vector3f axis) {

if (dragToRotate) {

if (canRotate) {

// value = -value;

} else {




Matrix3f mat = new Matrix3f();

//This seems to be clear. The axis is chosen around which should be rotated. Is this axis a local or a global axis?

mat.fromAngleNormalAxis(mapping.getSpeed() * value, axis);

//My wrapper class is called praxitelesCamera. It holds a spatial (this is MY CameraNode, not the JME3.0 CameraNode

//Here I load the WORLDROTATION of MY CameraNode

Vector3f up = praxitelesCamera.getSpatial().getWorldRotation().getRotationColumn(1);

Vector3f left = praxitelesCamera.getSpatial().getWorldRotation().getRotationColumn(0);

Vector3f dir = praxitelesCamera.getSpatial().getWorldRotation().getRotationColumn(2);

//Same than JME3.0

mat.mult(up, up);

mat.mult(left, left);

mat.mult(dir, dir);

Quaternion q = new Quaternion();

q.fromAxes(left, up, dir);


//As far as I understand I get the angels of the rotation around the axis

float[] angles = q.toAngles(null);

//Now the most important part. I can not set the axis of the camera object directly. I have to set the local rotations of

//my camera wrapper class. This would ONLY effect the rotation of the JME 3.0 camera node which is than automatically

//set to the camera position according to the code listed above.

praxitelesCamera.setLocalRotationX((float) Math.toDegrees(angles[0]));

praxitelesCamera.setLocalRotationY((float) Math.toDegrees(angles[1]));

praxitelesCamera.setLocalRotationZ((float) Math.toDegrees(angles[2]));



The strange thing is, that this code works perfect for looking up and down but it does not work for looking left and right. This is a heavy question, I know. Hopefully someone is interessted and could give me a hint. By the way, my setLocalRotation methods use degrees not radiants.

Thanks a lot.



1 Like

If you want to use the cam like a Spatial use CameraNode. But generally the camera cannot be oart of the scenegraph, its a part of the encompassing univerrse. The camera is like a god to the scenegraph, it can talk to it but it cannot explain it in scenegraph terms. :wink: