[vtkusers] Z-buffer and picking

Julian Ibarz julian.ibarz at gmail.com
Wed Jun 25 04:44:25 EDT 2008


Fixed, it's a bug from vtk, I made a bug report :

http://www.vtk.org/Bug/view.php?id=7236

2008/6/23 Julian Ibarz <julian.ibarz at gmail.com>:

> Hello everyone,
>
> I'm actually working on a picking that don't draw all the objets of the
> scene but only the pickable objects. In fact my scene contains for example
> 400 actors of 4 types of datas. My user want to select only one type of
> data. But he wants to select only the actors visibles.
>
> So to not draw all the actors on the pick rendering (i use
> vtkVisibleCellSelector for personnal implementation reason) I change a
> little VTK and I don't erase the z-buffer on the pick rendering. This
> permits to me to render only the actors pickable and to be sure that they
> are visible when all the actors are rendered.
>
> This works when the selection area is a point. But when the selection area
> is a rectangle the z-buffer is reset to 0 and I don't know where. A
> developper of VTK could tell me where in the code the z-buffer is set to 0
> and why ? (by default a clear z-buffer is equal to 1, the infinite, 0 is the
> near plan).
>
> This is the key code that shows the setting 0 of the z-buffer (in java ) :
>
> vtkFloatArray beforeNative = new vtkFloatArray();
>         canvas.GetRenderWindow().GetZbufferData(firstPoint[0],
> firstPoint[1], secondPoint[0], secondPoint[1], beforeNative);
>         float[] before = beforeNative.GetJavaArray();
>
> // Making my picking
>
> vtkFloatArray afterNative = new vtkFloatArray();
>         canvas.GetRenderWindow().GetZbufferData(firstPoint[0],
> firstPoint[1], secondPoint[0], secondPoint[1], afterNative);
>
>         float[] after = afterNative.GetJavaArray();
>
>         System.out.println("Z-BUFFER : ");
>         for(int i = 0 ; i < before.length ; ++i)
>         {
>             System.out.println(before[i] + " -> " + after[i]);
>         }
>
> The output for a point selection :
>
> Z-BUFFER :
> 0.37655056 -> 0.37655056
>
> The output for a rectangle selection :
>
> Z-BUFFER :
> 0.0 -> 0.4381339
> 0.0 -> 0.43666053
> 0.0 -> 0.43538022
> 0.0 -> 0.4345476
> 0.0 -> 0.43371505
> 0.0 -> 0.43288243
> 0.0 -> 0.43204987
> 0.0 -> 0.43142706
> 0.0 -> 0.43115902
> 0.0 -> 0.43089098
> 0.0 -> 0.43062294
> 0.0 -> 0.4303549
> 0.0 -> 0.43019688
> 0.0 -> 0.43046153
> 0.0 -> 0.43072623
> 0.0 -> 0.43099087
> 0.0 -> 0.43125558
> 0.0 -> 0.43152028
> 0.0 -> 0.43230826
> 0.0 -> 0.43310922
> 0.0 -> 0.4339102
> 0.0 -> 0.43471116
> 0.0 -> 0.43551213
>
> Any suggestion ?
>
> --
> Julian Ibarz




-- 
Julian Ibarz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080625/1b40adc0/attachment.htm>


More information about the vtkusers mailing list