Binding a camera to a sphere

ramar

25-08-2008 15:30:22

Hi people. I read some threads but i cant solve my problem. I want to bind my camera to a sphere (that fall, rotate and so on). I created a childNode from the sphere one and then i attached mycamera into the cameranode but the camera goes crazy because it rotates with the sphere. So i tried this code:
cameraNode = sphereNode->createChildSceneNode ("mCam",Vector3::ZERO,Quaternion::ZERO );

in this way the camera only follows the sphere and doesn't rotate. This could be fine but from this point i cant absolutly change camera orientation neithwer pitch/yaw/roll. Ii'd like to adjust direction and i want the camera rotate around the sphere with mouse control. How can i do it? :)

Cheers

ramar

25-08-2008 15:44:02

ooooh, i just discovered

cameraNode->setInheritOrientation(false);

and now i solved my problem! :)

Prophet

25-08-2008 15:44:03

Perhaps this will work;
Create the body/actor for the sphere. In a framelistener (or when you render, what ever suits you), you set the cameras node position from the actor/body's. Like;camNode>setPosition(sphere->getGlobalPositionAsOgreVector3());I'm not sure if this is the right thing to do, or even a good way, but it works. Probably, betajaen has a better solution. :)
I read this again, and maybe you are looking for the lookAt function? (For the camera)
Read it again, and problem solved! :D