Page 1 of 1

Camera doesnt rotate

Posted: Wed Jun 14, 2006 6:18 pm
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.

Posted: Wed Jun 14, 2006 6:19 pm
by TheGameMaker
you have to say the camera when to rotate....
show me your code an i´ll may say more...

Posted: Wed Jun 14, 2006 6:21 pm
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?!

Posted: Wed Jun 14, 2006 7:52 pm
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.

Posted: Wed Jun 14, 2006 7:57 pm
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

Posted: Wed Jun 14, 2006 8:02 pm
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: