PDA

View Full Version : SoRayPickAction Problem



artmansoft
04-10-2010, 07:02 AM
Hi,

I have a code in which I'm using a SoTransform node for rotating the model instead of rotating the camera. At some point, I need to pick a point from the model using mouse left button. In the follwoing code:

viewer is an instance of SoQtExaminerViewer
event is an instance of SoEventCallback which is gotten from the mouse event handler
dynObjects is an instance of SoSeparator which contains the dynamic components of the model and its first child is the SoTransform node mentioned above.

Here is the actual code I used for picking a point:

viewer.mode(acuSgViewer.MODE_VIEWING)

vpr = viewer.getViewportRegion()
rpa = SoRayPickAction(vpr)

camera = viewer.getCamera()
pos = event.getNormalizedPosition(vpr)
rpa.setNormalizedPoint(pos)

dynObjects.insertChild(camera, 0)
rpa.apply(self.asg.dynObjects)
dynObjects.removeChild(camera)

pickedPoint = rpa.getPickedPoint()

The pickedPoint is not what I want, but it is a random point. It is either Null or points to a point other than the place that I pressed the mouse button.

Before I used the above method, i.e. when I was using rotation camera instead of model, it worked properly. The problem arises from the SoTransform node probably. Does anybody know any other way to get the picked point?

Thanks in advance,
artmansoft

mikeheck
04-13-2010, 09:37 AM
See response in Open Inventor Forum: http://www.mc3dviz.com/openinventor-forum/showthread.php?p=585#poststop