[vtkusers] Re: vtkPanel translate problem
Jeff Lee
jeff at cdnorthamerica.com
Fri Mar 7 06:41:51 EST 2003
yes, please send the whole thing so I can see what you are trying to do.
-Jeff
Brandon Douthit-Wood wrote:
>Jeff,
>Here are a few snippets of code from my app. I can send you all the
>files if you want to try and run it.
>
>// here's where I setup the render window and renderer for the file
>// importer
>renderWindow = visPanel.GetRenderWindow();
>renderer = visPanel.GetRenderer();
>fileImporter = new vtk3DSImporter();
>fileImporter.SetRenderWindow(renderWindow);
>fileImporter.ComputeNormalsOn();
>fileImporter.SetFileName(filename);
>fileImporter.Read();
>visPanel.SetRenderer(renderer);
>
>// this is the code that is used for translate (nothing was changed)
>if (this.InteractionMode == 2)
>{
> double FPoint[];
> double PPoint[];
> double APoint[] = new double[3];
> double RPoint[];
> double focalDepth;
>
> // get the current focal point and position
> FPoint = cam.GetFocalPoint();
> PPoint = cam.GetPosition();
>
> // calculate the focal depth since we'll be using it a lot
> ren.SetWorldPoint(FPoint[0],FPoint[1],FPoint[2],1.0);
> ren.WorldToDisplay();
> focalDepth = ren.GetDisplayPoint()[2];
>
> APoint[0] = rw.GetSize()[0]/2.0 + (x - lastX);
> APoint[1] = rw.GetSize()[1]/2.0 - (y - lastY);
> APoint[2] = focalDepth;
> ren.SetDisplayPoint(APoint);
> ren.DisplayToWorld();
> RPoint = ren.GetWorldPoint();
> if (RPoint[3] != 0.0)
> {
> RPoint[0] = RPoint[0]/RPoint[3];
> RPoint[1] = RPoint[1]/RPoint[3];
> RPoint[2] = RPoint[2]/RPoint[3];
> }
> cam.SetFocalPoint(
> (FPoint[0]-RPoint[0])/2.0 + FPoint[0],
> (FPoint[1]-RPoint[1])/2.0 + FPoint[1],
> (FPoint[2]-RPoint[2])/2.0 + FPoint[2]);
> cam.SetPosition(
> (FPoint[0]-RPoint[0])/2.0 + PPoint[0],
> (FPoint[1]-RPoint[1])/2.0 + PPoint[1],
> (FPoint[2]-RPoint[2])/2.0 + PPoint[2]);
> resetCameraClippingRange();
> }
>
>thanks,
>
>--
>Brandon Douthit
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
>
--
Jeff Lee
Software Engineer
Computational Dynamics North America Ltd
21 Lafayette Street, Suite 230
Lebanon NH 03766 USA
fax: 603 643 9994
phone: 603 643 9993 x109
http://www.cd-adapco.com
More information about the vtkusers
mailing list