[vtkusers] Problem moving a sphere through the 3D space

Imanol Muñoz Pandiella imanolm at lsi.upc.edu
Wed Jan 9 06:32:17 EST 2013


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.




More information about the vtkusers mailing list