Hi Ben,

On Sat, Sep 6, 2008 at 8:28 AM, benben <[EMAIL PROTECTED]> wrote:
> Can I add an osg::Camera to an osg::PositionAttitudeTransform node to render
> the scene? The idea is to use the transform node to move and orientate the
> camera.

The Camera isn't an ordinary object like a car or house that you
position in the scene, the relationship is that the Camera sits above
the scene that you wish to render, this applies to high level Viewe
Camera's just as it does to ones in the scene graph.  The next special
relationship is that the OpenGL modelview matrix the world underneath
the camera positions the world in the local coordinates of the camera,
rather than positioning the camera in world coordinates - this is just
how OpenGL works and OSG works with.

In your own application you need to Camera to contain the scene you
want to render, if it was a leaf of your scene graph then it wouldn't
have anything to render.  You could add you scene to the Camera but
this would cause a circular cycle in the scene graph and bag you'd end
up reccursing till your memory blows... so that certainly work either.

Second you want to set the Camera's view matrix to be the inverse of
the model matrix, rather than the the model matrix that will be
inherited down to the Camera that you have in your setup.  So again we
are getting the opposite of what you want by placing the Camera as a
leaf.

So this brings us to how do you solve the task of following nodes in
the scene?  The osgGA::NodeTrackerManipulator is one solution, as is
holding the NodePath from the root of your scene to the node you want
to set the position by, and then computing the world to local
transform using osg::computeWorldToLocal(NodePath) (this is what
NodeTracker does internally).  If you set the viewer's Camera's view
matrix yourself don't attach a camera manipulator, and just set the
view matrix each frame like:


   while(!viewer.done())
   {
       // break frame into it's constituent parts
       viewer.advance();
       viewer.updateTraversal();
       viewer.eventTraversals();

       viewer.getCamera()->setViewMatrix(osg::computeWorldToLocal(myNodePath);

       viewer.renderingTraversals();
   }


Or just write your own version of NodeTrackerManipulator.

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to