Page 1 of 1

How to slow down my camera?

Posted: Sun Dec 04, 2005 6:14 pm
by VooDooMilivoje
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///

Posted: Sun Dec 04, 2005 6:29 pm
by data_drain
Use a variable, when a zombie is close enough set it to 600.0f, else, 1200.0f.

Posted: Sun Dec 04, 2005 6:38 pm
by Conquistador
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. :?

Posted: Sun Dec 04, 2005 7:03 pm
by kushagra
i think u can place another camera for slow motion . Initialize it with a lesser value and when zombie comes start this camera with dropping the first one

Posted: Mon Dec 05, 2005 12:17 pm
by Guest
I tried to do that kushagra, but it is a little bit imprecise... :? Thanks anyway///

Posted: Mon Dec 05, 2005 6:56 pm
by pfo
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:

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;

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).

Posted: Wed Dec 07, 2005 1:57 pm
by kushagra
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
}