OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
32 namespace opencover
33 {
34 class ARToolKitMarker;
35 class coTUILabel;
36 class coTUIToggleButton;
39 class coTUITab;
40 class coTUIElement;
41 }
42 
43 #include <net/covise_connect.h>
44 #include <net/message.h>
45 
46 #include "coTUIListener.h"
47 
48 namespace opencover
49 {
50 class COVEREXPORT ARToolKitNode : public osg::Drawable
51 {
52 private:
53  bool displayVideo; // true if CoviseConfig.displayVideo is set
54  bool renderTextures;
55  std::string m_artoolkitVariant;
56 
57 public:
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 
71 class COVEREXPORT ARToolKitInterface
72 {
73 public:
75  virtual ~ARToolKitInterface(){};
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 
100 class COVEREXPORT RemoteARInterface
101 {
102 public:
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 
126 class COVEREXPORT ARToolKit
127 {
128 private:
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 
138 public:
139  bool running;
140  virtual ~ARToolKit();
141  static ARToolKit *instance();
143  bool flipH;
146 
147  void update();
148  void config();
149  bool isRunning();
150 
151  unsigned char *videoData;
152  unsigned char *videoDataRight;
160  std::string m_artoolkitVariant;
161  std::list<ARToolKitMarker *> markers;
162  void addMarker(ARToolKitMarker *);
163  bool doMerge;
164  bool testImage;
165 };
166 
167 class COVEREXPORT ARToolKitMarker : public coTUIListener
168 {
169 private:
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  osg::Matrix OpenGLToOSGMatrix;
182  osg::Matrix PfToOpenGLMatrix;
183  coTUILabel *markerLabel;
184  coTUIToggleButton *vrmlToPfFlag;
185  coTUIEditFloatField *size;
186  coTUIEditFloatField *posX;
187  coTUIEditFloatField *posY;
188  coTUIEditFloatField *posZ;
189  coTUIEditFloatField *rotH;
190  coTUIEditFloatField *rotP;
191  coTUIEditFloatField *rotR;
192 
193 public:
194  ARToolKitMarker(const char *Name);
195  virtual ~ARToolKitMarker();
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();
204  int getPattern();
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;
216  osg::ref_ptr<osg::MatrixTransform> markerQuad;
217  osg::MatrixTransform *posSize;
218  osg::Vec4Array *colors;
219  osg::Geometry *geom;
223  osg::Matrix matrixSumm;
225  void setOffset(osg::Matrix &mat);
226 };
227 }
228 #endif
int videoMode
Definition: ARToolKit.h:155
osg::Geode * quadGeode
Definition: ARToolKit.h:215
void setObjectMarker(bool o)
Definition: ARToolKit.h:210
bool flipH
Definition: ARToolKit.h:143
Definition: coTabletUI.h:140
bool videoMirrorLeft
Definition: ARToolKit.h:158
virtual void updateViewerPos(const osg::Vec3f &vp)
Definition: ARToolKit.h:89
unsigned char * videoData
Definition: ARToolKit.h:151
bool videoMirrorRight
Definition: ARToolKit.h:159
std::list< ARToolKitMarker * > markers
Definition: ARToolKit.h:161
virtual bool isVisible(int)
Definition: ARToolKit.h:80
Definition: coTabletUI.h:668
Definition: coTabletUI.h:205
int videoHeight
Definition: ARToolKit.h:154
coTUIToggleButton * calibrate
Definition: ARToolKit.h:221
bool stereoVideo
Definition: ARToolKit.h:157
Definition: ARToolKit.h:167
Definition: coTabletUI.h:1640
RemoteARInterface * remoteAR
Definition: ARToolKit.h:145
virtual ~RemoteARInterface()
Definition: ARToolKit.h:106
osg::Matrix matrixSumm
Definition: ARToolKit.h:223
osg::ref_ptr< osg::MatrixTransform > markerQuad
Definition: ARToolKit.h:216
bool doMerge
Definition: ARToolKit.h:163
Tablet user interface proxy classes.
static ARToolKitNode * theNode
Definition: ARToolKit.h:60
int numCalibSamples
Definition: ARToolKit.h:222
osg::Vec4Array * colors
Definition: ARToolKit.h:218
bool running
Definition: ARToolKit.h:139
osg::MatrixTransform * posSize
Definition: ARToolKit.h:217
Definition: ARToolKit.h:71
virtual int loadPattern(const char *)
Definition: ARToolKit.h:76
ARToolKitInterface()
Definition: ARToolKit.h:74
bool lastVisible
Definition: ARToolKit.h:224
bool isObjectMarker()
Definition: ARToolKit.h:206
coTUITab * artTab
Definition: ARToolKit.h:142
ARToolKitInterface * arInterface
Definition: ARToolKit.h:144
virtual ~ARToolKitInterface()
Definition: ARToolKit.h:75
osg::Matrix & getOffset()
Definition: ARToolKit.h:198
Definition: coTabletUI.h:1152
RemoteARInterface()
Definition: ARToolKit.h:103
int videoDepth
Definition: ARToolKit.h:156
virtual bool usesIRMOS() const
Definition: ARToolKit.h:112
virtual bool isReceiver() const
Definition: ARToolKit.h:116
Action listener for events triggered by any coTUIElement.
Definition: coTUIListener.h:58
virtual void updateMarkerParams()
Definition: ARToolKit.h:93
osg::Geometry * geom
Definition: ARToolKit.h:219
std::string m_artoolkitVariant
Definition: ARToolKit.h:160
coTUIToggleButton * displayQuad
Definition: ARToolKit.h:220
virtual osg::Matrix getMat(int, double[2], double, double[3][4])
Definition: ARToolKit.h:84
Definition: ARToolKit.h:100
unsigned char * videoDataRight
Definition: ARToolKit.h:152
Definition: ARToolKit.h:126
int videoWidth
Definition: ARToolKit.h:153
virtual bool isARToolKit()
Definition: ARToolKit.h:94
bool testImage
Definition: ARToolKit.h:164
Definition: ARToolKit.h:50
virtual covise::ClientConnection * getIRMOSClient() const
Definition: ARToolKit.h:120