Starting/terminating animators in a loaded .irr file

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
sd
Posts: 11
Joined: Wed Feb 27, 2008 4:18 am

Starting/terminating animators in a loaded .irr file

Post by sd »

Hi there,

If I set some meshes to animators in an .irr file, and they're not yet in the camera view, will they be taking processing time by animating? If that's the case and I have many and don't want to was processing cycles, is there some way I can start them only when they come into the camera view or close to it? And then terminate those scene nodes when those enemies get destroyed or they leave the camera view?

I don't know how to get my scene node to terminate when a createFollowSplineAnimator ends its course in general either? (eg. enemy is killed or finishes its animation)

Thanks,
sd.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The animators will be run for all scene nodes that isVisible() would return true, even if their parent is not visible. If, after you have a fully working application, you notice that performance is being affected by the animators that are not in view (using a profiler), then you could implement a paging system that would remove animators until they are needed.

Travis
sd
Posts: 11
Joined: Wed Feb 27, 2008 4:18 am

Post by sd »

By a profiler do you mean some software that I can use to test/stress the application to see how its measuring up to performance or system requirements? You could suggest one? (unless you meant something else?)

So basically I just hide the node with node->setVisible(0); when an enemy dies? But not kill the node itself? Can I node->remove(); or something? When I tried that kinda thing it crashed.

What if I want an animator only to start when it comes into view .. paging system? How would I do that? If I have an .irr file with all the animators set and load that. Then scan the scene for animators somehow, and suspend them all somehow -- save them into an array? And compare the positions stored in the array against the camera view?

Not sure where to start?

sd.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

sd wrote:By a profiler do you mean some software that I can use to test/stress the application to see how its measuring up to performance or system requirements?
Yes.
sd wrote:You could suggest one?
That depends on which envoronment you're on. There is gprof and V-Tune. There are also a few lesser known ones. If I remember correctly, there is one that ships with some versions of Microsoft Visual C++.
sd wrote:So basically I just hide the node with node->setVisible(0);
You could do that. You would only do it if you wanted to reuse the node at a later time without having to recreate it.
sd wrote:But not kill the node itself? Can I node->remove(); or something?
This is what you would normally do. If you remove the node from the scene graph (that is what this function does), it would no longer have its animators update.
sd wrote:When I tried that kinda thing it crashed.
Then you have some type of reference counting bug. Most likely you called drop() on a pointer you shouldn't have.
sd wrote:What if I want an animator only to start when it comes into view .. paging system? How would I do that?
You would think about it, figure out how you want it to behave, and then you'd write the code.
sd wrote:If I have an .irr file with all the animators set and load that. Then scan the scene for animators somehow, and suspend them all somehow -- save them into an array? And compare the positions stored in the array against the camera view?
Something like that.
sd wrote:Not sure where to start?
If you're not sure where to start, then you don't understand the problem well enough. I suggest that you do some experimentation to figure out how things work in Irrlicht. You also need to determine if this is even a problem that you need to solve, and if so, how your system will solve it. Once you've got a pretty good idea about how you want things to behave, it will be much easier to implement the solution.

Travis
sd
Posts: 11
Joined: Wed Feb 27, 2008 4:18 am

Post by sd »

Oh, I am creating a scrolling cowboy game (scrolling in up/down Y direction only), where you run along and can shoot, and these little cowboys enter from the top of the screen on their spline animator, run down and off the screen to escape according to a spline path, and fire a few shots.

So the spline animator can't really start before they get in range of the camera. And when they're out of the camera view, they aren't needed and should probably have their nodes deleted.

I found "createDeleteAnimator" which could set a time-out to terminate the node. irrEdit doesn't seem to allow me to set a value for it though.

Currently my plan was this:
1. load .irr file
2. smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes);
to get the nodes loaded in the .irr file
3. arrange that array into say pages of 50 vertical units (0-50, 50-100, 100-150, etc)
4. in the main rendering loop scan the first page (0-50) for any nodes of cowboys who should have their animators started, and start them (taking it that they are about to get in range of the camera).

But it seems I'll have to store the spline animator data elsewhere than the .irr file, as I don't know how to start/stop/reset an animator as loaded from the .irr file.

Is this the best way?

Please help if you can someone!
Post Reply