<div dir="ltr"><div>Hi Serge,</div><div><br></div><div>To get the scale right, I add an observer for the renderer's StartEvent</div><div>that does all the necessary calculations to set the position and scale</div><div>of the actor correctly just before the render occurs. It's kind of messy,</div><div>but I don't know a better way. The code that I use to compute the</div><div>correct actor scale is as follows:</div><div><br></div><div><div>void ComputeScale(const double position[3], vtkRenderer *renderer)</div><div>{</div><div> // Find the cursor scale factor such that 1 data unit length</div><div> // equals 1 screen pixel at the cursor's distance from the camera.</div><div> // Start by computing the height of the window at the cursor position.</div><div> double worldHeight = 1.0;</div><div> vtkCamera *camera = renderer->GetActiveCamera();</div><div> if (camera->GetParallelProjection())</div><div> {</div><div> worldHeight = 2*camera->GetParallelScale();</div><div> }</div><div> else</div><div> {</div><div> vtkMatrix4x4 *matrix = camera->GetViewTransformMatrix();</div><div> // Get a 3x3 matrix with the camera orientation</div><div> double cvz[3];</div><div> cvz[0] = matrix->GetElement(2, 0);</div><div> cvz[1] = matrix->GetElement(2, 1);</div><div> cvz[2] = matrix->GetElement(2, 2);</div><div><br></div><div> double cameraPosition[3];</div><div> camera->GetPosition(cameraPosition);</div><div><br></div><div> double v[3];</div><div> v[0] = cameraPosition[0] - position[0];</div><div> v[1] = cameraPosition[1] - position[1];</div><div> v[2] = cameraPosition[2] - position[2];</div><div><br></div><div> worldHeight = 2*(vtkMath::Dot(v,cvz)</div><div> * tan(0.5*camera->GetViewAngle()/57.296));</div><div> }</div><div><br></div><div> // Compare world height to window height.</div><div> int windowHeight = renderer->GetSize()[1];</div><div> double scale = 1.0;</div><div> if (windowHeight > 0)</div><div> {</div><div> scale = worldHeight/windowHeight;</div><div> }</div><div><br></div><div> return scale;</div><div>}</div></div><div><br></div><div>For the other question, it sounds like you want VTK to ignore the depth</div><div>buffer when it renders your actor. I don't know if this is possible. If I need</div><div>an annotation or a cursor to be in front of everything, I do a pick to find the</div><div>depth (i.e. frontmost object) at the position where I want to render my cursor,</div><div>and then I place my cursor at that depth.</div><div><br></div><div> - David</div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 13, 2015 at 2:54 PM, Serge Lalonde <span dir="ltr"><<a href="mailto:serge@infolytica.com" target="_blank">serge@infolytica.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Anyone have any suggestions on how to implement the display of the
origin?<br>
It doesn't have to be axes (although that would be nice).<br>
The trick is to get it to be a fixed size regardless of the camera
zoom and to make it visible even if "hidden" inside of another
actor.<br>
<br>
Thanks for any tips.<span class=""><font color="#888888"><br>
<div>-- <br>
<a href="http:://www.infolytica.com" target="_blank">www.infolytica.com </a><br>
300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3<br>
<a href="tel:%28514%29%20849-8752%20x236" value="+15148498752" target="_blank">(514) 849-8752 x236</a>, Fax: <a href="tel:%28514%29%20849-4239" value="+15148494239" target="_blank">(514) 849-4239</a></div></font></span></div></blockquote></div><br></div></div>