[vtkusers] Picking
Denis Shamonin
dshamoni at science.uva.nl
Mon Mar 31 03:47:05 EST 2003
ramu chandran wrote:
> Hello Users,
> Can somebody please tell me how to pick a point upon
> mouse click. I get X and Y coordinate of the window upon mouseClick.
> now how do I pick the particular point of the 3D object using these
> two coordinates. I tried using vtkPointPicker, but its not working
> properly. A small example code will be of great help. I am running out
> of time. please somebody help me.
I think this can help you a little :)
==================================================
MyClass::MyClass()
{
picker = vtkCellPicker::New();
}
void MyClass::SelectPoint(int X, int Y)
{
float Point[3];
if(PickPoint(X,Y,Point))
{
cout<<"Point("<<Point[0]<<","<<Point[1]<<","<<Point[2]<<")\n";
renwin->Render();
}
}
int MyClass::PickPoint(int X,int Y,float Point[3])
{
float *pos;
int result = picker->Pick((float)X,(float)Y,0.0,ren);
if (result)
{
pos = picker->GetPickPosition();
for(int i=0;i<3;i++)
Point[i] = pos[i];
return 1;
}
return 0;
}
--
Denis Shamonin
Address : Section Computational Science
University of Amsterdam
Kruislaan 403, 1098 SJ Amsterdam
the Netherlands
E-mail : dshamoni at science.uva.nl
URL : http://www.science.uva.nl/~dshamoni/
More information about the vtkusers
mailing list