Hello folks! Last night I started working on adding a few debugging tools to osgWidget (both for myself, and for people to use in the future) and what I'm currently trying to do is provide a hotkey that will allow a user to switch their HUD view from the standard 2D view and "zoom out" to a fully perspective 3D view. The main reason I want to do this is so that people can actively view how all of their Windows/Widgets are "layered" in three dimensions, which will really help me as I finish up this stratum stuff. :) (Don't you love the word stratum?)
In osgWidget, a WindowManager is simply a subclass of osg::Switch with overridden childInserted/childRemoved/etc. methods that properly "transform" an Window object as they are added. More specifically, as Windows are added, a list is maintained internally and used later as all the children are enumerated and their Z values are set in an arbitrary range (though -1.0 - 0.0 is the default, naturally). Assuming that the WindowManager is placed inside a standard 2D HUD-like Camera (that is itself a child of some osgViewer::View/osg::View), what I want to do is grab that Camera and change it to a perspective view. My first attempt looked something like this: ------------------------------------------------------------------- osg::Camera* camera = dynamic_cast<osg::Camera*>(getParent(0)); if(!camera) return false; osg::Matrix m = osg::Matrix::lookAt( osg::Vec3(0.0f, 3.0f, 10.0f), osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 1.0f, 0.0f) ); camera->setProjectionMatrix(m); camera->setReferenceFrame(osg::Transform::RELATIVE_RF); camera->setViewMatrix(osg::Matrix::identity()); camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setRenderOrder(osg::Camera::POST_RENDER); ------------------------------------------------------------------- ...which is close, but not quite right. The biggest issue is that I seem to be getting some funky, but probably understandable, clipping. :) What I'm looking for are some guidelines on how I can approach this. I feel like it should be pretty straightforward, but the fact that I'm manipulating a camera-within-a-camera (how a POST_RENDER/ABSOLUTEL_RF HUD works has always been a mystery to me) seems to complicate matters a bit. Perhaps I need to approach this differently? _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org