HI Mark,

OK, I now understand better what you are trying to do.

You can use a osgGA::NodeTrackerManipulator as per the osgsimulation
example, or attach a CameraView node to the same subgraph as the
object you want to follow that use a
osgGA::CameraViewSwitchManipulator.

Alternatively rather than use a CameraManpulator just roll you own
code to set the Camera's view matrix on each new frame.  The view
matrix required is the inverse of the accumulated from the root of the
scene graph to the node you want to track.  The
node->getWorldMatrices() method can be used to be the matrx (or
matrices) that position you node, then just invert this and pass to
the viewer via:


viewer.realize();

while(!viewer.done())
{
  viewer.advncne();
  viewer.eventTraversal();
  viewer.updateTraversal();

  // really should double check size ofmatrices array returned, but
will leave this to reader to complete :-)
  osg::Matrix worldTolocal = myNode->getWorldMatrices()[0];
  viewer.getCamera()->setViewMatrix(osg::Matrix::inverse(localToWorld));

  viewer.renderingTraversals();
}


Robert.

On Fri, Mar 6, 2009 at 6:13 PM, Mark Yantek <myan...@rscusa.com> wrote:
> Robert,
>
> Sorry for my lack of clarity.
>
> I'm trying to have the camera locked on to a user controlled object.
>
> After rethinking this I can see the path I need to follow. In the
> example OSGSIMULATOR there is a plane with a camera following it. I just
> need to move user control from the camera to the object.
>
> Thanks
>
> - Mark
>
> -----Original Message-----
> From: osg-users-boun...@lists.openscenegraph.org
> [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
> Osfield
> Sent: Friday, March 06, 2009 9:56 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Help with adding a player model
>
> Hi Mark,
>
> On Fri, Mar 6, 2009 at 4:34 PM, Mark Yantek <myan...@rscusa.com> wrote:
>> I would like to "an object in the scene to the follow the viewer's
>> master camera", like in a Jet flight simulator.
>
> I don't know of tutorial to point you at that specifically does this,
> even with the extra info above it still doesn't provide enough info
> about exactly what you are doing/expecting.
>
> Typically an application that is controlling the camera will know
> where the viewer camera is, as it'll be controlling it, unless your
> app is simply reusing the standard viewer CameraManipulator.  How are
> you controlling the viewer's master camera in your app?
>
> What you say follow, what exactly do you mean?  Do you mean a ground
> based Camera that follows the main viewpoint around?   Do you mean a
> cockpit that is rendered around the viewer?  Do you mean a chase
> plane?
>
> Robert.
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to