1SoRayPickAction(3IV)() SoRayPickAction(3IV)()
2
3
4
6 SoRayPickAction — intersects objects with a ray cast into scene
7
9 SoAction > SoPickAction > SoRayPickAction
10
12 #include <Inventor/actions/SoRayPickAction.h>
13
14 Methods from class SoRayPickAction:
15
16 SoRayPickAction(const SbViewportRegion &view‐
17 portRegion)
18 void setPoint(const SbVec2s &viewportPoint)
19 void setNormalizedPoint(const SbVec2f &normPoint)
20 void setRadius(float radiusInPixels)
21 void setRay(const SbVec3f &start, const SbVec3f
22 &direction, float nearDistance = -1.0,
23 float farDistance = -1.0)
24 void setPickAll(SbBool flag)
25 SbBool isPickAll() const
26 const SoPickedPointList & getPickedPointList() const
27 SoPickedPoint * getPickedPoint(int index = 0) const
28
29 Methods from class SoPickAction:
30
31 void setViewportRegion(const SbViewportRegion
32 &newRegion)
33 const SbViewportRegion & getViewportRegion() const
34
35 Methods from class SoAction:
36
37 virtual void apply(SoNode *node)
38 virtual void apply(SoPath *path)
39 virtual void apply(const SoPathList &pathList, SbBool obeysRules =
40 FALSE)
41 static SoType getClassTypeId()
42 virtual SoType getTypeId()
43 virtual SbBool isOfType(SoType type)
44 virtual void invalidateState()
45
46
48 This class performs picking by casting a ray into a scene and perform‐
49 ing intersection tests with each object. The ray is extended to be a
50 cone or cylinder, depending on the camera type, for intersection with
51 points and lines. Each intersection is returned as an SoPickedPoint
52 instance.
53
54 The picking ray can be specified as either a ray from the camera loca‐
55 tion through a particular viewport pixel, or as a world-space ray. In
56 the former case, a valid camera must be encountered during traversal of
57 the graph to determine the location of the ray in world space.
58
59 Callers can cause the action to compute all intersections along the ray
60 (sorted closest to farthest) by setting the pickAll flag to TRUE. By
61 default, the action computes only the closest intersection. In either
62 case, the intersections are returned in an SoPickedPointList. Each
63 intersection can be examined by accessing the appropriate SoPickedPoint
64 in the list. The SoPickedPoint class provides methods to get the inter‐
65 section point, normal, and other info.
66
68 SoRayPickAction(const SbViewportRegion &view‐
69 portRegion)
70 Constructor takes viewport region to use for picking. Even though
71 the picking operation may not involve a window per se, some nodes
72 need this information to determine their size and placement.
73
74 void setPoint(const SbVec2s &viewportPoint)
75 Sets the viewport-space point through which the ray passes, starting
76 at the camera's viewpoint. Viewport coordinates range from (0,0) at
77 the lower left to (width-1,height-1) at the upper right.
78
79 void setNormalizedPoint(const SbVec2f &normPoint)
80 Sets the viewport point in normalized coordinates, which range from
81 (0,0) at the lower left to (1,1) at the upper right.
82
83 void setRadius(float radiusInPixels)
84 Set the radius (in pixels) around the point. This is used when test‐
85 ing the ray against lines and points. By default, the radius is 5
86 pixels. For perspective cameras, the ray is extended to be a cone
87 when testing against lines and points. For orthographic cameras, the
88 ray is extended to be a cylinder. The radius has no effect for
89 shapes of other types.
90
91 void setRay(const SbVec3f &start, const SbVec3f
92 &direction, float nearDistance = -1.0,
93 float farDistance = -1.0)
94 Sets a world-space ray along which to pick. The ray is defined as a
95 world space starting point and direction vector. The direction vec‐
96 tor will be normalized automatically. The last two arguments are the
97 parametric distances between which intersections along the ray must
98 occur. The distances are measured as if the direction vector is unit
99 length; e.g., if nearDistance is 2.0, the intersection must occur
100 past (start + 2*(length of the direction vector)) units along the
101 ray. These distances can be used to achieve near and far plane clip‐
102 ping. A negative distance (such as the default values) means disable
103 clipping to that plane.
104
105 void setPickAll(SbBool flag)
106 SbBool isPickAll() const
107 Sets/returns whether the action will return all objects intersected
108 or just the closest one.
109
110 const SoPickedPointList & getPickedPointList() const
111 Returns list of picked points.
112
113 SoPickedPoint * getPickedPoint(int index = 0) const
114 Returns the indexed picked point from the list.
115
116
118 SoPickedPoint, SoPickedPointList
119
120
121
122
123 SoRayPickAction(3IV)()