Hi folks,

I am using the z-Buffer in osg 2.4 and have problems getting reasonable values. 
When the camera is about two meters away from any flat object surface, I'll get 
the value 0.995, and when the camera  is about eight meters away i'll get 0.997 
from the z buffer. I have also tried to transform the z value into a distance 
value, but the distance value makes no sense! Below is my code!

Cheers, Roland

osgViewer::View* view = new osgViewer::View; 
viewer.addView(view);

view->setSceneData(root); 
   
view->getCamera()->setProjectionMatrixAsPerspective(V_FoV_deg,V_FoV_deg/H_FoV_deg,1,100);
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, 64, 48 )); 
view->getCamera()->setGraphicsContext(gc.get());

osg::Image* image = new osg::Image();
view->getCamera()->attach(osg::Camera::DEPTH_BUFFER,image);
        
image->allocateImage(64,48,1,GL_DEPTH_COMPONENT,GL_FLOAT);

float z;

while( !viewer.done() )
{
   viewer.frame();

    z = ((float*)pmdimage->data())[1];
    std::cout << "z value : " << z << std::endl;
}

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13976#13976





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

Reply via email to