Page 1 of 1

get the mouse position in the point coud

Posted: Sun Apr 17, 2016 9:45 am
by zzwbeyond
Hi,

I want to add box primitive in the point cloud, and the center of the box is the mouse position. So how can I get the position(X,Y,Z) of the mouse in the point cloud?

Thanks.

Re: get the mouse position in the point coud

Posted: Mon Apr 18, 2016 9:18 am
by daniel
To get the position of the mouse relatively to a 3D view, you can connect a slot to the 'mouseMoved' event of the 3D view.

Then you can reproject a 2D position in 3D by using the 'ccGLCameraParameters' structure of the same window (the 'unproject' method notably).

But mind that the 'z' coordinate is arbitrary! You might have to be a little more clever here to get a proper position.