Code: Select all
...
ICameraSceneNode* camera = 0;
IAnimatedMeshSceneNode* animNode = 0;
//This is a simple internal class that handles input for camera motion
//TODO: seperate this into its own class and make it more robust.
class MyEventReceiver : public IEventReceiver{
public:
virtual bool OnEvent(SEvent event) {
if(animNode != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown) {
switch(event.KeyInput.Key)
{
case KEY_KEY_W :
case KEY_KEY_S : {
vector3df v = animNode->getPosition();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
animNode->setPosition(v);
}//end case
}//end switch
}//end if
return false;
}//end method
};//end class
...
IAnimatedMesh* mesh = smgr->getMesh("media\\sydney.md2");
animNode = smgr->addAnimatedMeshSceneNode(mesh);
//The next commented out lines turns off lighting, sets an
//animation loop for the mesh, and gives the mesh a texture.
if(animNode) {
animNode->setFrameLoop(0,1000);
animNode->setMaterialTexture(0, driver->getTexture("media\\sydney.bmp"));
}//end if
...
ISceneNode* node = 0;
...
camera = smgr->addCameraSceneNode(animNode, vector3df(0,10,-10), vector3df(0,0,10));
...
Any help would be apreciated!
Thanx,
Me.