Hi Oscar,
Oscar De Leon wrote:
> I've tried to add a slave camera using setViewMatrixAsLookAt to an
> example but i cannot get the desired result. I try to view a boat from 2
> different points. Here is the code:
>...
> for(unsigned int i=0; i<numCameras;++i)
> {
> osg::ref_ptr<osg::Camera> camera = new osg::Camera;
> camera->setGraphicsContext(gc.get());
>...
> camera->setViewMatrixAsLookAt(osg::Vec3d(0,0,10),osg::Vec3d(0,0,0),osg::Vec3d(0,1,0));
>...
> viewer.addSlave(camera.get(), osg::Matrixd(),
> osg::Matrixd::scale(aspectRatioScale,1.0,1.0));
> }
I've been struggling with slave cameras in the past as well and found some
caveats using them:
- the slave Camera reference frame must be RELATIVE_RF
- the slave Camera's matrices (View and Projection) are *overwritten* by the
masterCamera.matrix * offset (again for both View and Projection)
So the setViewMatrixAsLookAt() is ignored and overwritten. You definitively
cannot have a
camera with an independent position and only different ViewMatrix.
In the end I decided for myself that slave cameras are probably more (only?)
useful when
having multiple render windows/contexts like having two OTW views with slightly
rotated
view frusta.
I ended up using a Camera node for the same task which works beautifully but if
you want
to keep things (like view angle) in sync you have to do it manually.
If someone could confirm this I'd be willing to write a wiki entry about slave
cameras.
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org