Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoRayPickAction.h
1 #ifndef COIN_SORAYPICKACTION_H
2 #define COIN_SORAYPICKACTION_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/actions/SoPickAction.h>
37 
38 class SbBox3f;
39 class SbLine;
40 class SbMatrix;
41 class SbVec2f;
42 class SbVec2s;
43 class SbVec3f;
44 class SbViewVolume;
45 class SbViewportRegion;
46 class SoPickedPoint;
47 class SoPickedPointList;
48 class SoRayPickActionP;
49 
50 class COIN_DLL_API SoRayPickAction : public SoPickAction {
51  typedef SoPickAction inherited;
52 
53  SO_ACTION_HEADER(SoRayPickAction);
54 
55 public:
56  SoRayPickAction(const SbViewportRegion & viewportregion);
57  virtual ~SoRayPickAction();
58  static void initClass(void);
59 
60  void setPoint(const SbVec2s & viewportPoint);
61  void setNormalizedPoint(const SbVec2f & normpoint);
62  void setRadius(const float radiusinpixels);
63  float getRadius(void) const;
64  void setRay(const SbVec3f & start, const SbVec3f & direction,
65  float neardistance = -1.0,
66  float fardistance = -1.0);
67  void setPickAll(const SbBool flag);
68  SbBool isPickAll(void) const;
69  const SoPickedPointList & getPickedPointList(void) const;
70  SoPickedPoint * getPickedPoint(const int index = 0) const;
71 
72 
73  void computeWorldSpaceRay(void);
74  SbBool hasWorldSpaceRay(void) const;
75  void setObjectSpace(void);
76  void setObjectSpace(const SbMatrix & matrix);
77  SbBool intersect(const SbVec3f & v0, const SbVec3f & v1, const SbVec3f & v2,
78  SbVec3f & intersection, SbVec3f & barycentric,
79  SbBool & front) const;
80  SbBool intersect(const SbVec3f & v0, const SbVec3f & v1,
81  SbVec3f & intersection) const;
82  SbBool intersect(const SbVec3f & point) const;
83  SbBool intersect(const SbBox3f & box, const SbBool usefullviewvolume = TRUE);
84  SbBool intersect(const SbBox3f & box, SbVec3f & intersection,
85  const SbBool usefullviewvolume = TRUE);
86  const SbViewVolume & getViewVolume(void);
87  const SbLine & getLine(void);
88  SbBool isBetweenPlanes(const SbVec3f & intersection) const;
89  SoPickedPoint * addIntersection(const SbVec3f & objectspacepoint, SbBool frontpick = TRUE);
90 
91  void reset(void);
92 
93 protected:
94  virtual void beginTraversal(SoNode * node);
95 
96 private:
98 
99  // NOT IMPLEMENTED:
100  SoRayPickAction(const SoRayPickAction & rhs);
101  SoRayPickAction & operator = (const SoRayPickAction & rhs);
102 }; // SoRayPickAction
103 
104 #endif // !COIN_SORAYPICKACTION_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:49
The SoRayPickAction class does ray intersection with scene graphs.
Definition: SoRayPickAction.h:50
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition: SbBox3f.h:46
The SoPickAction class is the base class for picking actions.
Definition: SoPickAction.h:43
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
The SoPickedPointList class is a container for pointers to SoPickedPoint objects. ...
Definition: SoPickedPointList.h:40
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:77
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:51
The SbLine class represents a line in 3D space.
Definition: SbLine.h:41
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
The SbViewVolume class is a viewing volume in 3D space.
Definition: SbViewVolume.h:50
The SoPickedPoint class is used for specifying picked points.
Definition: SoPickedPoint.h:48
virtual void beginTraversal(SoNode *node)
Definition: SoPickAction.cpp:134
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition: SbVec2s.h:51