OpenCOVER
coVR3DRotGizmo.h
Go to the documentation of this file.
1#ifndef _CO_VR_3D_ROT_GIZMO
2#define _CO_VR_3D_ROT_GIZMO
3
6
7/* ToDo;
8 - other interactors have: forbid translation in y-direction if traverseInteractors is on --> why do we need this ????
9 - doInteraction: if (coVRNavigationManager::instance()->getMode() == coVRNavigationManager::TraverseInteractors) --> for what ?
10 - for what is shared state necessary ?
11*/
12
13namespace opencover
14{
15
16class PLUGIN_UTILEXPORT coVR3DRotGizmo : public coVR3DGizmoType
17{
18private:
19 bool _rotateXonly{false}, _rotateYonly{false}, _rotateZonly{false};
20 bool _wristRotation{false};
21 const float _radius{3};
22 osg::Vec3 _startPointOnCircle; // point on circle which was selected when interaction started
23
24 enum class RotationAxis { Z = 0, X, Y };
25
26 osg::ref_ptr<osg::MatrixTransform> _axisTransform; // all the Geometry
27 osg::ref_ptr<osg::Geode> _sphereGeode;
28 osg::ref_ptr<osg::Group> _xRotCylGroup;
29 osg::ref_ptr<osg::Group> _zRotCylGroup;
30 osg::ref_ptr<osg::Group> _yRotCylGroup;
31
32 // draw circles with osg::DrawArrays (not intersectable)
33 // osg::Geode* circles( RotationAxis axis, int approx, osg::Vec4 color );
34 // draw circles with cylinders
35 osg::Group* circlesFromCylinders( RotationAxis axis, int approx, osg::Vec4 color, float cylinderLength );
36 // calculate the verts for a circle
37 osg::Vec3Array* circleVerts(RotationAxis axis, int approx);
38
39
40 // calculate the rotation for a 2D input device
41 osg::Matrix calcRotation2D(const osg::Vec3& lp0_o, const osg::Vec3& lp1_o, osg::Vec3 rotationAxis);
42 // calculate the rotation for a 3D input device (use wrist rotation)
43 osg::Matrix calcRotation3D(osg::Vec3 rotationAxis);
44 void snapTo45(float& angle) const;
45
46
47 // get the rotation axis
48 bool rotateAroundSpecificAxis(osg::Group *group)const;
49 // if 3D input device is used check if wrist rotation should be used
50 bool useWristRotation()const;
51
52
53 // returns the closest distance between a point and circle which are in the same plane
54 // pointOnCircle ist the corresponding point on the circle
55 float closestDistanceLineCircle(const osg::Vec3& lp0, const osg::Vec3& lp1,osg::Vec3 rotationAxis, osg::Vec3& pointOnCircle) const;
56
57 // calculate the angle between two 3d vectors in the range 0-360 degree
58 double vecAngle360(const osg::Vec3 vec1, const osg::Vec3 &vec2, const osg::Vec3& refVec);
59
60protected:
61 void createGeometry() override;
62
63
64public:
65 coVR3DRotGizmo(osg::Matrix m, float s, coInteraction::InteractionType type, const char *iconName, const char *interactorName, coInteraction::InteractionPriority priority,coVR3DGizmo* gizmoPointer = nullptr);
66
67 virtual ~coVR3DRotGizmo();
68
69 virtual void startInteraction() override;
70 virtual void stopInteraction() override;
71 virtual void doInteraction() override;
72};
73
74}
75#endif
Definition: ARToolKit.h:33
Definition: coVR3DGizmo.h:20
Definition: coVR3DGizmoType.h:22
Definition: coVR3DRotGizmo.h:17
void createGeometry() override
virtual void doInteraction() override
coVR3DRotGizmo(osg::Matrix m, float s, coInteraction::InteractionType type, const char *iconName, const char *interactorName, coInteraction::InteractionPriority priority, coVR3DGizmo *gizmoPointer=nullptr)
virtual void stopInteraction() override
virtual void startInteraction() override