Need help with Rotation
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?
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.
The FPC works correctly. It is the FPC used in the examples.
Nevertheless could you please explain your suggestion?
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);
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.
Thank you koirat and smiley80,
Now it works!!