[prev in list] [next in list] [prev in thread] [next in thread]
List: vtkusers
Subject: Re: [vtkusers] Picking
From: Denis Shamonin <dshamoni () science ! uva ! nl>
Date: 2003-03-31 8:47:05
Message-ID: 3E880089.9050403 () science ! uva ! nl
[Download RAW message or body]
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@science.uva.nl
URL : http://www.science.uva.nl/~dshamoni/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic