randomobstacles.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __RANDOMOBSTACLES_H
00025 #define __RANDOMOBSTACLES_H
00026
00027 #include "abstractobstacle.h"
00028 #include "abstractground.h"
00029 #include "pos.h"
00030
00031 namespace lpzrobots {
00032
00033 struct RandomObstaclesConf {
00034 Pos area;
00035 osg::Matrix pose;
00036 Pos minSize;
00037 Pos maxSize;
00038 double minDensity;
00039 double maxDensity;
00040 int boxRelFreq;
00041 int sphereRelFreq;
00042 int capRelFreq;
00043 };
00044
00045
00046
00047
00048
00049
00050
00051 class RandomObstacles : public AbstractObstacle {
00052
00053 int index;
00054 RandomObstaclesConf conf;
00055 public:
00056 enum OType {Box, Sphere, Caps, ORandom};
00057 enum SType {Metal, Plastic, Rubber, Foam, SRandom};
00058
00059
00060 static RandomObstaclesConf getDefaultConf(AbstractGround* ground = 0){
00061 RandomObstaclesConf c;
00062 if(ground){
00063 c.area = Pos(ground->getGroundLength()/2, ground->getGroundWidth()/2, 5)*0.95;
00064 c.pose = ground->getPose();
00065 }else{
00066 c.area = Pos(10,10,4);
00067 c.pose = osg::Matrix::translate(0,0,0);
00068 }
00069 c.minSize = Pos(.5,.5,.5);
00070 c.maxSize = Pos(2,2,2);
00071 c.minDensity=1;
00072 c.maxDensity=10;
00073 c.boxRelFreq=5;
00074 c.sphereRelFreq=1;
00075 c.capRelFreq=1;
00076 return c;
00077 }
00078
00079 RandomObstacles(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00080 const RandomObstaclesConf& conf = getDefaultConf());
00081
00082
00083 virtual void setPose(const osg::Matrix& pose);
00084
00085 virtual Primitive* getMainPrimitive() const;
00086
00087 virtual void create(){};
00088
00089 virtual void remove(bool all = false);
00090
00091 virtual void spawn(OType type = ORandom , SType subtype = SRandom);
00092
00093 };
00094
00095 }
00096
00097 #endif
00098
00099
00100