Page 1 of 1

camera rotation problems.... it wont stay still

Posted: Mon Oct 10, 2005 4:46 am
by cheesyPoof
hey all. i'm fairly new to irrlicht and have a question regarding camera rotation.

i am using an FPS camera, and when i run my app, the camera continually rotates upward, and will not stay still.

here is the code for my Camera class:

Code: Select all


#include "Camera.hh"

#include "IrrManager.hh"

using namespace irr;

    
Camera::Camera()
{
  scene::ISceneManager* smgr = IrrManager::get()->getSceneManager();
  
  node = smgr->addCameraSceneNodeFPS( 0, 100.0, 500.0 );
  
  node->setParent( smgr->getRootSceneNode() );
  node->setFarValue( 12000.0 );
  node->setUpVector( core::vector3df( 0.0, 1.0, 0.0 ) );
}

void Camera::setPosition( core::vector3df position )
{
  node->setPosition( position );
}
 
void Camera::setTarget( core::vector3df target )
{
  node->setTarget( target );
}
    
void Camera::setParent( scene::ISceneNode* parent )
{
  node->setParent( parent );
}

core::vector3df Camera::getPosition()
{
  return node->getPosition();
}

core::vector3df Camera::getTarget()
{
  return node->getTarget();
}

scene::ISceneNode* Camera::getParent()
{
  return node->getParent();
}

scene::ICameraSceneNode* Camera::getCameraNode()
{
  return node;
}
and here is how it is used in my World class:

Code: Select all

  // Add camera
  camera = new Camera();
  camera->setPosition( core::vector3df( 1900*2, 255*2, 3700*2 ) );
  camera->setTarget( core::vector3df( 2397*2, 343*2, 2700*2 ) );
for reference, i am building my code on fedora core 4, using g++ compiler, and irrlicht version 0.12.0.

has anyone seen this problem?

Posted: Mon Oct 10, 2005 7:49 am
by Foole
I had this problem when I didn't realise that the camera's target co-ordinates are in world co-ordinates, not local. As the camera moves, it turns so that it is facing the same global location.

Posted: Mon Oct 10, 2005 9:47 pm
by cheesyPoof
i tried it without setting a target vector, same problem.
also, it happens if the camera is moving or standing still.

when i build and run the example 12, i don't see this problem.

could it be the way i am storing the camera node object?

i am generally a java programmer, so subtle c++ issues sometimes go over my head.

Posted: Tue Oct 11, 2005 6:20 am
by cheesyPoof
i played around with it some more, and found that the problem is somehow tied to the setting for resolution.

when i set up the irrlicht device object, as such, there is no problem.

Code: Select all

  device = createDevice( driverType,
			 core::dimension2d<s32>( 1024, 768 ) );
however, when i use "1280, 800" as a resolution, the camera continually rotates upward no matter what.

i have tested this mith many resolutions, only 1280, 800 seems to be problematic.

i use this resolution because i am developing on a compaq laptop with a widescreen.

does anyone know why the resolution setting would affect the camera's rotational behaivor?

note: i see this problem as well when i change the resolution in the example 12 code.

Posted: Tue Oct 11, 2005 7:12 am
by Guest
this is weird because in my own stuff it has never happened, but I checked out the irrlicht visual editor yesterday and that was doing just what you said - and this was also on a laptop (1280x800) but of course it wasn't a fullscreen app or anything but a window in a gui tool.

Posted: Thu Oct 13, 2005 10:02 am
by bearSoft
yes, i can confirm that. Post irr 0.9 this happens (with win resolution 6*800) if irr viewport y >570
i would suspect that theres other limits for other win resolutions??

Posted: Mon Oct 17, 2005 2:06 am
by cheesyPoof
thanx for verifying this guys.

so does this mean that i can't run anything at fullscreen on my laptop, without this happening?