hi all ,
in my code i use setAnimationEndCallback to call a function in which there are rules that control the movement of the static mesh bird . below is my code
-----------------------------------------------------------------------------
irr::scene::ISceneManager* smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh(
"../../media/bird.x");
scene::IAnimatedMeshSceneNode* anode = 0;
anode = smgr->addAnimatedMeshSceneNode(mesh);
anode->setLoopMode(true);
anode->setAnimationEndCallback(callBack);
-----------------------------------------------------------------------
------------------------------------------------------------------------------
void BoidsFlyer::callBack()
{
// Use the provided pointer argument to -
// - call a specific flyer's member functions.
BoidsFlyer *boidsFlyer = static_cast< BoidsFlyer * >( arg );
boidsFlyer -> directToBoid( );
boidsFlyer -> velocityMatching( );
boidsFlyer -> collisionAvoidance( );
boidsFlyer -> moveObject( );
boidsFlyer -> individual();
boidsFlyer ->foraging();
boidsFlyer ->subflocking();
}
-------------------------------------------------------------------
what do u think the problem is i m getting this error
------------------------------------------------
c:\documents and settings\haritha kolli\desktop\changing code\boidsflyer.cpp(53) : error C2664: 'setAnimationEndCallback' : cannot convert parameter 1 from 'void (void *)' to 'class irr::scene::IAnimationEndCallBack *'
There is no context in which this conversion is possible
------------------------------------------------------------------------------
please help
Problem with setAnimationEndCallback
You must pass a pointer to an instance of a class that derives from IAnimationEndCallback th the function setAnimationEndCallback...
Code: Select all
class BoidsFlyer : public IAnimationEndCallBack
{
//...
public:
BoidsFlyer(scene::ISceneManager* smgr)
{
scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/bird.x");
Node
= smgr->addAnimatedMeshSceneNode(mesh);
Node->setLoopMode(true);
Node->setAnimationEndCallback(this);
}
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node)
{
this->directToBoid( );
this->velocityMatching( );
this->collisionAvoidance( );
this->moveObject( );
this->individual();
this->foraging();
this->subflocking();
}
};
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Pasing functions with a specific interface is the usual C way of doin callbacks. With OOP you often use object interfaces. In this case there's an interface class named IAnimationEndCallBack. You have to implement this abstract class with your own derived class. This class ha a method named OnAnimationEnd. put the code of your method into this method, pass the arguments to the constructor and pass the instantiated objects to the IAnimatedMeshSceneNode method.
this is indeed a slightly advanced programming style so you might need some more experience before you can achieve this. Or maybe someone will code this for you (I won't as this wouldn't help you to really learn this stuff - you have to do it onyour own to really learn this Hmm, too late )
this is indeed a slightly advanced programming style so you might need some more experience before you can achieve this. Or maybe someone will code this for you (I won't as this wouldn't help you to really learn this stuff - you have to do it onyour own to really learn this Hmm, too late )