Peterakos wrote on 2012-11-07: > Hello. > > I use the following to render a cessna. > > Viewer viewer; viewer.setSceneData(group); Camera* camera = > viewer.getCamera(); camera->setProjectionMatrixAsPerspective(45, 1, 1, > 30); viewer.setUpViewInWindow(40,40,width,height); return viewer.run(); > > > Question 1 > According to perspective, it means that whatever is further than -30, > is out of the view volume and will not be rendered, right ? > I use the right click to make the cessna move away, but i still see it. > What do i do wrong ?
By default, OSG calculates the projection matrix for you; see osg::Camera::setComputeNearFarMode() and DO_NOT_COMPUTE_NEAR_FAR to use the projection matrix you are trying to set. > Question 2 > Is gl_FragCoord.z the right way to get the depth value of a fragment ? > If the answer is yes, why is the cessna's tail white even though is so > close to the screen ? > What's the right way to get teh depth value ? Yes, that's the fragment depth value, but since OSG set the projection matrix and the tail is the farthest geometry, the far plane is immediately beyond it. Therefore, the depth value will be almost one. Also, the depth value is not linear from the near plane to the far plane, so depths very quickly get close to one as the geometry gets farther from the near plane. If you want to see how the depth changes better, you might want to linearize the values (there's lots of help on this on the Internet; for example, http://stackoverflow.com/questions/6652253/getting-the-true-z-value-from -the-depth-buffer). Hope this helps! -- Bryan Thrall Principal Software Engineer FlightSafety International [email protected] _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

