[vtkusers] Perspective view of vtkCursor3D

Karthik Krishnan karthik.krishnan at kitware.com
Tue Sep 14 05:30:42 EDT 2010


On Mon, Sep 13, 2010 at 8:05 PM, Granseier, Michael (VISUS) <
granseier at visus.com> wrote:

> Dear VTK Users,
>
> I'm trying to mark a three-dimensional point in a volume using the
> vtkCursor3D class.
> My problem is, that the length of the crosshairs' lines stay constant, even
> if the position of the point is farther away from the camera.
> I'm using SetModelBounds to specify the length.
>
> The same problem occurs with a vtkSphereSource. The radius of the source
> stays the same, no matter how far away it is from the camera.
>
> Is it possible to scale the crosshairs' lines or the sphere radius relative
> to the camera distance?
> So, that the marker-object becomes smaller, the further the specified point
> is away from the camera and larger, the closer it is?
>
>
I presume you mean "becomes larger the further ..."

3D props maintain a fixed physical (world) size, unlike 2D props which
maintain a fixed display size.

I'd recommend using the vtkHandleWidget, in conjunction with a
vtkPointHandleRepresentation3D. This representation contains a vtkCursor3D
and scales it dynamically based on the camera distance, so that it appears
to maintain the same normalized display size.

Use the widget with event processing disabled (SetProcessEventsOff()) and
its pretty much what you need. Take a look at its tests in VTK for usage.

-------

Alternatively, to dynamically on your own prop you could write a prop that
derives from vtkProp3D and internally contains a vtkCursor3D along with its
associated polydatamapper and actor. Then override the method
RenderOpaqueGeometry to set your own actor scale.... something to the effect
of...

int myProp::RenderOpaqueGeometry(vtkViewport *v)
{
  // Get camera params
  // Use the coordinate conversion methods vtkRenderer to
  // compute the right scale so that your cursor maintains the same
  // extent in normalized display coordinates.
  this->Cursor3DActor->SetScale( computedScale );
  return this->Cursor3DActor->RenderOpaqueGeometry(v);
}


--
karthik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100914/de07f3be/attachment.htm>


More information about the vtkusers mailing list