Camera help

skorpio

06-03-2007 10:51:15

Hello

I need some help with the camera. I created 3 camera to switch among them. In the framelistener I added the code to switch. The switching works fine but the problem is that changes in position and viewing-angle of the current camera affects the next camera when the next camera is switched-in. So if I pitch CAM1 then CAM2 will be pitched by the same amount when CAM2 is switched-in. If CAM1 is moved then CAM2 will move too.

Is there a way for each camera to retain its position and viewing-angle, so that when I switch among all the cameras, they are unaffected by changes in the other cameras?

Thanks for your help




# create the first camera node/pitch node
node = sceneManager.rootSceneNode.createChildSceneNode("CamNode1", ogre.Vector3(0, 0, 0))
node.pitch(ogre.Degree(d=7))
node = node.createChildSceneNode("PitchNode1")
node.attachObject(self.camera)

# create the second camera node/pitch node
node = sceneManager.rootSceneNode.createChildSceneNode("CamNode2", ogre.Vector3(-2, 55, -335))
node.createChildSceneNode("PitchNode2")

# create the third camera node/pitch node
node = sceneManager.rootSceneNode.createChildSceneNode("CamNode3", ogre.Vector3(0, 39, -270))
node.createChildSceneNode("PitchNode3")



and


# keyboard input
if self._isToggleKeyDown(OIS.KC_1,0.25):
self.camera.parentSceneNode.detachObject(self.camera)
self.sceneManager.getSceneNode("PitchNode1").attachObject(self.camera)

if self._isToggleKeyDown(OIS.KC_2,0.25):
self.camera.parentSceneNode.detachObject(self.camera)
self.sceneManager.getSceneNode("PitchNode2").attachObject(self.camera)

if self._isToggleKeyDown(OIS.KC_3,0.25):
self.camera.parentSceneNode.detachObject(self.camera)
self.sceneManager.getSceneNode("PitchNode3").attachObject(self.camera)


bharling

07-03-2007 01:27:09

Does your other framelistener code (for moving the camera / pitch roll) move all the CamNodes?. They could all be rotating together.

if not, then perhaps this?:

self.camera.setDirection(self.sceneManager.getSceneNode("PitchNode2").getOrientation())

please post the rest of your framelistener code, so we can see what's happening. My guess is that you are rotating the camera, rather than each node, therefore, each node is still in the same position and rotation that it started in.