[vtkusers] Re: reticle / crosshair

Goodwin Lawlor goodwin.lawlor at ucd.ie
Fri Jun 23 10:43:08 EDT 2006


Marty Humperdink wrote:
> I'm working on a project to test the pointing accuracy
> of a 3D tracking system and am using VTK to visualize
> results. I'm rendering a 3D scene where the actors
> remain fixed (in world coordindates) but I move the
> camera based on measured data to create frames for an
> animation. I'd like to include a fixed reference
> feature (crosshair or reticle) in each frame that
> stays in the same positon wrt the camera and borders
> of the image frame and shows what is "in the line of
> fire" of the camera. 
> 
> I first tried vtkCursor3D to create an actor that
> moves with the camera in order to produce crosshairs
> in each frame, but haven't been satisfied with the
> look of the results.
> 
> It seems like another apporach would be to overlay a
> 2D image onto the rendering of the 3D actors. To do
> this I'm guessing I would need to create a 2D image of
> crosshairs with an alpha channel then use
> vtkImageBlend to overlay this onto each frame, but am
> not certain how to do this. Do I need to first use
> vtkWindowToImageFilter to make a 2D image of the
> rendered scene then blend this with a image of the
> crosshairs?
> 
> Many thanks for suggestions or opinions.

Hi Marty,

Have a look at /vtk/examples/annotation/tcl/labeledMesh.tcl for an 
example of what you want. Here's the important code:

# Create a selection window.

set xmin 200
set xLength 100
set xmax [expr $xmin + $xLength]
set ymin 200
set yLength 100
set ymax [expr $ymin + $yLength]

vtkPoints pts
     pts InsertPoint 0 $xmin $ymin 0
     pts InsertPoint 1 $xmax $ymin 0
     pts InsertPoint 2 $xmax $ymax 0
     pts InsertPoint 3 $xmin $ymax 0
vtkCellArray rect
     rect InsertNextCell 5
     rect InsertCellPoint 0
     rect InsertCellPoint 1
     rect InsertCellPoint 2
     rect InsertCellPoint 3
     rect InsertCellPoint 0
vtkPolyData selectRect
     selectRect SetPoints pts
     selectRect SetLines rect
vtkPolyDataMapper2D rectMapper
     rectMapper SetInput selectRect
vtkActor2D rectActor
     rectActor SetMapper rectMapper

hth

Goodwin




More information about the vtkusers mailing list