[vtkusers] Problem Interpreting z-buffer data. -- how to convert z-buffer values to quantitative measurements !!!!!!

Deepak Roy cdeepakroy at yahoo.com
Thu Dec 8 15:36:29 EST 2005


Hello Clinton,
   
  Thank you very much for the reply. I really appreciate it....
   
  What do you mean when u mentioned "You'd also have to take samples to find the width & height in world coordiantes of a screen pixel." I suppose you are talking about the volume of each screen pixel. Could you please explain how to find this in more detail ?
   
  I have looked into the code of vtkSelectVisiblePoints. It consists of the forward transformation and what i want is an inverse of it probably. 
   
  In vtkSelectVisiblePoints, given object coordinates of the geometry, for example one of the vertices of the geometry we are rendering. 
   
    
   It is first converted to view coordinates using vtkCamera::GetCompositePerspectiveTransformMatrix( 1 , 0 , 1 ).  
   Then it is converted to display coordinates using vtkRenderer::ViewToDisplay  
   The z value of the Display Coordinate is the z-buffer value we get.
  Now i wrote code to do the exact reverse
   
    
   I convert the Display coordinates to View coordinates using vtkRenderer::DisplayToView  
   Then i convert the view coordinates to world or object coordinates using the inverse of the matrix obtained using vtkCamera::GetCompositePerspectiveTransformMatrix( 1 , 0 , 1 ).  
   This will give me the object coordinates. I do this in each execution of the inner loop that computes the difference of the z-values.
  Is this z-difference my final volume estimate or do i have to do any more transformation using the volume of a screen pixel ???? 
   
  Dont you think this difference is still not independent of the display viewport ? 
   
  Because for a simple testcase, a hemisphere of radius 8 whose volume should be approx 1072 units -----------> the computed z-difference is 185493.18 units which is not the volume obviously ?
   
  What more transformation is needed ?
   
  Thanks in Advance.
   
  Regards,
   
  Deepak
   
   
  

Clinton Stimpson <clinton at elemtech.com> wrote:
  
You can look at the code in vtkSelectVisiblePoints to see how to 
transform between z-buffer data to world coordinates.
You'd also have to take samples to find the width & height in world 
coordiantes of a screen pixel.

To find the volume enclosed in a set of triangulated surfaces, one can 
walk each triangle and sum the volumes of imaginary tetrahedrons where 
each tetrahedron is composed of three points of a triangle and the 
origin (0,0,0).

vtkRenderer::ParallelProjectionOn is all you need for orthographic 
projection.

Clint

>Date: Thu, 8 Dec 2005 08:55:41 -0800 (PST)
>From: Deepak Roy 
>Subject: [vtkusers] Problem Interpreting z-buffer data. -- how to
> convert z-buffer values to quantitative measurements !!!!!!
>To: vtkusers at vtk.org
>
>hello,
> 
> I am trying to compute the volume enclosed between two surface by subtracting the z-buffers of the two surfaces. I am using parallel projection for the computation.
> 
> I computed the z-buffer difference, This difference is relative to the viewport size set up. I have no idea how to convert this difference to a quantitative estimate of the voume. I have problems interpreting the z-buffer data.
> 
> Firslty, how to set the orthographic projection in VTK ? i call vtkRenderer::ParallelProjectionOn and then invoke vtkRenderer::ResetCamera. Is this enough ? or is anything wrong. Because when i looked through the VTK code, i found glOrtho in vtkCamera::ComputePerspectiveTransform.
> 
> How can i transform the z-buffer values to quantitative z-values of the geometry renderer ?
> 
> I tried multiplying it with the inverse of the vrkCamera::GetViewTransformation matrix but it doesnt work.
> 
> I also tried doing vtkCamera::ViewToWorld on the final difference but this still does not work.
> 
> Can anyone tell me, how to transform the z-buffer difference to a quantitative estimate of the volume. 
> 
> Please Help !!!!!!!!
> 
> Thanks in advance.
> 
> Regards,
> 
> Deepak 
> 
>

  


			
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051208/b57bf3be/attachment.htm>


More information about the vtkusers mailing list