OpenCOVER
coVR3DGizmoType.h
Go to the documentation of this file.
1#ifndef _CO_VR_3D_GIZMO_TYPE
2#define _CO_VR_3D_GIZMO_TYPE
3
5#include <net/tokenbuffer_serializer.h>
7#include <net/tokenbuffer.h>
8
10#include <PluginUtil/coLine.h>
11
12#include <OpenVRUI/coAction.h>
16
17namespace opencover
18{
19
20class coVR3DGizmo;
21class PLUGIN_UTILEXPORT coVR3DGizmoType : public coVRIntersectionInteractor
22{
23private:
24 bool _changeGizmoType{false};
25 coVR3DGizmo* _observer{nullptr}; // if coVR3DGizmoType is constructed from a coVR3DGizmo the Gizmotype can be changed
26 std::unique_ptr<coCombinedButtonInteraction> _interactionB; // interaction to switch GizmoType
27
28 void changeGizmoType();
29
30protected:
31
32 float _distance{0};
33 osg::Vec3 _diff; //diff between intersection point and sphere center
34 osg::Vec4 _red{0.5, 0.2, 0.2, 1.0}, _blue{0.2, 0.2, 0.5, 1.0}, _green{0.2, 0.5, 0.2, 1.0}, _grey{0.5, 0.5, 0.5, 1};
35
36 osg::Matrix _interMat_o; // current Matrix
37 osg::Matrix _startInterMat_w; // Matrix when interaction was started
38 osg::Matrix _startHandMat_o;
39 osg::Matrix _startHandMat_w;
40
41 std::unique_ptr<opencover::coPlane> _helperPlane;
42 std::unique_ptr<opencover::coLine> _helperLine;
43
44 void createGeometry() override = 0;
45 void updateSharedState() override; // braucht man das ?
46 typedef vrb::SharedState<osg::Matrix> SharedMatrix; // check if I need this
47
48 // calculate the intersection point between the pointer direction and a plane is used to calculate the new position
49 osg::Vec3 calcPlaneLineIntersection(const osg::Vec3& lp0, const osg::Vec3& lp1, osg::Vec3 axis) const;
50
51 void calculatePointerDirection_w(osg::Vec3& lp0, osg::Vec3& lp1, osg::Vec3& pointerDirVec ) const;
52 void calculatePointerDirection_o(osg::Vec3& lp0_o, osg::Vec3& lp1_o, osg::Vec3& pointerDirVec ) const;
53
54public:
55 coVR3DGizmoType(osg::Matrix m, float s, coInteraction::InteractionType type, const char *iconName, const char *interactorName, coInteraction::InteractionPriority priority ,coVR3DGizmo* gizmoPointer = nullptr);
56
58 virtual void updateTransform(osg::Matrix m);
59
60 void preFrame() override;
61 void startInteraction() override;
62 void stopInteraction() override;
63 int hit(vrui::vruiHit *hit) override;
64 void miss() override;
65 void resetState() override; // un-highlight
66
67 void update() override;
68 void setShared(bool state) override;
69
70 virtual osg::Matrix getMoveMatrix_o() const; // returns diff Mat between start and end of movement in object coordinates
71 osg::Matrix getMoveMatrix_w() const; // returns diff Mat between start and end of movement in world coordinates
72
73
74};
75
76}
77#endif
Definition: ARToolKit.h:33
Definition: coVRIntersectionInteractor.h:56
Definition: coVR3DGizmo.h:20
Definition: coVR3DGizmoType.h:22
void startInteraction() override
void setShared(bool state) override
make state shared among partners in a collaborative session
osg::Vec3 _diff
Definition: coVR3DGizmoType.h:33
void createGeometry() override=0
coVR3DGizmoType(osg::Matrix m, float s, coInteraction::InteractionType type, const char *iconName, const char *interactorName, coInteraction::InteractionPriority priority, coVR3DGizmo *gizmoPointer=nullptr)
osg::Matrix _startHandMat_w
Definition: coVR3DGizmoType.h:39
virtual osg::Matrix getMoveMatrix_o() const
virtual void updateTransform(osg::Matrix m)
std::unique_ptr< opencover::coPlane > _helperPlane
Definition: coVR3DGizmoType.h:41
int hit(vrui::vruiHit *hit) override
osg::Matrix _startHandMat_o
Definition: coVR3DGizmoType.h:38
void calculatePointerDirection_o(osg::Vec3 &lp0_o, osg::Vec3 &lp1_o, osg::Vec3 &pointerDirVec) const
void stopInteraction() override
void calculatePointerDirection_w(osg::Vec3 &lp0, osg::Vec3 &lp1, osg::Vec3 &pointerDirVec) const
void preFrame() override
osg::Vec3 calcPlaneLineIntersection(const osg::Vec3 &lp0, const osg::Vec3 &lp1, osg::Vec3 axis) const
vrb::SharedState< osg::Matrix > SharedMatrix
Definition: coVR3DGizmoType.h:46
std::unique_ptr< opencover::coLine > _helperLine
Definition: coVR3DGizmoType.h:42
osg::Matrix _startInterMat_w
Definition: coVR3DGizmoType.h:37
void updateSharedState() override
reimplement in derived class for updating value of m_sharedState
osg::Matrix getMoveMatrix_w() const
osg::Matrix _interMat_o
Definition: coVR3DGizmoType.h:36
void resetState() override
Definition: vruiHit.h:21