ICameraSceneNodeFPS points at origin?

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.

ICameraSceneNodeFPS points at origin?

Postby beebs » Tue Mar 06, 2012 6:55 pm

Hiya,

I'm trying to recreate the camera orientation after loading a saved game. The camera rotation is serialised as a rotation vector returned from ICameraSceneNode::getRotation().

After reloading a save game and calling ICameraSceneNode::setRotation(), the camera unexpectedly points towards the origin instead being rotated to the orientation that was saved..

In this instance, the camera is guaranteed to be a child of the root node - so I assumed setRotation() would work.

Does anyone know why this happens?

Thanks for any suggestions.

Cheers!
beebs
 
Posts: 4
Joined: Tue Jan 31, 2012 7:57 pm

Re: ICameraSceneNodeFPS points at origin?

Postby CuteAlien » Tue Mar 06, 2012 7:47 pm

Rotation and target are only identical if you have set bindTargetAndRotation(true). Otherwise you have to save the target.
Also camera are serializable - so you can maybe just use the Irrlicht functionality for saving/loading (aka serializeAttributes/deserializeAttributes).
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5364
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: ICameraSceneNodeFPS points at origin?

Postby beebs » Tue Mar 06, 2012 8:52 pm

Thanks for that - the save information is actually being deserialised from a database and sent across the network, otherwise I'd use the built in functionality.

I've used bindTargetAndRotation(), but it doesn't seem to have any effect..

cpp Code: Select all
 
/* Create the camera. */
_camera = getScene()->addCameraSceneNodeFPS(0, 50, 0.1f);
 
/* Set the camera position. */
_camera->bindTargetAndRotation(true);
_camera->setPosition(irr::core::vector3df(zoneLoadPacket.PositionX, zoneLoadPacket.PositionY, zoneLoadPacket.PositionZ));
_camera->setRotation(irr::core::vector3df(zoneLoadPacket.RotationX, zoneLoadPacket.RotationY, zoneLoadPacket.RotationZ));
 


Strange - I'll have another look into this.
beebs
 
Posts: 4
Joined: Tue Jan 31, 2012 7:57 pm

Re: ICameraSceneNodeFPS points at origin?

Postby gerdb » Sun Mar 18, 2012 2:13 pm

are the values

zoneLoadPacket.RotationX,
zoneLoadPacket.RotationY,
zoneLoadPacket.RotationZ

correct?
gerdb
 
Posts: 169
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany


Return to Beginners Help

Who is online

Users browsing this forum: Masterhawk and 1 guest