<div dir="ltr">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:<div><br></div><div>camera.SetFocalPoint(pos[0] + d * zvec[0], pos[1] + d * zvec[1], pos[2] + d * zvec[2]);<br></div><div><br></div><div>where d is the distance. </div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><br><div>Regards</div><div>Naimul Mefraz Khan</div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Aug 20, 2015 at 11:55 AM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 20, 2015 at 7:47 AM, naimulkhan <span dir="ltr"><<a href="mailto:naim.13@gmail.com" target="_blank">naim.13@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hi David,<br>
<br>
I am in the same boat as the opener of this thread. I am trying to use an<br>
external tracker (NDI Aurora) to control the vtkCamera (basically "look<br>
through" the position and orientation of the tracker). I can set the<br>
position through vtkCamera::SetPosition() easily, but I am not sure what<br>
parameters SetViewUp() and SetFocusPoint() should be called with. Any help<br>
would be greatly appreciated, thanks!<br></blockquote><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>The second unit vector that we will use is the camera's local Y axis. This is just the ViewUp direction.</div><div><br></div><div>I advise taking a look at Figure 3.9 on this web page: <a href="http://www.glprogramming.com/red/chapter03.html" target="_blank">http://www.glprogramming.com/red/chapter03.html</a></div><div><br></div><div>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:</div><div><br></div><div>double pos[3] = { 0.0, 0.0, 0.0 };</div><div>double zvec[3] = { 0.0, 0.0, 1.0 };</div><div>double yvec[3] = { 0.0, 1.0, 0.0 };</div><div><br></div><div>transform->TransformPoint(pos, pos);</div><div>transform->TransformVector(zvec, zvec);</div><div>transform->TransformVector(yvec, yvec);</div><div><br></div><div>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.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div> - David</div><div> </div></font></span></div></div></div>
</blockquote></div><br></div>