51#ifndef _SO_RAY_PICK_ACTION_
52#define _SO_RAY_PICK_ACTION_
54#include <Inventor/SoLists.h>
55#include <Inventor/nodes/SoCamera.h>
56#include <Inventor/actions/SoPickAction.h>
57#include <Inventor/SbBox.h>
58#include <Inventor/lists/SoPickedPointList.h>
60class PickedPointListImpl;
397#ifndef HIDDEN_FROM_DOC
499 {
return normVPPoint; }
547 float nearDistance = -1.0,
548 float farDistance = -1.0);
570 float nearDistance = -1.0,
571 float farDistance = -1.0);
664 {
return s_triangleCullingEnabled; }
710 {
return m_conicPickVolume; }
729 void computeWorldSpaceRay();
733 SbBool hasWorldSpaceRay()
const;
746 void setObjectSpace();
747 void setObjectSpace(
const SbMatrix &matrix);
781 return intersect(xbox, useFullViewVolume);
790 SbBool intersect(
const SbXfBox3f &box,
SbBool useFullViewVolume = TRUE);
800 const SbViewVolume &getViewVolume()
const
808 const SbLine &getLine()
const
817 SbBool isBetweenPlanes(
const SbVec3f &intersection)
const;
828 SoPickedPoint *addIntersection(
const SbVec3f &objectSpacePoint);
837 SoPickedPoint *addIntersection_ (
const SbVec3f &objectSpacePoint, PickedPointListImpl* ppimplptr );
838 SoPickedPoint *addIntersection_( SoPickedPoint *pp, PickedPointListImpl* ppimplptr );
839 SoPickedPoint *addIntersection_( SoPickedPoint *pp );
845 SoPickedPoint *getUnsortedPickedPoint(
int i )
const;
849 int getPickedPointsListLength()
const;
853 virtual void beginTraversal(SoNode *node);
856 static void initClass();
857 static void exitClass();
860 static SbBool isPickOptimSet()
861 {
return s_useAlternateIntersection; }
865 static bool isPtCulledByClippingPlanes(
const SbVec3f &worldPt, SoState *state,
bool worldCoord =
true );
869 static bool isBboxCompletelyCulledByClippingPlanes(
const SbBox3d& worldBBox, SoState* state,
bool worldCoord =
true );
871 static bool isBboxCompletelyCulledByClippingPlanes(
const SbBox3f& worldBBox, SoState* state,
bool worldCoord =
true );
873 static bool arePointsCulledByAClippingPlane(
const std::vector< SbVec3f>& pointVector, SoState* state,
bool worldCoord =
true );
880 enum PickedProperties
894 void enablePickedProperties(
const enum PickedProperties pickedProperty,
const SbBool enable);
899 SbBool isPickedPropertiesEnabled(
const enum PickedProperties pickedProperty)
const;
902 SbBool isEqual(
const SoPickedPoint *pp0,
const SoPickedPoint *pp1)
const;
906 SbBool isCloser(
const SoPickedPoint *pp0,
const SoPickedPoint *pp1)
const;
907 SbBool isCloser(
const SbVec3f& p0,
const SbVec3f& p1)
const;
910 double getDepth(
const SbVec3f& p0)
const;
913 void resetCurrPathCache();
915 enum PointPositionClassification
926 PointPositionClassification homogeneSpaceIntersection(
const SbVec3f &point, SbVec4f &pPoint )
const;
927 SoPath *getClonedCurrPath();
929 static bool isMTPickingActive();
932 float getVPRadiusPixel()
const ;
942 void setPointSizeForPicking(
float pointWidth,
float pointHeight);
945 void setPointSizeForPicking(
const SbVec2f & pointSize)
946 { setPointSizeForPicking(pointSize[0], pointSize[1]); }
949 SbVec2f getPointSizeForPicking()
950 {
return SbVec2f( m_pointWidthForPicking, m_pointHeightForPicking ); }
954 bool isValid =
false;
955 SbVec3f modelPosition;
956 uint32_t shapeId = 0;
958 float distToPickCenter = 0.f;
961 bool canGPUPick()
const;
966 void collectGPUPickingPath();
971 void renderGPUPickingScene();
975 const std::vector<GPUPickInfo>& getGPUPickInfo()
const;
977 PickedPointListImpl* getPickedPointListImpl()
const;
984 SbVec2f VPPointFloat;
994 SbViewVolume worldVol;
1000 SbBool clipToNear, clipToFar;
1006 SbViewVolume objVol;
1013 SbMatrix extraMatrix;
1016 void computeMatrices();
1019 void computeObjVolAndLine();
1022 void setUpRayBBoxAndWMat(
const SbVec3f ¢erPt );
1024 void evalCenterPts( SbVec3f ¢erPt, SbVec3d ¢erPtD, SbVec3d &projPtD );
1027 float getVPRadiusWorld()
const ;
1031 static float rayDistance(
const SbVec3f &start,
1032 const SbVec3f &direction,
1033 const SbVec3f &point);
1036 void setRayCommonProperties (
const SbVec3f &start,
const SbVec3f &direction,
1037 float fovy,
float aspectRatio = 1.0f,
float nearDistance=-1.0f,
float farDistance=-1.0f);
1040 void initializeMembersAfterVPPointSet(
bool normalizedPointSet);
1045 inline SbBool isInConicPickingVolume(
const SbVec3f &intersection )
const;
1047 void initSetRayData (
const SbVec3f &start,
const SbVec3f &direction,
1048 float fovy,
float aspectRatio = 1.0f,
1049 float nearDistance = -1.0f,
float farDistance = -1.0f );
1052 SbBool m_canUseTriangleCulling;
1061 HomTransfData *m_htdta;
1064 SbBool canUseTriangleCulling()
const
1065 {
return (s_triangleCullingEnabled && m_canUseTriangleCulling); }
1067 static SbBool s_triangleCullingEnabled ;
1070 static SbBool s_generateAllPickedProperties;
1076 static SbBool s_useAlternateIntersection;
1079 SbBool m_bEnableRadiusForTriangles;
1082 SbVec3f m_direction;
1089 template<
typename SO_NODE_OR_SO_PATH>
void commonApply(SO_NODE_OR_SO_PATH* nodeOrPath);
1091 float getCorrectedVPRadius()
const;
1093 int m_pickedPropertiesMask;
1096 int m_VPRadiusState;
1100 float m_nearDistance;
1101 float m_farDistance;
1102 float m_aspectRatio;
1105 SbBool m_conicPickVolume;
1107 PickedPointListImpl *m_pickedPointListlImpl;
1112 float m_pointPickingErrorX;
1113 float m_pointPickingErrorY;
1115 float m_projSpaceWidth;
1116 float m_projSpaceHeight;
1118 float m_pointWidthForPicking;
1119 float m_pointHeightForPicking;
1122 SoPathList m_gpuPickingCollectionPaths;
1123 std::vector<SoRayPickAction::GPUPickInfo> m_gpuPickingInfos;
1128 void fillGPUPickInfos();
1134 m_bEnableRadiusForTriangles = flag;
1140 return m_bEnableRadiusForTriangles;
Class for representing a viewport.
3D box with an associated transformation matrix.
virtual void apply(SoNode *node)
Initiates an action on the graph defined by a node.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Abstract base class for all database nodes.
Path that points to a list of hierarchical nodes.
Maintains a list of pointers to paths.
Represents point on surface of picked object.
Maintains a list of pointers to SoPickedPoint instances.
virtual void setPoint(const SbVec2f &viewportPoint)
Float version of setPoint.
virtual void apply(SoNode *node)
Initiates an action on the graph defined by a node.
SbBool isConicPickVolume()
Returns TRUE if the picking volume is a conic shape (not a frustum).
void enableNormalsGeneration(const SbBool enable)
Enables generation of normal vectors for picked points.
void setPickingMode(PickingMode pickingMode)
Sets the picking mode.
const SbVec2f & getPointFloat() const
Float version of getPoint().
static SoCamera::StereoMode getStereoMode()
Returns the view used to perform pick when stereo is active.
virtual void apply(const SoPathList &pathList, SbBool obeysRules=FALSE)
Initiates an action on the graph defined by a list of paths.
void setPickAll(SbBool flag)
Sets whether the action will return all objects intersected or just the closest one.
virtual void setPoint(const SbVec2s &viewportPoint)
Sets the viewport point through which the ray passes, starting at the camera position.
SbBool isRadiusEnableForTriangles()
Returns whether the pick radius specified by setRadius is taken into account for picking on triangle-...
static void setStereoMode(SoCamera::StereoMode stereoMode)
Tells ray pick action in which view the pick occurs.
SbBool isPickAll() const
Returns whether the action will return all objects intersected or just the closest one.
virtual void clearApplyResult()
Clears the picked point list.
SoRayPickAction(const SbViewportRegion &viewportRegion)
Constructor takes viewport region to use for picking.
static SbBool isTriangleCulling()
Returns whether triangle culling is enabled.
void enableConicPickVolume(SbBool flag)
Controls the pick volume shape for picking with setRay().
const SbVec2s & getPoint() const
Gets the viewport point in pixels (returns the last value passed to setPoint).
static void enableTriangleCulling(SbBool flag)
Enables culling of triangles relative to the ray frustum.
void setRadius(float radius)
Sets the radius around the point.
void enableTexCoordsGeneration(const SbBool enable)
Enables generation of texture coordinates for picked points.
PickingMode getPickingMode() const
Returns the PickingMode used for the ray pick action.
virtual void apply(SoPath *path)
Initiates an action on the graph defined by a path.
virtual void setRay(float fovy, const SbVec3f &start, const SbVec3f &direction, float nearDistance=-1.0, float farDistance=-1.0)
Sets a world-space ray along which to pick in the the same way as the other version of setRay(),...
SbBool isNormalsGenerationEnabled() const
Returns whether generation of normal vectors is enabled for picked points.
SoPickedPoint * getPickedPoint(int index=0) const
Returns the indexed picked point from the list.
void enableRadiusForTriangles(SbBool flag)
Enable radius for triangle-based shape.
virtual void setRay(const SbVec3f &start, const SbVec3f &direction, float nearDistance=-1.0, float farDistance=-1.0)
Sets a world-space ray along which to pick.
SoDEPRECATED void clearPickedPointList()
Clears the picked point list.
@ POINT_PICKING
In this mode, Inventor finds all the vertices inside the pick radius.
@ DEFAULT
In the default mode, Inventor computes the intersection of the pick ray with geometry nodes (face,...
const SbVec2f getNormalizedPoint() const
Gets the viewport point in normalized coordinates [0..1] (returns the last value passed to setNormali...
SbBool isTexCoordsGenerationEnabled() const
Returns whether texture coordinate generation is enabled for picked points.
float getRadius() const
Gets the radius (in pixels) around the point.
const SoPickedPointList & getPickedPointList() const
Returns list of picked points.
virtual void setNormalizedPoint(const SbVec2f &normPoint)
Sets the viewport point in normalized coordinates, which range from (0,0) at the lower left to (1,...