[vtkusers] Question on manual configuration of VTK camera

David Gobbi david.gobbi at gmail.com
Thu Aug 20 11:55:38 EDT 2015


On Thu, Aug 20, 2015 at 7:47 AM, naimulkhan <naim.13 at gmail.com> wrote:

> hi David,
>
> I am in the same boat as the opener of this thread. I am trying to use an
> external tracker (NDI Aurora) to control the vtkCamera (basically "look
> through" the position and orientation of the tracker). I can set the
> position through vtkCamera::SetPosition() easily, but I am not sure what
> parameters SetViewUp() and SetFocusPoint() should be called with. Any help
> would be greatly appreciated, thanks!
>

Consider: any frame of reference can be described by a point and two unit
vectors.  The "point" is easy, it's the camera's Position.

The first unit vector that we will use is the camera's local Z axis, which
points _away_ from the focal point, i.e. it points out the back of the
camera.  In other words, its direction is from the FocalPoint to the
Position.

The second unit vector that we will use is the camera's local Y axis.  This
is just the ViewUp direction.

I advise taking a look at Figure 3.9 on this web page:
http://www.glprogramming.com/red/chapter03.html

So, let's say that you have a vtkTransform that describes where you want to
place the camera.  How can you get the position and the two vectors?  Easy,
just apply the transform to the origin, to a unit z vector, and to a unit y
vector:

double pos[3] = { 0.0, 0.0, 0.0 };
double zvec[3] = { 0.0, 0.0, 1.0 };
double yvec[3] = { 0.0, 1.0, 0.0 };

transform->TransformPoint(pos, pos);
transform->TransformVector(zvec, zvec);
transform->TransformVector(yvec, yvec);

That's as far as I'll go, you should be able to figure out the math for
computing the FocalPoint from the Position, the zvec, and the Distance from
the camera to the object it is looking at.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150820/0e3c95e9/attachment.html>


More information about the vtkusers mailing list