[vtkusers] Problem moving a sphere through the 3D space
Yumin Yuan
yumin.yuan at kitware.com
Wed Jan 9 10:28:54 EST 2013
Try this:
double center[3];
mSphere->GetCenter(center);
mSphere->SetCenter(point[0],point[1],center[2]);
Yumin
On Wed, Jan 9, 2013 at 6:32 AM, Imanol Muñoz Pandiella
<imanolm at lsi.upc.edu> wrote:
> Hello,
>
> in my vtk application i am visualizing a sphere in the space. I would like
> to move the sphere with the mouse along the x and y axis of the camera's
> reference frame. I mean, i don't want to modify the position in the z axis
> of the camera's reference frame.
>
> In this way, I'm using the following code during the mouse movement to
> obtain the new position of the sphere after an interaction with the mouse:
>
> double point[3];
> mCellPicker->Pick(mStyle->GetInteractor()->GetEventPosition()[0],
> mStyle->GetInteractor()->GetEventPosition()[1],
> 0,
> mStyle->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
> mCellPicker->GetPickPosition(point);
> mSphere->SetCenter(point[0],point[1],point[2]);
>
> where mCellPicker and mStle are declared as follows:
> vtkCellPicker *mCellPicker;
> vtkInteractorStyleTrackballCamera* mStyle;
>
> The problem is the position of the sphere is modified in the x and y axis of
> the camera's reference frame and also, in the z axis. In this axis the
> sphere is placed in the middle of the zMin and zMax of the volume space.
>
> To ensure that the picker is not interacting with the rest of the actors of
> the scene, i use the following code whe the mouse button is pressed down
> without setting the actor list of the picker supposing that the picker will
> use an empty actor's list:
> mCellPicker->PickFromListOn();
>
> and the following code when the mouse button is released:
> mCellPicker->PickFromListOff();
>
> I have seen in another application that it can be done with a
> vtkPointWidget, and the translation works fine. The problem is I need this
> functionality to spheres, cylinders, semi-spheres, ...
>
> What am I doing wrong? How can I translate the sphere through the volume
> space without modifying the position of it in the z axis of the camera's
> reference frame?
>
> Thank you very much for your help!
>
> --
> Imanol Muñoz i Pandiella.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list