00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #ifndef __OSGPRIMITIVE_H
00084 #define __OSGPRIMITIVE_H
00085
00086 #include <string>
00087 #include <osg/ref_ptr>
00088 #include "osgforwarddecl.h"
00089 #include "osghandle.h"
00090 #include <osgDB/ReadFile>
00091
00092 namespace lpzrobots {
00093
00094
00095
00096
00097
00098
00099 class OSGPrimitive {
00100 public:
00101 typedef enum Quality {Low, Middle, High};
00102
00103 OSGPrimitive ();
00104 virtual ~OSGPrimitive ();
00105
00106
00107 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle) = 0;
00108
00109 virtual void setMatrix( const osg::Matrix& m4x4 );
00110
00111 virtual osg::Group* getGroup();
00112
00113 virtual void setTexture(const std::string& filename);
00114
00115 virtual void setTexture(const std::string& filename, bool repeatOnX, bool repeatOnY);
00116
00117 virtual void setColor(const Color& color);
00118
00119 virtual osg::Transform* getTransform();
00120
00121 protected:
00122 osg::ref_ptr<osg::Geode> geode;
00123 osg::ref_ptr<osg::MatrixTransform> transform;
00124 osg::ref_ptr<osg::ShapeDrawable> shape;
00125 };
00126
00127
00128
00129
00130 class OSGDummy : public OSGPrimitive {
00131 public:
00132 OSGDummy();
00133
00134 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00135 virtual void setMatrix( const osg::Matrix& m4x4 );
00136 virtual osg::Group* getGroup();
00137 virtual void setTexture(const std::string& filename);
00138 virtual void setColor(const Color& color);
00139
00140 virtual osg::Transform* getTransform();
00141 };
00142
00143
00144
00145
00146
00147 class OSGPlane : public OSGPrimitive {
00148 public:
00149 OSGPlane();
00150
00151 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00152 };
00153
00154
00155
00156
00157
00158 class OSGBox : public OSGPrimitive {
00159 public:
00160 OSGBox(float lengthX, float lengthY, float lengthZ);
00161 OSGBox(osg::Vec3 dim);
00162
00163 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00164
00165 osg::Vec3 getDim();
00166 void setDim(osg::Vec3);
00167
00168 protected:
00169 osg::Vec3 dim;
00170 osg::Box* box;
00171 };
00172
00173
00174
00175
00176
00177 class OSGSphere : public OSGPrimitive {
00178 public:
00179 OSGSphere(float radius);
00180
00181 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00182
00183 float getRadius() { return radius; }
00184 protected:
00185 float radius;
00186 };
00187
00188
00189
00190
00191 class OSGCapsule : public OSGPrimitive {
00192 public:
00193 OSGCapsule(float radius, float height);
00194
00195 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00196
00197 float getRadius() { return radius; }
00198 float getHeight() { return height; }
00199 protected:
00200 float radius;
00201 float height;
00202 };
00203
00204
00205
00206
00207
00208 class OSGCylinder : public OSGPrimitive {
00209 public:
00210 OSGCylinder(float radius, float height);
00211
00212 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00213
00214 float getRadius() { return radius; }
00215 float getHeight() { return height; }
00216 protected:
00217 float radius;
00218 float height;
00219 };
00220
00221
00222
00223
00224
00225 class OSGMesh : public OSGPrimitive {
00226 public:
00227
00228
00229
00230
00231
00232
00233 OSGMesh(const std::string& filename, float scale = 1, const osgDB::ReaderWriter::Options* options = 0);
00234 ~OSGMesh();
00235 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00236 virtual float getRadius();
00237 float getScale() { return scale; }
00238
00239 protected:
00240 std::string filename;
00241 float scale;
00242 const osgDB::ReaderWriter::Options* options;
00243 osg::ref_ptr<osg::Node> mesh;
00244 osg::ref_ptr<osg::MatrixTransform> scaletrans;
00245
00246 };
00247
00248 }
00249
00250 #endif
00251