what is the easiest way to handle time based movement?
i want to move camera left or right when 6secs passes and then little pause
for a few secs and then again to the right.
and it should be nice with a little acceleration...
please reply.
thanx
time
-
- Posts: 26
- Joined: Thu Feb 05, 2004 10:58 pm
How about an animator with a state variable to say whether it's currently moving left, moving right, or waiting 6 seconds?
First you'd need a variable to keep track of when to next switch states. You'd also need to keep a velocity vector and acceleration vector if you wanted to avoid Quaternions. Each loop, affect the velocity vector based on the acceleration vector and add the velocity vector to the position. The acceleration vector would have to be negated when you've reached half the time to the next state switch to cause deceleration.
First you'd need a variable to keep track of when to next switch states. You'd also need to keep a velocity vector and acceleration vector if you wanted to avoid Quaternions. Each loop, affect the velocity vector based on the acceleration vector and add the velocity vector to the position. The acceleration vector would have to be negated when you've reached half the time to the next state switch to cause deceleration.
However, I should also point out that IrrLicht now contains a Quaternion class, conversion methods to and from Quaternions to Matrix4s, and the Quaternion Slerp function. So all the hard work has already been done, you just need to specify a starting rotation, destination rotation, and keep track of time remaining for the animation.
-
- Posts: 26
- Joined: Thu Feb 05, 2004 10:58 pm
-
- Posts: 26
- Joined: Thu Feb 05, 2004 10:58 pm
Making an animator isn't much work. There's only 1 required method (animate, or animateNode, or whatever it's called), into which you will put your state update and basic velocity equation stuff. You cannot add acceleration to a FlyStraightAnimator except by either modifying the engine source (not recommended for this) or copying the FlyStraightAnimator code into your own animator (you could do this to start your animator). In any case, you're going to have to do some work to get what you want no matter what method you choose. IrrLicht does not have an AcceleratedMotionAnimator.
-
- Posts: 26
- Joined: Thu Feb 05, 2004 10:58 pm
here is the thing i need to do:
i have a room with few chairs,camera in the middle of it.camera needs to move to the left about 0.5 meter with acceleration,then pauses go into initial position and then does the same to the other side.
i have simple cameraNode and
vector3df camPosition;
camPosition.X=0;
.
.
.
also i have to change only x-position of the camera.
i didnt figure out that time issue...
i have a room with few chairs,camera in the middle of it.camera needs to move to the left about 0.5 meter with acceleration,then pauses go into initial position and then does the same to the other side.
i have simple cameraNode and
vector3df camPosition;
camPosition.X=0;
.
.
.
also i have to change only x-position of the camera.
i didnt figure out that time issue...