Animators

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
seventhtear
Posts: 11
Joined: Sat May 23, 2009 11:39 am
Location: Poland

Animators

Post by seventhtear »

Hi,

I'm writing my own file format. I have some problem with animators.
I have a node and it's animators from getAnimators(), next I check what type is this animator by getType().
And now if i get for example ESNAT_ROTATION where i can find that rotation vector?
There is only ISceneNodeAnimator abstract class, there in no such thing like RotationAnimator.
The same problem with other types of animators. Need some advice.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If the create...Animator() function you call returns an ISceneNodeAnimator*, there probably isn't an interface for the derived animator. i.e., createRotationAnimator() returns a ISceneNodeAnimator*. This is a pretty good indicator that there isn't an ISceneNodeAnimatorRotation type that has getRotation() or setRotation(), so there is no clean way for you to get at the rotation values.

Travis
seventhtear
Posts: 11
Joined: Sat May 23, 2009 11:39 am
Location: Poland

Post by seventhtear »

But irrEdit saves rotateAnimator to *.irr files. How it is done then?
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

irrEdit does use the serialization mechanism. Each node does overload serializeAttributes and deserializeAttributes. I'm not sure if that is the best way to access the value in your case, but it would be possible for you to access the rotation vector by wrapping or directly using that serialization mechanism. The other possibility would probably be to change the engine.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Like I said, there is no clean way for you to get the rotation values. The ISceneNodeAnimator interface does support serializing/deserializing the values, so you can access the data that way. I provided code in this thread for getting/modifying attributes for a particle emitter a while back. You could use it to write something like this...

Code: Select all


bool ISceneNodeAnimator_getRotation(io::IFileSystem* fs, scene::ISceneNodeAnimator* animator, core::vector3df& rot)
{
    io::IAttributes* attribs = fs->createEmptyAttributes();
    if (!attribs)
        return false;

    bool success = false;
    for (; /* once */;)
    {
        // get the attributes out of the emitter
        animator->serializeAttributes(attribs);

        const s32 index = attribs->findAttribute("Rotation");
        if (index < 0)
            break;

        if (io::EAT_VECTOR3D != attribs->getAttributeType(index))
            break;

        rotation = attribs->getAttributeAsVector3d(index);

        success = true;
    }

    attribs->drop();

    return success;
}
Post Reply