How to slow down my camera?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
VooDooMilivoje
Posts: 7
Joined: Fri May 20, 2005 11:09 am
Location: Serbia&Montenegro

How to slow down my camera?

Post 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///
data_drain
Posts: 7
Joined: Sat Dec 03, 2005 2:50 am

Post by data_drain »

Use a variable, when a zombie is close enough set it to 600.0f, else, 1200.0f.
Say what now?
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post 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. :?
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
kushagra
Posts: 40
Joined: Sun Dec 04, 2005 10:18 am

Post 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
Guest

Post by Guest »

I tried to do that kushagra, but it is a little bit imprecise... :? Thanks anyway///
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post 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).
kushagra
Posts: 40
Joined: Sun Dec 04, 2005 10:18 am

Post 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
}
Post Reply