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