| 1 |
NAME SoRayPickAction SoRayAct "" { |
| 2 |
intersects objects with a ray cast into scene |
| 3 |
} |
| 4 |
|
| 5 |
INCLUDE actions/SoRayPickAction.h |
| 6 |
|
| 7 |
DESC { |
| 8 |
This class performs picking by casting a ray into a scene and |
| 9 |
performing intersection tests with each object. The ray is extended to |
| 10 |
be a cone or cylinder, depending on the camera type, for intersection |
| 11 |
with points and lines. Each intersection is returned as an |
| 12 |
\cSoPickedPoint\. instance. |
| 13 |
\p |
| 14 |
The picking ray can be specified as either a ray from the camera |
| 15 |
location through a particular viewport pixel, or as a world-space ray. |
| 16 |
In the former case, a valid camera must be encountered during |
| 17 |
traversal of the graph to determine the location of the ray in world |
| 18 |
space. |
| 19 |
\p |
| 20 |
Callers can cause the action to compute all intersections along the |
| 21 |
ray (sorted closest to farthest) by setting the \vpickAll\. flag to |
| 22 |
TRUE. By default, the action computes only the closest intersection. |
| 23 |
In either case, the |
| 24 |
intersections are returned in an \cSoPickedPointList\.. Each |
| 25 |
intersection can be examined by accessing the appropriate |
| 26 |
\cSoPickedPoint\. in the list. The \cSoPickedPoint\. class provides |
| 27 |
methods to get the intersection point, normal, and other info. |
| 28 |
} |
| 29 |
|
| 30 |
METHOD "" SoRayPickAction(const SbViewportRegion &viewportRegion) { |
| 31 |
Constructor takes viewport region to use for picking. Even though |
| 32 |
the picking operation may not involve a window per se, some nodes need |
| 33 |
this information to determine their size and placement. |
| 34 |
} |
| 35 |
|
| 36 |
METHOD setPt void setPoint(const SbVec2s &viewportPoint) { |
| 37 |
Sets the viewport-space point through which the ray passes, starting |
| 38 |
at the camera's viewpoint. Viewport coordinates range from (0,0) at |
| 39 |
the lower left to (width-1,height-1) at the upper right. |
| 40 |
} |
| 41 |
|
| 42 |
METHOD setNormPt void setNormalizedPoint(const SbVec2f &normPoint) { |
| 43 |
Sets the viewport point in normalized coordinates, which range |
| 44 |
from (0,0) at the lower left to (1,1) at the upper right. |
| 45 |
} |
| 46 |
|
| 47 |
METHOD "" void setRadius(float radiusInPixels) { |
| 48 |
Set the radius (in pixels) around the point. This is used when testing |
| 49 |
the ray against lines and points. By default, the radius is 5 pixels. |
| 50 |
For perspective cameras, the ray is extended to be a cone when testing |
| 51 |
against lines and points. For orthographic cameras, the ray is |
| 52 |
extended to be a cylinder. The radius has no effect for shapes of |
| 53 |
other types. |
| 54 |
} |
| 55 |
|
| 56 |
METHOD "" void setRay(const SbVec3f &start, const SbVec3f &direction, |
| 57 |
float nearDistance = -1.0, float farDistance = -1.0) { |
| 58 |
Sets a world-space ray along which to pick. The ray is defined as a |
| 59 |
world space starting point and direction vector. The direction vector |
| 60 |
will be normalized automatically. The last two arguments are the |
| 61 |
parametric distances between which intersections along the ray must |
| 62 |
occur. The distances are measured as if the direction vector is unit |
| 63 |
length; e.g., if \anearDistance\. is 2.0, the intersection must occur |
| 64 |
past (\astart\. + 2*(length of the direction vector)) units along the |
| 65 |
ray. These distances can be used to achieve near and far plane clipping. |
| 66 |
A negative distance (such as the default values) means disable clipping |
| 67 |
to that plane. |
| 68 |
} |
| 69 |
|
| 70 |
METHOD "" void setPickAll(SbBool flag) {} |
| 71 |
METHOD "" SbBool isPickAll() const { |
| 72 |
Sets/returns whether the action will return all objects intersected or |
| 73 |
just the closest one. |
| 74 |
} |
| 75 |
|
| 76 |
METHOD getPickPtList const SoPickedPointList &getPickedPointList() const { |
| 77 |
Returns list of picked points. |
| 78 |
} |
| 79 |
|
| 80 |
METHOD getPickPt SoPickedPoint * getPickedPoint(int index = 0) const { |
| 81 |
Returns the indexed picked point from the list. |
| 82 |
} |
| 83 |
|
| 84 |
ALSO { SoPickedPoint, SoPickedPointList } |
| 85 |
|