create follow spline animator

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
lord_kraig
Posts: 6
Joined: Tue Oct 18, 2011 10:23 am

create follow spline animator

Post by lord_kraig »

hi im trying to use a create follow animator to make a sphere move from position to position
this is the code i have used

Code: Select all

scene::ISceneNode* n = smgr->addSphereSceneNode();
 
        if (n)
        {
     n->setMaterialTexture(0, driver->getTexture("../../media/axe.jpg"));
     n->setMaterialFlag(video::EMF_LIGHTING, false);
     n->setScale(core::vector3df (7,7,7));
  scene::ISceneNodeAnimator* anim =
  smgr->createFollowSplineAnimator(s32(0), points, 0.2f, 0.3f, true, true);
 
  core::array<core::vector3df> points;
    //points.push_back(core::vector3df(X,Y,Z));
  points.push_back(core::vector3df(-220,0,0));
   points.push_back(core::vector3df(100,0,0));
   points.push_back(core::vector3df(100,0,180));
  points.push_back(core::vector3df(-100,0,180));
   points.push_back(core::vector3df(-100,0,0));
   points.push_back(core::vector3df(-220,0,0));
 
  points.push_back(core::vector3df(-220,0,0));
  points.push_back(core::vector3df(100,0,0));
  points.push_back(core::vector3df(100,0,-180));
  points.push_back(core::vector3df(-100,0,-180));
  points.push_back(core::vector3df(-100,0,0));
  points.push_back(core::vector3df(-220,0,0));
 
                if (anim)
                {
                        death1->addAnimator(anim);
                        anim->drop();
                         }
        }
this is the code for adding the sphere and animator but when i apply this to the program it works but the sphere does nothing.
is this sort ove code even able to move things in such a way or have a missed something important. please could you give em some clue as to what the code needs to move,
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: create follow spline animator

Post by Radikalizm »

Code: Select all

 scene::ISceneNodeAnimator* anim =
  smgr->createFollowSplineAnimator(s32(0), points, 0.2f, 0.3f, true, true);
 
  core::array<core::vector3df> points;
How does this even compile?
Your array is declared after you pass it to the animator, which should bring up an error at compile-time

EDIT:

Also, why the s32(0)? s32 is a typedef for a signed integer (so just int in standard C++), why are you casting an already integer value to an integer?
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: create follow spline animator

Post by ACE247 »

Kraig please take the time to read the Tutorials and API Doc, maybe also that C++ book atop of the Shelf. ;)
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: create follow spline animator

Post by polylux »

Radikalizm wrote:

Code: Select all

 scene::ISceneNodeAnimator* anim =
  smgr->createFollowSplineAnimator(s32(0), points, 0.2f, 0.3f, true, true);
 
  core::array<core::vector3df> points;
How does this even compile?
Your array is declared after you pass it to the animator, which should bring up an error at compile-time

EDIT:

Also, why the s32(0)? s32 is a typedef for a signed integer (so just int in standard C++), why are you casting an already integer value to an integer?
The only way to get this through the compiler is that points is redeclared in this scope. Doesn't make it all more clever, of course... ;)
beer->setMotivationCallback(this);
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: create follow spline animator

Post by Radikalizm »

polylux wrote:
Radikalizm wrote:

Code: Select all

 scene::ISceneNodeAnimator* anim =
  smgr->createFollowSplineAnimator(s32(0), points, 0.2f, 0.3f, true, true);
 
  core::array<core::vector3df> points;
How does this even compile?
Your array is declared after you pass it to the animator, which should bring up an error at compile-time

EDIT:

Also, why the s32(0)? s32 is a typedef for a signed integer (so just int in standard C++), why are you casting an already integer value to an integer?
The only way to get this through the compiler is that points is redeclared in this scope. Doesn't make it all more clever, of course... ;)
Doesn't a redeclaration give an error too?
I think the OP should first of all take some more time to study C++, and then give this another try
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Re: create follow spline animator

Post by polylux »

Radikalizm wrote:
polylux wrote:
Radikalizm wrote:

Code: Select all

 scene::ISceneNodeAnimator* anim =
  smgr->createFollowSplineAnimator(s32(0), points, 0.2f, 0.3f, true, true);
 
  core::array<core::vector3df> points;
How does this even compile?
Your array is declared after you pass it to the animator, which should bring up an error at compile-time

EDIT:

Also, why the s32(0)? s32 is a typedef for a signed integer (so just int in standard C++), why are you casting an already integer value to an integer?
The only way to get this through the compiler is that points is redeclared in this scope. Doesn't make it all more clever, of course... ;)
Doesn't a redeclaration give an error too?
I think the OP should first of all take some more time to study C++, and then give this another try
Nope, a warning if at all - given the change in scope. True that on the other statement. :)
beer->setMotivationCallback(this);
Post Reply