Camera doesnt rotate

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mR.haHN
Posts: 49
Joined: Wed May 03, 2006 5:37 pm

Camera doesnt rotate

Post by mR.haHN »

Hi there,
I got a very dumb question, I think :lol:

If I create a CameraSceneNodeFPS, I can rotate it without problems. But if I want to use a "normal" camera, he doesnt want to rotate :?. No matter what I do, he doesnt rotate at all. But if I then put back the FPS, it works. I have no idea :oops: please help me.
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

you have to say the camera when to rotate....
show me your code an i´ll may say more...
mR.haHN
Posts: 49
Joined: Wed May 03, 2006 5:37 pm

Post by mR.haHN »

Yeah, I must say I´m not an absolute Beginner...but I´m now starting to code again after a while....

I just want to rotate the camera in initialization. 90° on the X-Axis, in fact. My code looks like this

Code: Select all

camera->setRotation(vector3df(90.0f,0.0f,0.0f));
EDIT: Found another strange thing:

Code: Select all

if(p.X <= 0.1)
                        {
                               vector3df pos = camera->getPosition();
                               pos.X = pos.X - 5;
                               camera->setPosition(pos);
                               
                               vector3df rot = camera->getRotation();
                               rot.X = rot.X - 50;
                               camera->setRotation(rot);
                        }
Explaination: p.X is in this case the relative position of the cursor. The strange thing about this is, that if I now move the mouse at the left side of the screen, the camera moves along the X-Axis, but it doesn´t rotate. I´ve got the feeling the normal camera can´t rotate?!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think you have to change the camera target. The rotation just affects the surrounding scene node (and thus also children), but the lookat target, and thus also the view stay the same. If you want to rotate around the X or Z axis you might also want to change the up vector.
TheGameMaker
Posts: 275
Joined: Fri May 12, 2006 6:37 pm
Location: Germany

Post by TheGameMaker »

yes.. i think, you have to change the target, too....

float rotation// just put a negativ/positiv value for rotating
vector3df camt=camera->getTarget();
camt.rotateXZby(rotation, camera->getPosition);
camera->setTarget(camt);

dunno if this works, but it should....
TGM
mR.haHN
Posts: 49
Joined: Wed May 03, 2006 5:37 pm

Post by mR.haHN »

OK, i already found a good solution at the forum:

Code: Select all

   ICameraSceneNode *camera = smgr->addCameraSceneNodeFPS (0, 100, 500);
camera->setInputReceiverEnabled (false); 

No problems, everything works just like it should :wink:
Post Reply