time

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
jugurdzija
Posts: 26
Joined: Thu Feb 05, 2004 10:58 pm

time

Post by jugurdzija »

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
jugurdzija
Posts: 26
Joined: Thu Feb 05, 2004 10:58 pm

Post by jugurdzija »

well i thought of not using quarternios...
i thought something simplier...
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

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.
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

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.
jugurdzija
Posts: 26
Joined: Thu Feb 05, 2004 10:58 pm

Post by jugurdzija »

i added flystraight animatior but i dont know how to add some acceleration and switch beetween animators
any ideas?
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

You'll have to make your own animator. You could start off by copying the code from the FlyStraightAnimator if you wanted, but I'd recommend starting from scratch so you're not stuck trying to squeeze your requirements into the FlyStraightAnimator's framework.
jugurdzija
Posts: 26
Joined: Thu Feb 05, 2004 10:58 pm

Post by jugurdzija »

well i need a specific motion that probably i will never use again so i thought not to make my own animator but to just simply change cam position in time based on basic velocity equatations (v=s/t , a=v/t hehe)
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

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.
jugurdzija
Posts: 26
Joined: Thu Feb 05, 2004 10:58 pm

Post by jugurdzija »

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