Camera rotation Question

Hi,



first i am new to jME.



I would like to achieve the following:



Display boxes circular around me.

show a HUD.

show a mouse arrow with an absolute Mouse to operate elements of my HUD.

This works and I see the boxes in front of my Camera.



Now something tricky (where i stuck):



I would like to rotate the cam if I press the right mouse button and drag it left/right and/or up/down.



I get that to work too - but with one issue:

As I press the mouse button and start to drag everything is okay.

But as soon as I rotated the camera about 90° to right or left the cam get slower and slower.



I more think this depends on some camera init parameter, because the deltax and deltay (what I use to rotate the camera) always return some values - I logged that on the console.



To rotate the camera i do:


o_TI_Timer.update();
/** Update tpf to time per frame according to the Timer. */
float tpf = o_TI_Timer.getTimePerFrame();
MouseInput thisMouse = o_IN_Input.getAbsoluteMouse().getMouseInput();
LoggingSystem.getLogger().log(Level.INFO, "Delta: "+thisMouse.getXDelta()+" - "+thisMouse.getYDelta());
o_CA_Kamera.setDirection(o_CA_Kamera.getDirection().add(((float)thisMouse.getXDelta())*tpf, ((float)thisMouse.getYDelta())*tpf, 0.0f));



Is that an camera issue?
Am i doing something wrong?

Thanks for your time.
Dom

When you rotate back to the original location, does it speed back up? Also, is the reponse slow or also the fps?

First if you want to use setDirection then it may help if you normalize the vector. You also need to reset up and left every time you change the direction because all these vectors must be 90 degrees apart. I would recommend using CameraNode instead.

Doing





Vector3f lookAtObject = o_CA_Kamera.getDirection().add(((float)thisMouse.getXDelta())*tpf*2, ((float)thisMouse.getYDelta())*tpf*2, 0.0f);
o_CA_Kamera.setFrame(o_CA_Kamera.getLocation(), new Vector3f(0,1,0).crossLocal(lookAtObject).normalizeLocal(), new Vector3f(1,0,0).crossLocal(lookAtObject).normalizeLocal(), lookAtObject.normalize());
o_CA_Kamera.update();



instead made the Cam faster at the edges but did not solved the Problem.

Can somebody post a Camera Init and a Scene Update function - or point me to a source in the jmetest where setframe is used?

take a look at KeyRotateAction and KeyLookAction. These rotate the camera based on relative mouse movements, but the algorithms should be the same (they do not have problems with slowdown).



You should also not call setFrame explicitly, you should call the update method.

I solved it by doing:


Quaternion q = new Quaternion();
float f[] = {camY, camX, 0};
q.fromAngles(f);
o_CA_Kamera.setFrame(o_CA_Kamera.getLocation(), q);
o_CA_Kamera.update();




Now I can move the Cam - I will try to playce the cam in a CameraNode to make it look better :)

That is basically what CameraNode dose.