Hx3DWand.h
1 #ifndef HX_3D_WAND_BASE_H
2 #define HX_3D_WAND_BASE_H
3 
4 #include <Inventor/SbLinear.h>
5 #include <mclib/McHandle.h>
6 #include <Inventor/nodes/SoSwitch.h>
7 #include <hxcore/api.h>
8 
9 
10 #pragma warning(push)
11 
12 // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
13 #pragma warning(disable:4251)
14 
17 #define GET_WAND(e) \
18  dynamic_cast<Hx3DWandBase*>((Hx3DWandBase*)(e)->trackerInfo().getData())
19 
42 class HXCORE_API Hx3DWand
43 {
44  public:
45 
54  void setGeometry(SoNode* wand, const SbVec3f& hotSpot);
55 
61  void setHighlightGeometry(SoNode* wand);
62 
73  void setWandScale(float scaleFactor);
74 
82  float getWandScale() const { return m_wandScale; }
83 
92  virtual void setHighlight(bool enable);
93 
99  bool getButton(int butIdx) const;
100 
105  int getButtonStatus() const { return m_buttonStatus; }
106 
113  bool wasButtonPressed(int butIdx) const;
114 
120  bool wasButtonReleased(int butIdx) const;
121 
131  const SbVec3f& origin(bool scene=true) const { return scene ? m_sceneOrigin : m_vrOrigin; }
132 
142  const SbVec3f& top(bool scene=true) const { return scene ? m_sceneTop : m_vrTop; }
143 
175  const SbRotation& orientation(bool scene=true) const { return scene ? m_sceneOrientation : m_vrOrientation; }
176 
182  float length(bool scene=true) const { return scene ? m_sceneLength : m_vrLength; }
183 
195  const SbMatrix& sceneXform() const { return *m_sceneToVRTransform; }
196 
203  const SbMatrix& sceneXformInverse() const { return *m_vrToSceneTransform; }
204 
211  virtual void update(const SbVec3f& pos, const SbRotation& rot, int butStat);
212 
217  const SbVec3f& getHotSpot() const { return m_hotSpot; }
218 
223  static SoSeparator* getDefaultWandGeometry();
224 
225 protected:
228  Hx3DWandBase();
229 
232  virtual ~Hx3DWandBase();
233 
239  static SoSeparator* createDefaultWand( bool highlight);
240 
244  SbVec3f m_hotSpot;
245 
249  float m_wandScale;
250 
254  McHandle<SoSwitch> m_highlightSwitch;
255 
259  enum WandGeom {
260  DEFAULT_GEOM = 0,
261  HIGHTLIGHT_GEOM = 1
262  };
263 
268 
272  SbVec3f m_sceneTop;
273 
277  SbVec3f m_sceneOrigin;
278 
282  SbRotation m_sceneOrientation;
283 
287  float m_vrLength;
288 
292  SbVec3f m_vrTop;
293 
297  SbVec3f m_vrOrigin;
298 
302  SbRotation m_vrOrientation;
303 
307  const SbMatrix* m_sceneToVRTransform;
308 
312  const SbMatrix* m_vrToSceneTransform;
313 
318 
324 };
325 
326 #pragma warning(pop)
327 
328 #endif
SbVec3f m_hotSpot
The hot spot of the wand.
Definition: Hx3DWand.h:244
const SbVec3f & origin(bool scene=true) const
Returns the origin of the 3D wand.
Definition: Hx3DWand.h:131
float m_vrLength
The length in VR coordinates.
Definition: Hx3DWand.h:287
float getWandScale() const
Returns the scale factor of the wand.
Definition: Hx3DWand.h:82
SbVec3f m_vrTop
The top in VR coordinates.
Definition: Hx3DWand.h:292
Base class representing a 3D wand in XScreen.
Definition: Hx3DWand.h:42
int getButtonStatus() const
Returns the current combined state of all buttons of the VR input device.
Definition: Hx3DWand.h:105
SbVec3f m_sceneOrigin
The origin in scene coordinates.
Definition: Hx3DWand.h:277
const SbMatrix & sceneXformInverse() const
Returns the inverse of sceneXform().
Definition: Hx3DWand.h:203
McHandle< SoSwitch > m_highlightSwitch
The node for switching between highlight ON/OFF.
Definition: Hx3DWand.h:254
float m_wandScale
The scale factor of the wand.
Definition: Hx3DWand.h:249
const SbMatrix & sceneXform() const
Returns the matrix which transforms between scene coordinates and VR coordinates, i...
Definition: Hx3DWand.h:195
SbVec3f m_vrOrigin
The origin in VR coordinates.
Definition: Hx3DWand.h:297
const SbVec3f & top(bool scene=true) const
Returns the top of the 3D wand.
Definition: Hx3DWand.h:142
SbRotation m_sceneOrientation
The orientation in scene coordinates.
Definition: Hx3DWand.h:282
const SbMatrix * m_sceneToVRTransform
The scene to VR transform.
Definition: Hx3DWand.h:307
SbRotation m_vrOrientation
The orientation in VR coordinates.
Definition: Hx3DWand.h:302
WandGeom
Code for the two (highlighted and not) geometries.
Definition: Hx3DWand.h:259
float length(bool scene=true) const
Returns the length of the wand.
Definition: Hx3DWand.h:182
float m_sceneLength
The length in scene coordinates.
Definition: Hx3DWand.h:267
int m_buttonStatus
The buttons (all) combined status.
Definition: Hx3DWand.h:317
int m_lastButtonStatus
The buttons (all) combined status sampled during last scene graph traversal.
Definition: Hx3DWand.h:323
const SbMatrix * m_vrToSceneTransform
The inverse of scene to VR transform.
Definition: Hx3DWand.h:312
const SbVec3f & getHotSpot() const
Returns the HotSpot.
Definition: Hx3DWand.h:217
const SbRotation & orientation(bool scene=true) const
Returns the current orientation of the wand.
Definition: Hx3DWand.h:175
SbVec3f m_sceneTop
The top in scene coordinates.
Definition: Hx3DWand.h:272