animators, or the day deps got tierd

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
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

animators, or the day deps got tierd

Post by deps »

Hello fellow irrlicht users,

I got a bit of a problem whit those animators. Trying to use them to do the work instead of doing it myself. I wish i knew math better. :)

In my current game project. A model needs to rotate 45 degrees in one second. (turn left or right, depends on what happens). So i started to do this in the constructor in a class that controls and contains a model:

Code: Select all

turnLeftAnim = smgr->createRotationAnimator( core::vector3df(0,-45,0) );
turnRightAnim = smgr->createRotationAnimator( core::vector3df(0,45,0) );
Not sure about the - up there. I just added it to test if it would work. Maybe it should be in that second line, but thats not the problem right now. The problem is that when i run:

Code: Select all

node->addAnimator( turnLeftAnim );
It starts to spin like a maniac. If behaves the same if I add turnRightAnim, so the negative value isn't the cause of the problem.
Also. I run this when a second has passed:

Code: Select all

node->removeAnimator( turnLeftAnim );
node->removeAnimator( turnRightAnim );
(I run them both. Just to make sure no turning animator is running)
But nothing happends.
It does however stop if i call removeAnimators(). But the model also have collision, and i want it to keep that.
So, to sum it all up,

* How come it doesn't rotate 45 degreees in one second?
* Why does it not stop?

Thankful for any help, ideas and suggestions.
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

smgr->createRotationAnimator( core::vector3df(0,-45,0) );

--

that sets an animator-- a thing thats going to constantly sit there and rotate a thing, and not only that but the current animators are not on a time schedule-- they do their business PER FRAME (which isnt the best way). So, you're probably getting 60+ FPS, and the animator is doing that many rotations per second.
a screen cap is worth 0x100000 DWORDS
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Another way to handle endpoints in the animators is like this.

In my Render loop, I have a checklist that goes through and sees if the object on that list has hit a certain criteria.

Though, I have been slowly adding checks to the animators in the core Irrlicht as well as having them send Event Messages to OnEvent when they have completed so that there is a notification process. I'll finish adding the notification code to the two core animators and put up a release of them soon.

Code: Select all

/*----------------------------------------------------------------------------------------------
Check if the Movement Animation is Finished
----------------------------------------------------------------------------------------------*/
bool ObjectHandler::CheckAnimation() {
	switch (iAnimation) {
		case ANIM_MOVE:
			if (Object[iCurrentObject].Core->getPosition() == vDestination) {
				iCurrentObject = -1;
				return true;
			} else {
				return false;
			}
			break;
		case ANIM_ROTATION:
if (Object[iCurrentObject].Core->getRotation() == vDestRotation)
			break;
		case ANIM_NONE:
			break;
	}
	return true;
}
Crud, how do I do this again?
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post by deps »

Thanks for your replies.
saigumi got some interesting code there, i guess i will do something like that.
Post Reply