Need help with Rotation


16-03-2010 17:46:59


I've tried to make a third-person-camera, they movement works, but the roation of the player is ... difficult.
I want to rotate a scenenode instead of the camera(which is the child of the scenenode).

I have this code for a FPC:
Camera.Yaw(e.state.X.rel * -ROTATE)
Camera.Pitch(e.state.Y.rel * -ROTATE)

but if i change it to this...

CameraBaseNode.Yaw(e.state.X.rel * -ROTATE)
CameraBaseNode.Pitch(e.state.Y.rel * -ROTATE)

... the camera gets crooked.
Any idea to fix this?


18-03-2010 00:07:22

It should work as badly in both cases.
Your camera is not smooth.
Consider having destination/source orientation , destination/source position and do a piece of smooth transition every frame until you reach destination.


18-03-2010 17:23:50

Hi koirat,

The FPC works correctly. It is the FPC used in the examples.
Nevertheless could you please explain your suggestion?


18-03-2010 18:50:24 ... era_system

cameraNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
cameraYawNode = cameraNode.CreateChildSceneNode();
cameraPitchNode = cameraYawNode.CreateChildSceneNode();

Mouse event handler:
cameraYawNode.Yaw(arg.state.X.rel * -ROTATE);
cameraPitchNode.Pitch(arg.state.Y.rel * -ROTATE);


18-03-2010 20:02:54

basically, what you are doing is linear movement/rotation. If you want your camera to move faster you increase ROTATE. In the end your camera smallest rotation == ROTATE. If it's to big you will encounter jerkines.
What you can do is to get arg.state.Y/X.rel and add it to some variable may it be "globalRotInfluenceX". Each passing time <-- your choice it may be frame. you make it closer to zero. Also each frame you can do (rot=globalRotInfluenceX * ROTATE) with ROTATE that is small, that will be your current rotation. Also you can set maximum/minimum camera rotation. It's a little different than interpolation that i was writing about, but this is how you can do it without a lot of work.


19-03-2010 16:42:56

Thank you koirat and smiley80,

Now it works!!