Re: [osg-users] ABSOLUTE_RF problem
HI Guillaume, 2010/7/8 Guillaume Tazé guillaume.t...@gmail.com: Hello, i'm trying to understand how ABSOLUTE_RF works, and i've made a small example. The problem is that it should works but it actually doesn't... ABSOLTE_RF means that the when the cull traversal encounters a Transform node it ignores the inherited modelview matrix so that the local transform matrix on the Transform node becomes the new modelview matrix. This means that the Transform nodes subgraph is placed in new coordinate frame rather than that of it's parents. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] ABSOLUTE_RF problem
Hello, i'm trying to understand how ABSOLUTE_RF works, and i've made a small example. The problem is that it should works but it actually doesn't... In the following lines : osg::Group * group = new osg::Group(); { //Relative osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform(); pat-setPosition(osg::Vec3(-10,0,0)); pat-addChild(osgDB::readNodeFile(cow.osg)); pat-setReferenceFrame(osg::Transform::RELATIVE_RF); group-addChild(pat); } { //Absolute osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform(); pat-addChild(osgDB::readNodeFile(cow.osg)); pat-setReferenceFrame(osg::Transform::ABSOLUTE_RF); //pat-setReferenceFrame(osg::Transform::RELATIVE_RF); pat-setPosition(osg::Vec3(10,0,0)); group-addChild(pat); } group-setEventCallback(new CEventCallback()); viewer.setSceneData(group); viewer.getCamera()-setCullingMode(osg::CullSettings::CullingModeValues::NO_CULLING); if i change pat-setReferenceFrame(osg::Transform::ABSOLUTE_RF); to pat-setReferenceFrame(osg::Transform::RELATIVE_RF); the two cows are here, but when the second pat is absolute, the second cow won't show... however i can actually pick it if i click on the area where it should be. I don't understand why it's not working... can someone helps me ? You can find the source file attached to this mail. i've made this test program because i have another problem where i try to pick an object which is in a pat with ABSOLUTE_RF, and can't make it work (i can pick all others objects but not the ones with absolute_rf...) Thanks --- Guillaume Tazé Main.cpp Description: Binary data ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] ABSOLUTE_RF problem
Hi Pavel, The RefererenceFrame in Transform is widely used and does work robust with ABSOLTE_RF - this is how most users with do HUDs (Camera is a subclass from Transform.) Just becuase the view matrix is identity doesn't mean that any subgraph underneath will be visible, far from it, the subgraph will only be visible if the objects local coordinates place it in front of the camera. In your transform set up code place add a query of the center of the subgraph and then create a transform that takes this to a position in front of the eye point. Robert. On Tue, Jan 27, 2009 at 8:49 AM, Pavel Domša pdo...@seznam.cz wrote: Hi all, i have an issue with osg::TransformMatrix::SetReferenceFrame and it's either bug or my misunderstanding. Documentation on osg::Transform explains difference between ABSOLUTE_RF and RELATIVE_RF pretty well. Also MatrixTransform.cpp shows how localToWorld transformations are being handled for both and code is clear and understandable. To demonstrate issue i've created simpliest scenario. Hierarchy is root-MatrixTransform-ModelNode(cow). Transformation is identity. By default reference frame is RELATIVE_RF and cow is clearly visible. But when reference frame is set to ABSOLUTE_RF nothing is being rendered at all. I believe that for ABSOLUTE_RF cow should be visible as well since transformation is still identity. I googled a lot but it seems that ABSOLUTE_RF is being used only for osg::Camera settings and i couldn't find any piece of code where it's set on MatrixTransform. So is SetReferenceFrame supposed to work on osg::MatrixTransform as well? i believe it should because it's very handy to share states and attributes from hierarchy above but be able to do transformation in world coords. Demo is attached. Thanks Pavel Domsa #include osg/Node #include osg/MatrixTransform #include osg/Group #include osg/BlendFunc #include osg/Geometry #include osgText/Text #include osgViewer/Viewer #include osgGA/TrackballManipulator #include osgDB/ReadFile #include osgViewer/ViewerEventHandlers int main( int argc, char **argv ) { osg::Referenced::setThreadSafeReferenceCounting(true); int rval = -1; osg::ArgumentParser args( argc, argv ); osg::ref_ptrosg::Node loadedModel = osgDB::readNodeFiles(args); if(!loadedModel) { loadedModel = osgDB::readNodeFile(cow.osg); } std::string filename; osgViewer::Viewer viewer; viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); viewer.addEventHandler(new osgViewer::WindowSizeHandler); viewer.addEventHandler(new osgViewer::StatsHandler); osg::ref_ptr osg::Group scene = new osg::Group; viewer.setSceneData( scene.get() ); osg::ref_ptrosg::MatrixTransform mxt = new osg::MatrixTransform; mxt-addChild(loadedModel.get()); // mxt-setReferenceFrame(osg::Transform::ABSOLUTE_RF); // uncomment here scene-addChild(mxt.get()); viewer.setCameraManipulator(new osgGA::TrackballManipulator()); viewer.run(); return( rval ); } ___ 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