I think I solved my own problem. I was planning to use viewer.addSlave(cam,...)
and then use cam->setReferenceFrame(osg::Transform::ABSOLUTE_RF) to decouple the slave camera from the master. (If this is not the best approach, I would still like to hear, but it seems pretty clean) It turned out that I did not even need the second call. I think this is because I have an update callback attached to each of the slave cameras that explicitly sets the view matrix to match the world-to-local matrix of some node in the scenegraph and thereby overrides the slaving. By the way, this is something else that has bothered me. The requirement for a camera to track a node in the scenegraph seems like it should be extremely common. But in order to implement this I had to write my own little NodeTracker Callback as follows: class NodeTracker : public NodeCallback { public: NodePath _nodepath; NodeTracker(Node* node):_nodepath(node->getParentalNodePaths()[0]){} virtual void operator()(Node* node, NodeVisitor* nv) { ref_ptr<Camera> cam=node->asCamera(); if(cam) { Matrix mat2=cam->getViewMatrix(); Matrix mat=computeWorldToLocal(_nodepath); cam->setViewMatrix(mat); } traverse(node, nv); } }; It feels like this is such a common requirement that something like it should be built into OSG. I had a look at the tutorial on the subject : http://trac.openscenegraph.org/projects/osg//wiki/Support/Tutorials/CameraControlNodeFollowing but it recommends a solution that seems even more generally useful and is quite verbose, yet is not included in osg. What am I missing here? Regards Hannes Naude On Tue, Apr 11, 2017 at 1:08 PM, Hannes Naude <naude...@gmail.com> wrote: > Hi all > > I am trying to render a single scene from multiple viewpoints. I initially > implemented this with a compositeviewer as per the osgthirdpersonview > example. This worked fine except that my update callbacks appeared to be > getting called more than once per render cycle. I assumed that the update > traversal was being done for each view separately and therefore nodes that > are present in multiple views will have their update callbacks called > multiple times. So, at this point I tried to do the same thing but with a > single View, somewhat similar to the osgCamera example. But, I do not want > to add my cameras with viewer.addSlave as I want them to move independently > of one another. So I tried adding them into the scene graph and giving each > their own GraphicsContext, but even though the windows corresponding to > these GraphicsContexts get created, it appears as if all rendering is done > in a single window with multiple viewpoints being rendered over one another. > > Obviously there are many ways to skin this cat, but I would appreciate > some guidance on the recommended approach. To recap my requirements are : > - Multiple cameras viewing the same scene. > - Camera positions and orientations must be independently controlled. > - Node update callbacks should be called only once per Node per render > cycle. > > Any help will be appreciated > > Regards > Hannes Naude >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org