Ogre Version: :14.4.1:
Operating System: : Linux:
Render System: :GL3Plus:
I'm updating some old code here from Ogre 1.12 to Ogre 14.4.1, but I'm struggling with getting the camera back to work.
The camera is defined with a position, a zoom factor and two rotation angles, theta for rotation around X axis and phi for rotation around Y axis, as bellow:
Code: Select all
Ogre::Radian thetaR = Ogre::Radian(Ogre::Degree(state.theta));
Ogre::Radian phiR = Ogre::Radian(Ogre::Degree(state.phi));
Ogre::Real cosTheta = Ogre::Math::Cos(thetaR);
Ogre::Real sinTheta = Ogre::Math::Sin(thetaR);
Ogre::Real cosPhi = Ogre::Math::Cos(phiR);
Ogre::Real sinPhi = Ogre::Math::Sin(phiR);
eye.x = state.center.x + state.zoom * cosTheta * sinPhi;
eye.y = state.center.y + state.zoom * sinTheta;
eye.z = state.center.z + state.zoom * cosTheta * cosPhi;
ogreCamera->setPosition(eye);
ogreCamera->lookAt(state.center);
Converting it to use a SceneNode, I've got wrong rotations within my phi variable (expected to be around Y axis). There is any difference in the usage of SceneNode::lookAt from the behavior of Camera::lookAt that I'm missing out?
My SceneNode creation:
Code: Select all
ogreSceneNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
ogreSceneNode->attachObject(ogreCamera);
and the change in the camera code:
Code: Select all
ogreSceneNode->setPosition(eye);
ogreSceneNode->lookAt(state.center, Ogre::Node::TS_WORLD);
