On Event Callback not calling back!
Posted: Mon Apr 11, 2005 7:20 pm
I have tried to implement an event reciever in my program, i used a lot of the code form the Mercior Irrlicht/Newton tutorial. But when i click the mouse or hit escape nothing happens, put in breakpoints and execution never reaches callback. Any ideas?
here is the class definition
Here is the callback prototype
Here is the callback definition
here is the class definition
Code: Select all
class CGame : public IEventReceiver {
Code: Select all
// Irrlicht Callbacks
virtual bool OnEvent(SEvent event);
Code: Select all
bool CGame::OnEvent(SEvent event)
{
printf("Newt~licht Event Recieved...");
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
// make a cube where the camera is and set its velocity to follow the target
NewtonModel *tmp = MakeModel(cam->getPosition()/*, veloc*/);
if (!tmp) return false;
vector3df camvec = (cam->getTarget() - cam->getPosition()).normalize() * 500;
float newpos[3] = { camvec.X, camvec.Y, camvec.Z };
NewtonBodySetVelocity(tmp->body1, (float*)newpos);
}
else if(event.EventType == EET_GUI_EVENT)
{
//here put GUI STUFF
}
else if( event.EventType == EET_KEY_INPUT_EVENT)
{
bool key[KEY_KEY_CODES_COUNT];
key[event.KeyInput.Key] = event.KeyInput.PressedDown;
if(key[KEY_ESCAPE])
{
NewtonReleaseCollision(nWorld, floor->collision);
NewtonDestroy(nWorld);
device->drop();
}
}
return false;
}