Hello everyone! I'm writing a bit of code using parts of OSG and pure OpenGLES2. This isn't exactly an OSG question, per se, but there are a lot of OpenGL experts here and this is a great resource. :) Any help is appreciated!

In my particular scene, I do not maintain a matrix representing my "camera"; there is a global projection matrix and each Drawable maintains its own model matrix. For this reason, whether pedantically right or wrong, I say that my camera always sits at 0, 0, 0 and looks into a frustum created using the equivalent of gluPerspective(45, 1, 1, 100).

What I'm looking for is the trigonometric calculation that would allow me to determine either the Z value to translate my scene or the scale to apply to my scene in order to fit the entire thing cleanly into my viewport.

I have both the osg::BoundingBox and osg::BoundingSphere of my scene, but since I'm not using a camera manipulator or view matrix directly, I can't simply reference the code in CameraManipulator.cpp.

Furthermore: I have this working currentls in a VERY TERRIBLE way. :) What I do is use reimplementations of gluProject and gluUnproject to caclulate screen-to-world and world-to-screen coordinates. I then use those values to figure out how much to scale my scene by, but this feels so wrong (and bound to a known window size) that I know there must be a better way.

Thanks!
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to