[vtkusers] Question on manual configuration of VTK camera
Naimul Khan
naim.13 at gmail.com
Tue Aug 25 16:54:08 EDT 2015
That worked, thank you so much! For anyone looking at this thread, this is
the right solution. To add to David, in my case, I wanted the focal point
always at a certain distance along the camera's local Z axis. To compute
that, just do the following in addition to what David did:
camera.SetFocalPoint(pos[0] + d * zvec[0], pos[1] + d * zvec[1], pos[2] + d
* zvec[2]);
where d is the distance.
Regards
Naimul Mefraz Khan
On Thu, Aug 20, 2015 at 11:55 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> 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/20150825/0f214cb9/attachment.html>
More information about the vtkusers
mailing list