Dear All

I create my "Animation" node deriving the "Sequence" node:
I create a plugin  file that I simple included in my project in order to save 
and load my scene.

This is my problem....
if I save and open my scene as .osg file everything works perfectly.

Now I'm trying to save and read the scene using .ive format.
The file is well saved but when I open it, it crash.
The problem occurs when I call a method of “Animation”:

        animationNode = dynamic_cast<Animation*>(sceneGraph->getChild(0));
        animationNode->SetLoopMode(Animation::LOOP);

It seem that it cant properly read the animation node.


Do I have to change something in the plugin passing from .osg to .ive format?
Thanks


In attachment I send the Animation plugin
This is part of my derived class:

class Animation : public osg::Sequence {

public:
        //costruttore
        Animation();

    /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
        Animation(const Animation&, const osg::CopyOp& 
copyop=osg::CopyOp::SHALLOW_COPY);

        META_Object(osg,Animation);

        virtual void traverse(osg::NodeVisitor& nv);

ecc..

#include <osg/Notify>
#include <osg/Geometry>
#include "Animation.h"
#include "Convert.h"
#include <osg/io_utils>

#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>

using namespace osg;
using namespace osgDB;


// forward declare functions to use later.
bool  Animation_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool  Animation_writeLocalData(const osg::Object &obj, osgDB::Output &fw);


// register the read and write functions with the osgDB::Registry.
osgDB::RegisterDotOsgWrapperProxy  Animation_Proxy
(
    new Animation,
    "Animation",
    "Object Node Animation Sequence Group",
    Animation_readLocalData,
    Animation_writeLocalData,
    DotOsgWrapper::READ_AND_WRITE
);


bool Animation_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
    Animation *anim = dynamic_cast<Animation*>(&obj);
    if (!anim) return false;

    bool itAdvanced = false;
    if (fr[0].matchWord("LoopMode"))
    {
                int loopMode = Animation::LOOP;
                fr[1].getInt(loopMode);
                anim->SetLoopMode((Animation::LoopMode)loopMode);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("RepetitionNumber"))
    {
                int repNum = 0;
                fr[1].getInt(repNum);
                anim->SetRepetitionNumber(repNum);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("FirstSequenceTime"))
    {
                int fSeqTime = 0;
                fr[1].getInt(fSeqTime);
                anim->SetFirstSequenceTime(fSeqTime);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("LastSequenceTime"))
    {
                int lSeqTime = 0;
                fr[1].getInt(lSeqTime);
                anim->SetLastSequenceTime(lSeqTime);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("DevelopTimeLapse"))
    {
                float devTimeLapse = 0;
                fr[1].getFloat(devTimeLapse);
                anim->SetDevelopTimeLapse(devTimeLapse);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("InitialDevelopTime"))
    {
                float initDev = 0;
                fr[1].getFloat(initDev);
                anim->SetInitialDevelopTime(initDev);
                itAdvanced = true;
                fr += 2;
    }
    else if (fr[0].matchWord("Multiplier"))
    {
                float mul = 0;
                fr[1].getFloat(mul);
                anim->SetMultiplierTime(mul);
                itAdvanced = true;
                fr += 2;
    }
    return itAdvanced;
}


bool Animation_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
    const Animation *ani = dynamic_cast<const Animation*>(&obj);
    if (!ani) return false;

        //fw.indent() << "LoopMode " << ani->GetLoopMode()<<std::endl;
        fw.indent() << "RepetitionNumber " << ani->GetRepetitionNumber() 
<<std::endl;
        fw.indent() << "FirstSequenceTime " << ani->GetFirstSequenceTime() 
<<std::endl;
        fw.indent() << "LastSequenceTime " << ani->GetLastSequenceTime() 
<<std::endl;
        fw.indent() << "DevelopTimeLapse " << ani->GetDevelopTimeLapse() 
<<std::endl;
        fw.indent() << "InitialDevelopTime " << ani->GetInitialDevelopTime() 
<<std::endl;
        fw.indent() << "Multiplier " << ani->GetMultiplierTime() <<std::endl;

        return true;
}


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to