00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SC_RAY_PICK_ACTION
00026 #define SC_RAY_PICK_ACTION
00027
00028 #include <Inventor/actions/SoRayPickAction.h>
00029
00030 class ScRayPickAction;
00031 class SoPath;
00032
00033 typedef void ScRayPickCallback( void*, ScRayPickAction* );
00034
00061 class ScRayPickAction : public SoRayPickAction
00062 {
00063 SO_ACTION_HEADER(ScRayPickAction);
00064
00065 public:
00066
00075 ScRayPickAction(
00076 const SbViewportRegion &viewportRegion,
00077 SoAction::DistribMode distribMode = SoAction::LOCAL_ONLY,
00078 ScRayPickCallback* callback = NULL,
00079 void* userData = NULL
00080 );
00081
00085 #ifndef HIDDEN_FROM_DOC
00086 ~ScRayPickAction();
00087 #endif // HIDDEN_FROM_DOC
00088
00092 virtual void apply( SoNode *node );
00093
00106 void setRay(
00107 const SbVec3f &rayStart,
00108 const SbVec3f &rayDirection,
00109 float nearDistance = -1,
00110 float farDistance = -1 );
00111
00118 void setRay(
00119 float fovy,
00120 const SbVec3f &rayStart,
00121 const SbVec3f &rayDirection,
00122 float nearDistance = -1,
00123 float farDistance = -1 );
00124
00133 void setPoint( const SbVec2s &viewportPoint );
00134
00140 void setPoint( const SbVec2f &viewportPoint );
00141
00149 void setNormalizedPoint( const SbVec2f &normPoint );
00150
00154 SbVec3f getppNormal();
00155
00159 SbVec3f getppPoint();
00160
00164 SoPath* getppPath();
00165
00169 SbBool isValidPp();
00170
00171 private:
00172
00173 typedef enum ScRayDefinition
00174 {
00175 UNDEFINED,
00176 RAY,
00177 POINT,
00178 NORMPOINT
00179 } ScRayDefinition_t;
00180
00181 static void initClass();
00182 static void exitClass();
00183 virtual bool mustTraverseDepth() { return true; }
00184
00185
00186 ScRayDefinition getRayDefinition() { return m_rayDefinition; }
00187
00188
00189 void getRay( SbVec3f &rayStart, SbVec3f &rayDirection, float &nearDistance, float &farDistance );
00190
00196 void getNormalizedPoint( SbVec2f &normPoint );
00197
00203 void getPoint( SbVec2s &point );
00204
00210 void getPoint( SbVec2f &point );
00211
00212
00213 float getFov();
00214
00215
00216 bool isFovSet();
00217
00218
00219 void setPickedPoint( SbVec3f ppPoint, SbVec3f ppNormal, SoPath* ppPath, SbBool isValidPp );
00220
00221
00222 private:
00223
00224
00225 ScRayPickCallback* m_rayPickCallback;
00226
00227
00228 void* m_data;
00229
00230 SbVec3f m_rayStart;
00231 SbVec3f m_rayDirection;
00232 SbVec2f m_normPoint;
00233 SbVec2f m_rayPoint;
00234 float m_nearDst;
00235 float m_farDst;
00236 ScRayDefinition m_rayDefinition;
00237 SbVec3f m_ppPoint;
00238 SbVec3f m_ppNormal;
00239 SoPath* m_ppPath;
00240 SbBool m_isValidPp;
00241 float m_fovy;
00242 bool m_bFovSet;
00243 };
00244
00245
00246
00247 inline void
00248 ScRayPickAction::setPickedPoint( SbVec3f ppPoint, SbVec3f ppNormal, SoPath* ppPath, SbBool isValidPp )
00249 {
00250 m_ppPoint = ppPoint;
00251 m_ppNormal = ppNormal;
00252 m_ppPath = ppPath;
00253 m_isValidPp = isValidPp;
00254 }
00255
00256
00257 inline SbVec3f
00258 ScRayPickAction::getppNormal()
00259 {
00260 return m_ppNormal;
00261 }
00262
00263
00264 inline SbVec3f
00265 ScRayPickAction::getppPoint()
00266 {
00267 return m_ppPoint;
00268 }
00269
00270
00271 inline SoPath*
00272 ScRayPickAction::getppPath()
00273 {
00274 return m_ppPath;
00275 }
00276
00277
00278 inline SbBool
00279 ScRayPickAction::isValidPp()
00280 {
00281 return m_isValidPp;
00282 }
00283
00284
00285 inline float
00286 ScRayPickAction::getFov()
00287 {
00288 return m_fovy;
00289 }
00290
00291 inline bool
00292 ScRayPickAction::isFovSet()
00293 {
00294 return m_bFovSet;
00295 }
00296 #endif // SC_RAY_PICK_ACTION
00297
00298
00299
00300
00301