Moving camera
Posted: Sat Jan 03, 2009 1:51 pm
I try to move camera by arrows
it normally movs by X axis? but it rotates arond Y, when I move it by Z axis
this s a method of my class
cpos is a temporary vector
pCamera is a pointer to object created with AddCameraSceneNode()
it normally movs by X axis? but it rotates arond Y, when I move it by Z axis
this s a method of my class
cpos is a temporary vector
pCamera is a pointer to object created with AddCameraSceneNode()
Code: Select all
void Move(irr::EKEY_CODE k)
{
this->cpos=this->pCamera->getPosition();
int fps = driver->getFPS();
float dist;
if (fps > 1)
dist = 200.0f / fps;
else
dist = 1.0f;
switch(k)
{
case KEY_UP:
{
this->cpos.X+=dist;
}
break;
case KEY_DOWN:
this->cpos.X-=dist;
break;
case KEY_LEFT:
this->cpos.Z+=dist;
break;
case KEY_RIGHT:
this->cpos.Z-=dist;
break;
default:
break;
}
pCamera->setPosition(cpos);
}