Incorrect Camera/Mesh movement
Posted: Sat Mar 08, 2008 8:24 pm
hi,
i am creating a ship which will move through the level with the camera following it, when i first start moving and when i stop moving its very 'jerky' but once its going its. when i stop it seems to move back a place rather than stop. ive been told it could be somehting to do with the camera not updating enough btu i cant find a problem and im not sure this is the fault, my code is as follows any help would be nice!
cheers
my keypress code
and my camera code
im using
also im getin very low FPS at aorund 15-19, is there a reason for this there isnt much in the scene but surely this isnt right
thanks again for any help
i am creating a ship which will move through the level with the camera following it, when i first start moving and when i stop moving its very 'jerky' but once its going its. when i stop it seems to move back a place rather than stop. ive been told it could be somehting to do with the camera not updating enough btu i cant find a problem and im not sure this is the fault, my code is as follows any help would be nice!
cheers
my keypress code
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (Navigator != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT)
{
core::vector3df v = Navigator->getPosition();
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
v.Y +=event.KeyInput.Key == KEY_KEY_W ? +4.0f : -4.0f;
Navigator->setPosition(v);
}
return true;
case KEY_KEY_A:
case KEY_KEY_D:
{
v.X += event.KeyInput.Key == KEY_KEY_A ? -4.0f : +4.0f;
Navigator->setPosition(v);
}
return true;
}
}
return false;
}
};
Code: Select all
vector3df NavigatorRot = Navigator->getRotation();
vector3df NavigatorPos = Navigator->getPosition();
float DirY = NavigatorRot.Y + (90 * 3.14) / 180; //original 3.14
float CamX = (NavigatorPos.X - cos(DirY)*45);
float CamZ = (NavigatorPos.Z - sin(DirY)*35);
float CamY = (NavigatorPos.Y + 5);
camera = smgr->addCameraSceneNode();
camera->setTarget(NavigatorPos);
camera->setPosition( vector3df( CamX, CamY, CamZ ) );
to update the ship positionNavigator->setPosition(v);
also im getin very low FPS at aorund 15-19, is there a reason for this there isnt much in the scene but surely this isnt right
thanks again for any help