[SOLVED] Scenenode teleportation


03-10-2010 16:46:02


I'm having problems with teleporting camera node into another zone.
The zone is known into which the camera node is to be teleported. The
only problem is that the camera node is moved and teleported through
physics so that camera node position update is not immediate
(not sure if it would affect anything).

Current teleportation code is the following:

// p_zone is the target zone
m_camera_node->setHomeZone( p_zone );
p_zone->_addNode( m_camera_node );

What happens:
Camera node pops into the correct place with the correct zone as its home.
However, the zone is not rendered - the only zones rendered are the ones where the
camera node used to be before the teleportation.

Edit: The problem is moving from one zone to another without following portals - I can reproduce the same behaviour when jumping into another zone over a portal. When I move the player back into the zone from which the player teleported / jumped out, rendering works okay again.

I have tried the following:

  1. m_camera_node->removeReferencesToZone( the zone from which the player teleported );
    m_camera_node->savePrevPosition(); // after setting the new home zone
    m_camera_node->_update( true, true ); // after setting the new home zone

    If any of those must have actually fixed it for me, then the problem might be that camera node position is not updated immediately after changing homeZone.

    Edit: I also tried to destroy the camera, perform an _update and then create another one, forcing it not to use frame to frame coherence cache, but it didn't seem to have helped. I'm out of ideas again.

    Edit: Tried two m_camera_node->_update(true, true)'s and a m_camera_node->setHomeZone(NULL) called manually after the teleportation. Also tried _updatePCZSceneNode(m_camera_node) after m_camera_node->setHomeZone(NULL). None of it worked, still the same problem that it places the camera node into the correct zone, but doesn't render the new zone nor any zones near it. It just gets stuck rendering the old zones.

    I'm using the PCZSceneManager version that comes with Ogre Mercurial.

    Any ideas?


30-12-2010 12:03:21

Yay, found the problem.

I had player set up as multiple scenenodes inside each-other. I teleported the outermost node, as transform matrices are propagated from a parent to its children.
However, zones are not propagated in this manner and it took me a while to figure that out (would've found it faster if I knew where the problem was :) ). So, the node encompassing the camera node had the correct zone, but the camera node itself was still in the old zone - which is why the old zone was rendered even when the new zone was properly found.

I'm not sure if it would be best, but perhaps home zones could also be propagated similar to how transformation matrices are?



30-12-2010 12:54:25

Glad you solved the problem. :-)

Unfortunately home zone cannot be propagated as there may be case where the parent node is in Zone A while the child node (which is offseted from parent node) could still be in Zone B as it has not cross over to Zone A. That being the case, even in teleporting case, your method will show glitches if you teleported close to a portal. What could be done is to have the child node set to parent node's position and then move it back to it's desired location to force a scene traversal and hopefully get it moved into the correct zone through the portals. :-)