Rotate Camera about the Origin

Hi guys, I have searched and searched for a solution to this problem, but nothing works  :expressionless:



All I want, is for the camera to rotate about a point (this rotation is akin to how the girl from the exorcist twists her head  }:-@ if you had to imagine the plane of rotation) of my choosing.



I want the camera to rotate a fraction when I press the right and left arrow buttons.



I tried this in my update method

if (KeyBindingManager.getKeyBindingManager().isValidCommand("right"))
   {
            roll180.fromAngleAxis( FastMath.PI/2 , new Vector3f(0,1,0) );
            /* The rotation is applied: The object rolls by 180 degrees. */
            cam.setAxes( roll180 );
   }



but for whatever reason, that didnt work. The error is at the line "roll180.fromAngleAxis......);"

Help please  ://

You should try to use the function cam.setLocalRotation(arg), and if i am not mistaken arg is a quaternion, in that you can use the function you wrote, fromangleaxis…

It appears that Camera has no such method - setLocalRotation



I'm at my wits end here and have no idea what to do.

Sorry, i forgot to mention that you have to use a camera node, and this is where you have to use setlocalrotation function.

Hi, I made a camera node and everything,



But the problem still appears to be this line:

    roll180.fromAngleAxis( FastMath.PI , new Vector3f(0,1,0) );


  • Where roll180 is a quaternion.



    Also, its a run-time error.

Hi guys,



The one line

      roll180.fromAngleAxis( FastMath.PI , new Vector3f(0,1,0) );      //roll180 is a Quaternion



is still the problem. I get a java.lang.NullPointerException everytime the code is being executed at run-time and the program crashes.

This might be a strange question, but did you initialized your roll180 object? If it is causing a NPE, then pehaps you should check (with an if perhaps?) if it is actually null before calling the fromAngleAxis method.



Also, you should be using Vector3f.UNIT_Y instead of creating a new Vector3f for it every time you call this.

You know, about 10 minutes after I made my last post, I discovered that I had in fact NOT initialized roll180  ://

I was too embarassed to say anything to be honest.



But my latest problem is that I can't get my camera node to move when calling setLocalTranslation. No error, its just that nothing happens.

Nevermind! Turns out all I had to do was add



cn.updateWorldData(0) //where cn is a CameraNode.



to the update method!



Sweet, this should start working now.

Cool, glad it is working!