Manipulating scene nodes?

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
prodcake
Posts: 10
Joined: Thu Jun 23, 2011 9:53 am

Manipulating scene nodes?

Post by prodcake »

I'm trying to avoid using animators, mostly because i don't want to go
through another layer of functions and i'm a total newbie at working with
irrlicht and they confuse the hell out of me at the moment.

so i'm really lost for ways to move scene nodes
without the if ( node ){ blah } thing, when i try
to use that in my object's step method. it crashes
the project D:

any help will be greatly appreciated
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Manipulating scene nodes?

Post by Radikalizm »

prodcake wrote:I'm trying to avoid using animators, mostly because i don't want to go
through another layer of functions and i'm a total newbie at working with
irrlicht and they confuse the hell out of me at the moment.
My advice would be to just take the step and learn how to use them, they're a really great tool for manipulating nodes without having to resort to hacks like animating nodes directly in your rendering loop

Also 'it crashes the project' doesn't give us enough information on what you want to accomplish and where it went wrong, please post what you're trying to do exactly with the code you're using, and post any error codes or crash reports
prodcake
Posts: 10
Joined: Thu Jun 23, 2011 9:53 am

Post by prodcake »

Code: Select all

class Footsoldier:Soldier
{

    public:
    int Hp;
    bool Dead;
    bool canshoot;

    IAnimatedMeshSceneNode* node;

    vector3df pos;
    vector3df rot;
    void Step();
    void Start()
    {

        IAnimatedMesh* mesh = smgr->getMesh("media/soldier.x");
        IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
        srand ( time(NULL) );
        X=rand()%20 - 10;
        Z=rand()%20 - 10;

        pos.X = X;
        pos.Y = 0;
        pos.Z = Z;

        rot.Y = ( rand()%360 );

        if (node)
        {

            node->setMaterialFlag(EMF_LIGHTING, false);
            node->setMaterialTexture( 0, driver->getTexture("media/soldier.png") ) ;
            node->setFrameLoop(0,25);
            node->setPosition(pos);
            node->setRotation(rot);

        }
    };

   // Step

};

   void Footsoldier::Step()
   {
            if (node)
        {

            pos.X += 3;
            node->setPosition(pos);

        }
   };
this is what causes the crash the second if (node),
obviously i shouldn't be using two "if (node)"'s because
this is what causes the crash in my project, I just don't
know how to set the position any other way, I'm still
studying the irrlicht manual and the examples at the
moment, and i don't know a way to change the exact
position without using node->setPosition(pos);

it compiles fine and when it runs it crashes
exception code c0000005
Xaryl
Posts: 90
Joined: Sat Apr 30, 2011 11:54 pm

Post by Xaryl »

Code: Select all

IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); 
"node" is a local variable, not the class variable.
prodcake
Posts: 10
Joined: Thu Jun 23, 2011 9:53 am

Post by prodcake »

Like i said, i'm a newbie at using irrlicht. so could you at least extrapolate a bit more? because just saying that alone isn't much.

but thank you anyway
Xaryl
Posts: 90
Joined: Sat Apr 30, 2011 11:54 pm

Post by Xaryl »

Replace it with

Code: Select all

node = smgr->addAnimatedMeshSceneNode( mesh ); 
so the "node" inside Step() would refer to the same variable.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

prodcake wrote:Like i said, i'm a newbie at using irrlicht. so could you at least extrapolate a bit more? because just saying that alone isn't much.

but thank you anyway
You look more like newbie to c++, you should study more of it if you want to work with irrlicht.
Working on game: Marrbles (Currently stopped).
prodcake
Posts: 10
Joined: Thu Jun 23, 2011 9:53 am

Post by prodcake »

that too. hah thanks for that Xaryl. i'l give it a shot.
prodcake
Posts: 10
Joined: Thu Jun 23, 2011 9:53 am

Post by prodcake »

It works now. thanks Xaryl! I knew it'd be something stupid like that :P
Post Reply