Re: [osg-users] View not as expected
Hi Sanat, Your subject line says View not as expected, but reading your email I don't get any qualification of this. Until you explain exactly what is wrong nobody will be able to help you. Robert. On Mon, Jul 5, 2010 at 11:24 PM, Sanat Talmaki sanat.sch...@gmail.com wrote: Hi, I am trying to use osgViewer::CompositeViewer to get multiple views of my scene. In the screenshot attached, I have the topmost view as the that of the overall scene. However I wanted the bottom-left view to be that of the just one of the models in the scene and following it in a manner similar to the out-of-car view seen in many car racing games. (the bottom right view has not yet been set but that would be similar only focusing on the other model in the scene). I looked at the osgthirdperson view example but wasn't sure if that was the way to go. Any help would be appreciated. Thanks, Regards, Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29707#29707 Attachments: http://forum.openscenegraph.org//files/test_sc1_589.jpg ___ 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
Re: [osg-users] View not as expected
Hi Robert, Ah yes, my post's title may have been misleading. But what I am trying is: For the top-most view, I add the whole scene to the view: Code: view-setSceneData(root); view-setCameraManipulator(new osgGA::TrackballManipulator); view-getCamera()-setUpdateCallback(new CameraFollowMyNodeCallback(backhoe1PAT)); For the bottom left view, I wanted a view of the 3D model (backhoe) and the terrain with the camera either inside the cab of the backhoe or hovering just above it. So I did the following: Code: view-setSceneData(backhoe1PAT); //where backhoe1PAT is the positionAtttransform of the 1st backhoe. view-setCameraManipulator(new osgGA::TrackballManipulator); view-getCamera()-setUpdateCallback(new CameraFollowMyNodeCallback(backhoe1PAT)); //follows backhoe1 in the overall scene view as in the topmost scene However on running this code, as you can see the bottom-left view shows only the backhoe and not resting on the underlying terrain. So I wanted to know what I am doing wrong Thanks Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29729#29729 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] View not as expected
Hi Sanat, It doesn't make sense to attach a CameraManipulator which updates the camera position and an update callback to update it's position, use one or the other. Robert. On Tue, Jul 6, 2010 at 3:01 PM, Sanat Talmaki sanat.sch...@gmail.com wrote: Hi Robert, Ah yes, my post's title may have been misleading. But what I am trying is: For the top-most view, I add the whole scene to the view: Code: view-setSceneData(root); view-setCameraManipulator(new osgGA::TrackballManipulator); view-getCamera()-setUpdateCallback(new CameraFollowMyNodeCallback(backhoe1PAT)); For the bottom left view, I wanted a view of the 3D model (backhoe) and the terrain with the camera either inside the cab of the backhoe or hovering just above it. So I did the following: Code: view-setSceneData(backhoe1PAT); //where backhoe1PAT is the positionAtttransform of the 1st backhoe. view-setCameraManipulator(new osgGA::TrackballManipulator); view-getCamera()-setUpdateCallback(new CameraFollowMyNodeCallback(backhoe1PAT)); //follows backhoe1 in the overall scene view as in the topmost scene However on running this code, as you can see the bottom-left view shows only the backhoe and not resting on the underlying terrain. So I wanted to know what I am doing wrong Thanks Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29729#29729 ___ 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
Re: [osg-users] View not as expected
Hi Sanat, For the bottom left view, I wanted a view of the 3D model (backhoe) and the terrain with the camera either inside the cab of the backhoe or hovering just above it. So I did the following: Code: view-setSceneData(backhoe1PAT); //where backhoe1PAT is the positionAtttransform of the 1st backhoe. view-setCameraManipulator(new osgGA::TrackballManipulator); view-getCamera()-setUpdateCallback(new CameraFollowMyNodeCallback(backhoe1PAT)); //follows backhoe1 in the overall scene view as in the topmost scene However on running this code, as you can see the bottom-left view shows only the backhoe and not resting on the underlying terrain. So I wanted to know what I am doing wrong Well, it seems to me you're getting the results your code asks for. view-setSceneData(backhoe1PAT); means that the view1 will only see the backhoe, because it's the only scene graph it knows about. You need to do view-setSceneData(root); Additionally, as Robert said, your camera manipulator and your camera update callback will fight to control the values in your camera's view matrix (i.e. they will each try to change your camera's position). Use one or the other. If you want to follow the backhoe in a fixed way you can use a camera update callback, but if you want to follow it but be able to change the angle with the mouse use a camera manipulator, in particular osgGA::NodeTrackerManipulator can do this. Search the OSG examples in the source code to see how to use it. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] View not as expected
Hi JS, Rob I understand what you meant by having either the manipulator or the update callback. The NodeTrackerManipulator worked perfectly. It gives me the exact behavior I wanted except for the fact that its default orientation is a side on view to my model node. I can rotate that with my mouse and change the view to my preference. But I would like to have the scene display with that view itself. I din't find any function in the source that allowed me to change rotation of the manipulator as the function Code: void computeNodeCenterAndRotation(osg::Vec3d center, osg::Quat rotation) const; is protected but it looks like it could do the trick for me. It is referenced in the public function Code: osg::Matrixd NodeTrackerManipulator::getMatrix() While I have used quat to set and change rotation in my code, I haven't used Matrixd. So I was hoping to know how I can get around this ? Thanks. Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29740#29740 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] View not as expected
Hello Sanat, The NodeTrackerManipulator worked perfectly. It gives me the exact behavior I wanted except for the fact that its default orientation is a side on view to my model node. I can rotate that with my mouse and change the view to my preference. But I would like to have the scene display with that view itself. I din't find any function in the source that allowed me to change rotation of the manipulator as the function To set the initial position/orientation of a CameraManipulator you use setHomePosition() (defined in osgGA::MatrixManipulator which osgGA::NodeTrackerManipulator inherits). You could also use setByMatrix()/setByInverseMatrix() but some manipulators used to have empty implementations for these (I don't know which have changed now, but for these historic reasons I don't generally use them). Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] View not as expected
Hi, I am trying to use osgViewer::CompositeViewer to get multiple views of my scene. In the screenshot attached, I have the topmost view as the that of the overall scene. However I wanted the bottom-left view to be that of the just one of the models in the scene and following it in a manner similar to the out-of-car view seen in many car racing games. (the bottom right view has not yet been set but that would be similar only focusing on the other model in the scene). I looked at the osgthirdperson view example but wasn't sure if that was the way to go. Any help would be appreciated. Thanks, Regards, Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29707#29707 Attachments: http://forum.openscenegraph.org//files/test_sc1_589.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org