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 #ifndef __OSGPRIMITIVE_H
00064 #define __OSGPRIMITIVE_H
00065
00066 #include <string>
00067 #include <osg/ref_ptr>
00068 #include "osgforwarddecl.h"
00069 #include "osghandle.h"
00070 #include <osgDB/ReadFile>
00071
00072 namespace lpzrobots {
00073
00074
00075
00076
00077
00078
00079 class OSGPrimitive {
00080 public:
00081
00082 typedef enum Quality {Low, Middle, High};
00083
00084 OSGPrimitive ();
00085 virtual ~OSGPrimitive ();
00086
00087
00088 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle) = 0;
00089
00090 virtual void setMatrix( const osg::Matrix& m4x4 );
00091
00092 virtual osg::Group* getGroup();
00093
00094 virtual void setTexture(const std::string& filename);
00095
00096 virtual void setColor(const Color& color);
00097
00098 virtual osg::Transform* getTransform();
00099
00100 protected:
00101 osg::ref_ptr<osg::Geode> geode;
00102 osg::ref_ptr<osg::MatrixTransform> transform;
00103 osg::ref_ptr<osg::ShapeDrawable> shape;
00104 };
00105
00106
00107
00108
00109 class OSGDummy : public OSGPrimitive {
00110 public:
00111 OSGDummy();
00112
00113 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00114 virtual void setMatrix( const osg::Matrix& m4x4 );
00115 virtual osg::Group* getGroup();
00116 virtual void setTexture(const std::string& filename);
00117 virtual void setColor(const Color& color);
00118
00119 virtual osg::Transform* getTransform();
00120 };
00121
00122
00123
00124
00125
00126 class OSGPlane : public OSGPrimitive {
00127 public:
00128 OSGPlane();
00129
00130 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00131 };
00132
00133
00134
00135
00136
00137 class OSGBox : public OSGPrimitive {
00138 public:
00139 OSGBox(float lengthX, float lengthY, float lengthZ);
00140
00141 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00142
00143 float getLengthX() { return lengthX; }
00144 float getLengthY() { return lengthY; }
00145 float getLengthZ() { return lengthZ; }
00146
00147 protected:
00148 float lengthX;
00149 float lengthY;
00150 float lengthZ;
00151 };
00152
00153
00154
00155
00156
00157 class OSGSphere : public OSGPrimitive {
00158 public:
00159 OSGSphere(float radius);
00160
00161 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00162
00163 float getRadius() { return radius; }
00164 protected:
00165 float radius;
00166 };
00167
00168
00169
00170
00171 class OSGCapsule : public OSGPrimitive {
00172 public:
00173 OSGCapsule(float radius, float height);
00174
00175 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00176
00177 float getRadius() { return radius; }
00178 float getHeight() { return height; }
00179 protected:
00180 float radius;
00181 float height;
00182 };
00183
00184
00185
00186
00187
00188 class OSGCylinder : public OSGPrimitive {
00189 public:
00190 OSGCylinder(float radius, float height);
00191
00192 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00193
00194 float getRadius() { return radius; }
00195 float getHeight() { return height; }
00196 protected:
00197 float radius;
00198 float height;
00199 };
00200
00201
00202
00203
00204
00205 class OSGMesh : public OSGPrimitive {
00206 public:
00207
00208
00209
00210
00211
00212
00213 OSGMesh(const std::string& filename, float scale = 1, const osgDB::ReaderWriter::Options* options = 0);
00214 ~OSGMesh();
00215 virtual void init(const OsgHandle& osgHandle, Quality quality = Middle);
00216
00217 float getScale() { return scale; }
00218 protected:
00219 std::string filename;
00220 float scale;
00221 const osgDB::ReaderWriter::Options* options;
00222 osg::ref_ptr<osg::Node> mesh;
00223 osg::ref_ptr<osg::MatrixTransform> scaletrans;
00224
00225 };
00226
00227 }
00228
00229 #endif
00230