Hi everybody, i have one question...
I added a camera scene node to my 3d world:
g_camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f,11,g_keyMap,8,true);
so, speed of that camera is 1200.0f.
But, after a while, under certain circumstances/when zombie reachs my camera/, i want to slow down it (eg. i want that speed of camera to be 600.0f)...
Does anyone have any idea how to do that??
Thanks///
How to slow down my camera?
-
- Posts: 7
- Joined: Fri May 20, 2005 11:09 am
- Location: Serbia&Montenegro
-
- Posts: 7
- Joined: Sat Dec 03, 2005 2:50 am
-
- Posts: 340
- Joined: Wed Sep 28, 2005 4:38 pm
- Location: Canada, Eh!
I don't think that'd work, once the camera is initialized, the camera is initialized. I don't think there is a way with CameraScenNodeFPS to do that. I was wondering about that myself awhile ago for my own project.
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
The best way to get smooth camera movement is to use inverse dynamics. Make up a 'virtual mass' number, it can be any positive non-zero number. This will be the virtual mass of the camera, the camera has no real mass, but having virtual mass will allow it to behave more smoothly. You use it as follows:
Note that when velocity is 0, the second piece of code subtracts 0 from the velocity (an object at rest tends to stay at rest...). As velocity increases, the dampening ammount decreases. This has the effect that acceleration can be quite high, but the camera will still accelerate slowly from rest. It allows a lot more control over the camea (trust me).
Code: Select all
// when calculating velocity, do it like this:
core::vector3df velocity = acceleration * virtual_mass * delta_t;
// right afterwards, do this
velocity -= velocity / virtual_mass;
Now do one thing
create a camera scene node (not fps nor maya). Receive its events
Until a key is not released or for free camera u can take help of Userdata1/2/3
{
do
Change the target position of the camera accordingly
If(distance from camera target vector to zombie position vector < a value)// where value is the distance when u want camera to be slow
then Change the target position of the camera with less factor
}
create a camera scene node (not fps nor maya). Receive its events
Until a key is not released or for free camera u can take help of Userdata1/2/3
{
do
Change the target position of the camera accordingly
If(distance from camera target vector to zombie position vector < a value)// where value is the distance when u want camera to be slow
then Change the target position of the camera with less factor
}