Robotsystem of the Robot Group Leipzig: playground.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# playground.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
    00003  *    martius@informatik.uni-leipzig.de                                    *
    00004  *    fhesse@informatik.uni-leipzig.de                                     *
    00005  *    der@informatik.uni-leipzig.de                                        *
    00006  *    frankguettler@gmx.de                                                 *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  *   $Log: playground.h,v $
    00024  *   Revision 1.18  2008/02/07 14:25:29  der
    00025  *   added setWallTexture for PlayGround
    00026  *
    00027  *   Revision 1.17  2007/08/28 09:25:13  martius
    00028  *   include primitive.h
    00029  *
    00030  *   Revision 1.16  2007/08/24 11:53:10  martius
    00031  *   Change geometry
    00032  *
    00033  *   Revision 1.15  2007/07/03 13:06:41  martius
    00034  *   groundplane thick
    00035  *
    00036  *   Revision 1.14  2007/03/16 11:01:37  martius
    00037  *   abstractobstacle gets mor functionallity
    00038  *   setSubstance
    00039  *
    00040  *   Revision 1.13  2006/09/21 22:09:12  martius
    00041  *   *** empty log message ***
    00042  *
    00043  *   Revision 1.12  2006/08/11 15:41:04  martius
    00044  *   playgrounds handle non-quadratic ground planes
    00045  *
    00046  *   Revision 1.11  2006/07/14 12:23:33  martius
    00047  *   selforg becomes HEAD
    00048  *
    00049  *   Revision 1.10.4.16  2006/07/14 11:11:53  martius
    00050  *   revert to 1.10.4.12
    00051  *
    00052  *   Revision 1.10.4.12  2006/06/29 16:39:55  robot3
    00053  *   -you can now see bounding shapes if you type ./start -drawboundings
    00054  *   -includes cleared up
    00055  *   -abstractobstacle and abstractground have now .cpp-files
    00056  *
    00057  *   Revision 1.10.4.11  2006/05/23 13:37:34  robot3
    00058  *   -fixed some creating bugs
    00059  *   -setColor,setTexture and createGround must be
    00060  *    called before setPosition now
    00061  *
    00062  *   Revision 1.10.4.10  2006/05/19 08:42:54  robot3
    00063  *   -some code moved to abstractground.h
    00064  *   -it's now possible creating a playground without a groundplane
    00065  *
    00066  *   Revision 1.10.4.9  2006/05/18 14:32:12  robot3
    00067  *   walls are now textured with a wood texture
    00068  *
    00069  *   Revision 1.10.4.8  2006/05/18 12:54:24  robot3
    00070  *   -fixed not being able to change the color after positioning
    00071  *    the obstacle
    00072  *   -cleared the files up
    00073  *
    00074  *   Revision 1.10.4.7  2006/05/18 09:43:24  robot3
    00075  *   using existing texture image in cvs for the groundplane now
    00076  *
    00077  *   Revision 1.10.4.6  2006/05/18 07:42:36  robot3
    00078  *   Grounds have now a groundPlane for shadowing issues
    00079  *   osgprimitive.cpp contains a bug that repeating textures (wrapping)
    00080  *   don't work, needs to be fixed
    00081  *
    00082  *   Revision 1.10.4.5  2006/05/11 08:59:15  robot3
    00083  *   -fixed a positioning bug (e.g. for passivesphere)
    00084  *   -some methods moved to abstractobstacle.h for avoiding inconsistencies
    00085  *
    00086  *   Revision 1.10.4.4  2006/03/29 15:04:39  martius
    00087  *   have pose now
    00088  *
    00089  *   Revision 1.10.4.3  2006/01/10 20:27:15  martius
    00090  *   protected members
    00091  *
    00092  *   Revision 1.10.4.2  2006/01/10 17:17:33  martius
    00093  *   new mode for primitives
    00094  *
    00095  *   Revision 1.10.4.1  2005/12/06 10:13:23  martius
    00096  *   openscenegraph integration started
    00097  *
    00098  *   Revision 1.10  2005/09/22 12:24:36  martius
    00099  *   removed global variables
    00100  *   OdeHandle and GlobalData are used instead
    00101  *   sensor prepared
    00102  *
    00103  *   Revision 1.9  2005/09/13 13:19:57  martius
    00104  *   no texture
    00105  *
    00106  *   Revision 1.8  2005/08/02 14:09:06  fhesse
    00107  *   factor between length in x and y direction
    00108  *   added to constructor
    00109  *
    00110  *   Revision 1.7  2005/07/29 14:27:59  martius
    00111  *   color set to some red
    00112  *
    00113  *   Revision 1.6  2005/07/18 14:52:33  martius
    00114  *   world and space are not pointers anymore.
    00115  *
    00116  *   Revision 1.5  2005/07/07 10:24:23  martius
    00117  *   avoid internal collisions
    00118  *
    00119  *   Revision 1.4  2005/06/15 14:22:11  martius
    00120  *   GPL included
    00121  *                                                                 *
    00122  ***************************************************************************/
    00123 #ifndef __PLAYGROUND_H
    00124 #define __PLAYGROUND_H
    00125
    00126 #include "mathutils.h"
    00127 #include "abstractground.h"
    00128 #include "primitive.h"
    00129
    00130 namespace lpzrobots {
    00131
    00132   class Playground : public AbstractGround {
    00133
    00134   protected:
    00135
    00136     double length, width, height;
    00137     double factorlength2;
    00138
    00139   public:
    00140
    00141     Playground(const OdeHandle& odeHandle, const OsgHandle& osgHandle ,
    00142                const osg::Vec3& dimension = osg::Vec3(7.0, 0.2, 0.5) ,
    00143                double factorxy = 1, bool createGround=true)
    00144       : AbstractGround(odeHandle, osgHandle, createGround, dimension.x(), dimension.x()*factorxy, dimension.y()) {
    00145
    00146       length=dimension.x();
    00147       width=dimension.y();
    00148       height=dimension.z();
    00149       factorlength2=factorxy;
    00150     };
    00151
    00152     virtual void changeGeometry(double length, double width, double height, double factorxy){
    00153       AbstractGround::changeGeometry(length, width, height, factorxy);
    00154       this->length = length;
    00155       this->width  = width;
    00156       this->height  = height;
    00157       this->factorlength2  = factorxy;
    00158       if (obstacle_exists) {
    00159         destroy();
    00160         create();
    00161       }
    00162     }
    00163
    00164     virtual void setWallSubstance(const Substance& substance) {
    00165       if (obstacle_exists) {
    00166         FOREACH(std::vector<Primitive*>,obst,wall) {
    00167           (*wall)->substance=substance;
    00168         }
    00169       } else
    00170         std::cerr << "PlayGround::setWallSubstance() - PlayGround gound not created!\n";
    00171
    00172     }
    00173
    00174
    00175   protected:
    00176     virtual void create(){
    00177       createGround();
    00178
    00179       Box* box;
    00180       osg::Vec3 offset(- (length/2 + width/2),
    00181                        0,
    00182                        height/2+0.01f/*reduces graphic errors and ode collisions*/);
    00183       box = new Box( width , (length * factorlength2) + 2 * width , height);
    00184       box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
    00185       box->setPose(osg::Matrix::translate(offset) * pose);
    00186       box->getOSGPrimitive()->setTexture(wallTextureFileName);
    00187       obst.push_back(box);
    00188
    00189       offset.x() = length/2 + width/2;
    00190       box = new Box( width , (length * factorlength2) + 2 * width , height);
    00191       box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
    00192       box->setPose(osg::Matrix::translate(offset) * pose);
    00193       box->getOSGPrimitive()->setTexture(wallTextureFileName);
    00194       obst.push_back(box);
    00195
    00196       offset.x() = 0;
    00197       offset.y() = -( (length*factorlength2)/2 +width/2);
    00198       box = new Box( length, width, height);
    00199       box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
    00200       box->setPose(osg::Matrix::translate(offset) * pose);
    00201       box->getOSGPrimitive()->setTexture(wallTextureFileName);
    00202       obst.push_back(box);
    00203
    00204       offset.y() = (length*factorlength2)/2 +width/2;
    00205       box = new Box( length, width, height);
    00206       box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
    00207       box->setPose(osg::Matrix::translate(offset) * pose);
    00208       box->getOSGPrimitive()->setTexture(wallTextureFileName);
    00209       obst.push_back(box);
    00210
    00211       obstacle_exists=true;
    00212     };
    00213
    00214   };
    00215
    00216 }
    00217
    00218 #endif