<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks David,<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I got it to work perfectly as long as I'm looking at the scene from the top. But when i rotate the scene, e.g. tilt it forward around the x-axis, then the dragging of the pieces lags behind the mouse. Geometrically I somehow understand why, as I'm constraining to only move the piece in the x-y plane and the Display2World transformation is also returning a z-component that I'm ignoring. Is there a shortcut in vtk to do the necessary z to x,y projections, or should i just figure it out on my own? Again, my requirement is that the mouse should stay around the same position on the piece, as I'm moving it around.<br>
<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Regards,<br>Dov<br><br></div><div style id="divCleekiAttrib"></div><div style id="divCleekiAttrib"></div></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Tue, Apr 8, 2014 at 11:19 PM, 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">
Hi Dov,<br>
<br>
I use a function like this:<br>
<br>
void DisplayToWorld(vtkRenderer *renderer,<br>
double x, double y, double z, // window coordinates (the input)<br>
double world[3]) // world coordinates (the output)<br>
{<br>
// Use the vtkViewport interterface for conversions.<br>
renderer->SetDisplayPoint(x, y, z);<br>
renderer->DisplayToWorld();<br>
double hcoord[4];<br>
renderer->GetWorldPoint(hcoord);<br>
world[0] = hcoord[0]/hcoord[3];<br>
world[1] = hcoord[1]/hcoord[3];<br>
world[2] = hcoord[2]/hcoord[3];<br>
}<br>
<br>
It is not enough to have just the xy window coordinates. You also<br>
need a z window coordinate, which is a depth value in the range [0,1].<br>
Usually you get the depth from the pick.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Apr 8, 2014 at 2:03 PM, Dov Grobgeld <<a href="mailto:dov.grobgeld@gmail.com">dov.grobgeld@gmail.com</a>> wrote:<br>
> I'm trying to create a toy x-y board which has pieces, realized as Actors,<br>
> that I can drag around in the x-y plane. Through the vtkPicker() I have<br>
> figured out how to choose a piece, and I can get the render window<br>
> coordinates through GetInteractor().GetEventPosition(). Further, if I now<br>
> move the mouse I can calculate a Dx,Dy shift in the window coordinate. But I<br>
> would now like to translate the Window Dx,Dy to an Actor Dx,Dy shift. I.e. I<br>
> would like to take a two pairs of xy coordinates in window coordinates and<br>
> calculate their respective positions in actor coordinates, according to the<br>
> current actor to dispay matrix. How can I do that?<br>
><br>
> Thanks in advance!<br>
> Dov<br>
</div></div></blockquote></div><br></div>