You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
I use static meshes and animate them with flyStraightAnimators. I'd like to create a new animator whenever the last animation is finished. I thought the OnAnimationEnd callback would be a good solution for that. The callback stuff seems to work but as soon as I call setLoopMode( false ), the app crashes.
Are you absolutely sure that you have a valid scene node pointer. Just because it is not pointing to NULL does not mean that it is a valid pointer. You might try changeing mp_unitNode->setLoopMode( false ) to mp_unitNode->getAbsoluteTransformation() to see if it still crashes.
No the pointer is valid. I tried what you told me. It's in fact not the setLoopMode() method where the app crashs, but the next CAnimatedMeshSceneNode->render() call in the next render loop. If I omit setLoopMode() the app doesent crash at that point.
I would step through the irrlicht code but gdb doesent let me step into sceneManager->drawAll() but tells me about a segfault.
Try making your own delta-timed fly striaght animator. Its not very hard and you can implement your own setLoopMode function. Irrlicht's fly straight animators while handy at times can be very stuffy, (for instance it refused to set one after the draw loop, and therefore cannot be called from inside anotehr animator.) I recommend a custom scene node animator for this job. Although getting the delta timing 100% can be pretty damn confusing...
(make a "float currenttime;" and initiate it to 0 somewhere in the constructor)
if(currenttime != 0){node->setPosition((f32)velocity * (f32)(timeMs - currenttime));}
currenttime = timeMs;
I wrote that quickly by hand so theres bound to be something i forgot lol...hope it helps though!
OH woops. I just realised this has NOTHING to do with setLoopMode...
Ummm nevermind then!
PS: But how can static meshes have animation!? Also what format is your model?
My meshes are OBJ files. I experimented a lot with diferent formats and obj was pretty much the only one that worked. I only animate them within irrlicht (e.g. move the whole object form one point to another.
I already thought about coding my own animator but I always try to make as much use of Irrlicht features as possible.
The Task (just to let you know):
Im coding an RTS game and the units should follow some waypoints they store internally. With the flyStraightAnimator, I would have added an animator whenever the last animator is fisnished. But if I have to code my own animator, I guess my animator will take care of the whole path at once.
Isnt setLoopMode for actual animated meshes?! As in X or B3D or MD2, with vertex or bone animations. Not SceneNodeAnimators lol...obj files I dont think have any sort of animation atleast in Irrlicht eh. So setLoopMode will not have any effect even if it did work, because what it does is repeat the animation once the animation frames have finished (Actual mesh animation not SceneNodeAnimators).
I think you are right, but it doesent really matter in my case. I only call setLoopMode( false ) because if I would'nt, the OnAnimationEnd() callback won't be triggered. And the OnAnimationEnd() callback does work, it gets called after my animator is done.
IMHO setLoopMode should not crash just because my meshes dont have animations. btw the app doesent crash if I call setLoopMode( true ).
In my game projects that use fly straight animators I just make a new one every frame and that works fine...I don't think it is as resource consuming as you may think, give it a try.
PS: I am confused you say the callback only works when the loop mode is set to false but so far it only crashes when you set it to false?
PS: I am confused you say the callback only works when the loop mode is set to false but so far it only crashes when you set it to false?
Yep thats right. The callback works, but in the next render loop somwhere in CAnimatedMeshSeceneNode->render() the app crashs if setLoopMode is set to false.
I'll code my own animator which takes care of all those waypoints at once. Seems to me to be more efficient than creating a new animator every frame.