OpenCOVER
ARToolKit.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
21#ifndef ARTOOLKIT_H
22#define ARTOOLKIT_H
23
24#include <list>
25#include <osg/Matrix>
26#include <osg/MatrixTransform>
27#include <osg/Drawable>
28#include <osg/Geode>
29#include <osg/Geometry>
30#include <osg/Vec3>
31
32namespace opencover
33{
34class ARToolKitMarker;
35class coTUILabel;
39class coTUITab;
40class coTUIElement;
41}
42
43#include <net/covise_connect.h>
44#include <net/message.h>
45
46#include "coTUIListener.h"
47
48namespace opencover
49{
50class COVEREXPORT ARToolKitNode : public osg::Drawable
51{
52private:
53 bool displayVideo; // true if CoviseConfig.displayVideo is set
54 bool renderTextures;
55 std::string m_artoolkitVariant;
56
57public:
58 ARToolKitNode(std::string artoolkitVariant);
59 virtual ~ARToolKitNode();
61 virtual void drawImplementation(osg::RenderInfo &renderInfo) const;
64 virtual osg::Object *cloneType() const;
65
68 virtual osg::Object *clone(const osg::CopyOp &) const;
69};
70
71class COVEREXPORT ARToolKitInterface
72{
73public:
76 virtual int loadPattern(const char *)
77 {
78 return -1;
79 };
80 virtual bool isVisible(int)
81 {
82 return false;
83 };
84 virtual osg::Matrix getMat(int /* pattID */, double /*pattCenter*/[2], double /*pattSize*/, double /* pattTrans */[3][4])
85 {
86 osg::Matrix m;
87 return m;
88 };
89 virtual void updateViewerPos(const osg::Vec3f &vp)
90 {
91 (void)vp;
92 }
93 virtual void updateMarkerParams(){};
94 virtual bool isARToolKit()
95 {
96 return false;
97 };
98};
99
100class COVEREXPORT RemoteARInterface
101{
102public:
104 {
105 }
107 {
108 }
109 virtual void update() = 0;
110 virtual void receiveImage(const char *data) = 0;
111 virtual void updateBitrate(const int bitrate) = 0;
112 virtual bool usesIRMOS() const
113 {
114 return false;
115 }
116 virtual bool isReceiver() const
117 {
118 return false;
119 }
120 virtual covise::ClientConnection *getIRMOSClient() const
121 {
122 return NULL;
123 }
124};
125
126class COVEREXPORT ARToolKit
127{
128private:
129 static ARToolKit *art;
130 ARToolKit();
131 std::string m_configPath;
132 covise::Message msg;
133
134 bool objTracking;
135 int numObjectMarkers;
136 std::list<ARToolKitMarker *> objectMarkers;
137
138public:
140 virtual ~ARToolKit();
143 bool flipH;
146
147 void update();
148 void config();
149 bool isRunning();
150
151 unsigned char *videoData;
152 unsigned char *videoDataRight;
161 std::list<ARToolKitMarker *> markers;
165};
166
167class COVEREXPORT ARToolKitMarker : public coTUIListener
168{
169private:
170 int pattID;
171 double pattSize;
172 double pattCenter[2];
173 double pattTrans[3][4];
174 bool VrmlToPf;
175 bool objectMarker;
176 float x, y, z, h, p, r;
177 bool visible;
178 osg::Matrix offset;
179 osg::Matrix Ctrans;
180 osg::Matrix Mtrans;
181 coTUILabel *markerLabel = nullptr;
182 coTUIToggleButton *vrmlToPfFlag = nullptr;
183 coTUIEditFloatField *size = nullptr;
184 coTUIEditFloatField *posX = nullptr;
185 coTUIEditFloatField *posY = nullptr;
186 coTUIEditFloatField *posZ = nullptr;
187 coTUIEditFloatField *rotH = nullptr;
188 coTUIEditFloatField *rotP = nullptr;
189 coTUIEditFloatField *rotR = nullptr;
190
191public:
192 ARToolKitMarker(const std::string &configName,int MarkerID,double size,osg::Matrix&mat, osg::Matrix& hostMat,bool VrmlToOSG);
193 ARToolKitMarker(const char* Name);
194 void updateData(double markerSize, osg::Matrix& mat, osg::Matrix& hostMat, bool vrmlToOsg);
196 osg::Matrix &getCameraTrans();
197 osg::Matrix &getMarkerTrans();
198 osg::Matrix &getOffset()
199 {
200 return offset;
201 };
202 virtual void tabletEvent(coTUIElement *tUIItem);
203 double getSize();
205 bool isVisible();
207 {
208 return objectMarker;
209 };
210 void setObjectMarker(bool o)
211 {
212 objectMarker = o;
213 };
214 void setColor(float r, float g, float b);
215 osg::Geode *quadGeode = nullptr;
216 osg::ref_ptr<osg::MatrixTransform> markerQuad;
217 osg::MatrixTransform *posSize=nullptr;
218 osg::Vec4Array *colors = nullptr;
219 osg::Geometry *geom = nullptr;
220 coTUIToggleButton *displayQuad = nullptr;
221 coTUIToggleButton *calibrate = nullptr;
223 osg::Matrix matrixSumm;
225 void setOffset(osg::Matrix &mat);
226 osg::Matrix OpenGLToOSGMatrix;
227 osg::Matrix PfToOpenGLMatrix;
228};
229}
230#endif
Tablet user interface proxy classes.
Definition: ARToolKit.h:33
Definition: ARToolKit.h:51
static ARToolKitNode * theNode
Definition: ARToolKit.h:60
virtual osg::Object * clone(const osg::CopyOp &) const
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
ARToolKitNode(std::string artoolkitVariant)
virtual osg::Object * cloneType() const
Definition: ARToolKit.h:72
ARToolKitInterface()
Definition: ARToolKit.h:74
virtual int loadPattern(const char *)
Definition: ARToolKit.h:76
virtual void updateMarkerParams()
Definition: ARToolKit.h:93
virtual bool isVisible(int)
Definition: ARToolKit.h:80
virtual bool isARToolKit()
Definition: ARToolKit.h:94
virtual void updateViewerPos(const osg::Vec3f &vp)
Definition: ARToolKit.h:89
virtual ~ARToolKitInterface()
Definition: ARToolKit.h:75
virtual osg::Matrix getMat(int, double[2], double, double[3][4])
Definition: ARToolKit.h:84
Definition: ARToolKit.h:101
RemoteARInterface()
Definition: ARToolKit.h:103
virtual covise::ClientConnection * getIRMOSClient() const
Definition: ARToolKit.h:120
virtual bool isReceiver() const
Definition: ARToolKit.h:116
virtual bool usesIRMOS() const
Definition: ARToolKit.h:112
virtual void updateBitrate(const int bitrate)=0
virtual void receiveImage(const char *data)=0
virtual ~RemoteARInterface()
Definition: ARToolKit.h:106
Definition: ARToolKit.h:127
bool videoMirrorLeft
Definition: ARToolKit.h:158
ARToolKitInterface * arInterface
Definition: ARToolKit.h:144
RemoteARInterface * remoteAR
Definition: ARToolKit.h:145
int videoWidth
Definition: ARToolKit.h:153
int videoMode
Definition: ARToolKit.h:155
std::list< ARToolKitMarker * > markers
Definition: ARToolKit.h:161
std::string m_artoolkitVariant
Definition: ARToolKit.h:160
void addMarker(ARToolKitMarker *)
bool stereoVideo
Definition: ARToolKit.h:157
bool doMerge
Definition: ARToolKit.h:163
int videoDepth
Definition: ARToolKit.h:156
static ARToolKit * instance()
bool videoMirrorRight
Definition: ARToolKit.h:159
coTUITab * artTab
Definition: ARToolKit.h:142
bool running
Definition: ARToolKit.h:139
bool testImage
Definition: ARToolKit.h:164
unsigned char * videoDataRight
Definition: ARToolKit.h:152
int videoHeight
Definition: ARToolKit.h:154
unsigned char * videoData
Definition: ARToolKit.h:151
bool flipH
Definition: ARToolKit.h:143
Definition: ARToolKit.h:168
int numCalibSamples
Definition: ARToolKit.h:222
osg::Matrix OpenGLToOSGMatrix
Definition: ARToolKit.h:226
ARToolKitMarker(const std::string &configName, int MarkerID, double size, osg::Matrix &mat, osg::Matrix &hostMat, bool VrmlToOSG)
osg::Matrix & getCameraTrans()
osg::Matrix & getMarkerTrans()
void updateData(double markerSize, osg::Matrix &mat, osg::Matrix &hostMat, bool vrmlToOsg)
void setObjectMarker(bool o)
Definition: ARToolKit.h:210
void setColor(float r, float g, float b)
virtual void tabletEvent(coTUIElement *tUIItem)
osg::Matrix & getOffset()
Definition: ARToolKit.h:198
osg::ref_ptr< osg::MatrixTransform > markerQuad
Definition: ARToolKit.h:216
void setOffset(osg::Matrix &mat)
bool isObjectMarker()
Definition: ARToolKit.h:206
osg::Matrix matrixSumm
Definition: ARToolKit.h:223
osg::Matrix PfToOpenGLMatrix
Definition: ARToolKit.h:227
bool lastVisible
Definition: ARToolKit.h:224
ARToolKitMarker(const char *Name)
Definition: coTabletUI.h:147
Definition: coTabletUI.h:212
Definition: coTabletUI.h:672
Definition: coTabletUI.h:1156
Definition: coTabletUI.h:1644
Action listener for events triggered by any coTUIElement.
Definition: coTUIListener.h:61