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.11  2006/07/14 12:23:33  martius
00025  *   selforg becomes HEAD
00026  *
00027  *   Revision 1.10.4.16  2006/07/14 11:11:53  martius
00028  *   revert to 1.10.4.12
00029  *
00030  *   Revision 1.10.4.12  2006/06/29 16:39:55  robot3
00031  *   -you can now see bounding shapes if you type ./start -drawboundings
00032  *   -includes cleared up
00033  *   -abstractobstacle and abstractground have now .cpp-files
00034  *
00035  *   Revision 1.10.4.11  2006/05/23 13:37:34  robot3
00036  *   -fixed some creating bugs
00037  *   -setColor,setTexture and createGround must be
00038  *    called before setPosition now
00039  *
00040  *   Revision 1.10.4.10  2006/05/19 08:42:54  robot3
00041  *   -some code moved to abstractground.h
00042  *   -it's now possible creating a playground without a groundplane
00043  *
00044  *   Revision 1.10.4.9  2006/05/18 14:32:12  robot3
00045  *   walls are now textured with a wood texture
00046  *
00047  *   Revision 1.10.4.8  2006/05/18 12:54:24  robot3
00048  *   -fixed not being able to change the color after positioning
00049  *    the obstacle
00050  *   -cleared the files up
00051  *
00052  *   Revision 1.10.4.7  2006/05/18 09:43:24  robot3
00053  *   using existing texture image in cvs for the groundplane now
00054  *
00055  *   Revision 1.10.4.6  2006/05/18 07:42:36  robot3
00056  *   Grounds have now a groundPlane for shadowing issues
00057  *   osgprimitive.cpp contains a bug that repeating textures (wrapping)
00058  *   don't work, needs to be fixed
00059  *
00060  *   Revision 1.10.4.5  2006/05/11 08:59:15  robot3
00061  *   -fixed a positioning bug (e.g. for passivesphere)
00062  *   -some methods moved to abstractobstacle.h for avoiding inconsistencies
00063  *
00064  *   Revision 1.10.4.4  2006/03/29 15:04:39  martius
00065  *   have pose now
00066  *
00067  *   Revision 1.10.4.3  2006/01/10 20:27:15  martius
00068  *   protected members
00069  *
00070  *   Revision 1.10.4.2  2006/01/10 17:17:33  martius
00071  *   new mode for primitives
00072  *
00073  *   Revision 1.10.4.1  2005/12/06 10:13:23  martius
00074  *   openscenegraph integration started
00075  *
00076  *   Revision 1.10  2005/09/22 12:24:36  martius
00077  *   removed global variables
00078  *   OdeHandle and GlobalData are used instead
00079  *   sensor prepared
00080  *
00081  *   Revision 1.9  2005/09/13 13:19:57  martius
00082  *   no texture
00083  *
00084  *   Revision 1.8  2005/08/02 14:09:06  fhesse
00085  *   factor between length in x and y direction
00086  *   added to constructor
00087  *
00088  *   Revision 1.7  2005/07/29 14:27:59  martius
00089  *   color set to some red
00090  *
00091  *   Revision 1.6  2005/07/18 14:52:33  martius
00092  *   world and space are not pointers anymore.
00093  *
00094  *   Revision 1.5  2005/07/07 10:24:23  martius
00095  *   avoid internal collisions
00096  *
00097  *   Revision 1.4  2005/06/15 14:22:11  martius
00098  *   GPL included
00099  *                                                                 *
00100  ***************************************************************************/
00101 #ifndef __PLAYGROUND_H
00102 #define __PLAYGROUND_H
00103 
00104 #include "mathutils.h"
00105 #include "abstractground.h"
00106  
00107 namespace lpzrobots {
00108 
00109 //Fixme: playground creates collisions with ground and itself
00110 //fixed: collisions with ground
00111 class Playground : public AbstractGround {
00112 
00113 protected:
00114 
00115   double length, width, height;
00116   double factorlength2;
00117 
00118 public:
00119   
00120   Playground(const OdeHandle& odeHandle, const OsgHandle& osgHandle , 
00121              const osg::Vec3& dimension = osg::Vec3(7.0, 0.2, 0.5) ,
00122              double factorxy = 1, bool createGround=true):
00123     AbstractGround::AbstractGround(odeHandle, osgHandle, createGround){
00124 
00125     length=dimension.x();
00126     width=dimension.y();
00127     height=dimension.z();
00128     factorlength2=factorxy;
00129 
00130   };
00131 
00132  protected:
00133   virtual void create(){
00134     Box* box;
00135     osg::Vec3 offset(- (length/2 + width/2),
00136                      0,
00137                      height/2+0.01f/*reduces graphic errors and ode collisions*/);
00138     box = new Box( width , (length * factorlength2) + 2 * width , height);
00139     box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
00140     box->setPose(osg::Matrix::translate(offset) * pose);
00141     box->getOSGPrimitive()->setTexture(wallTextureFileName);
00142     obst.push_back(box);
00143 
00144     offset.x() = length/2 + width/2;
00145     box = new Box( width , (length * factorlength2) + 2 * width , height);
00146     box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
00147     box->setPose(osg::Matrix::translate(offset) * pose);
00148     box->getOSGPrimitive()->setTexture(wallTextureFileName);
00149     obst.push_back(box);
00150 
00151     offset.x() = 0;
00152     offset.y() = -( (length*factorlength2)/2 +width/2);
00153     box = new Box( length, width, height);
00154     box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
00155     box->setPose(osg::Matrix::translate(offset) * pose);
00156     box->getOSGPrimitive()->setTexture(wallTextureFileName);
00157     obst.push_back(box);
00158 
00159     offset.y() = (length*factorlength2)/2 +width/2;
00160     box = new Box( length, width, height);
00161     box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw);
00162     box->setPose(osg::Matrix::translate(offset) * pose);
00163     box->getOSGPrimitive()->setTexture(wallTextureFileName);
00164     obst.push_back(box);
00165     
00166     // size of groundplane
00167     ground_length=length;
00168 
00169     obstacle_exists=true;
00170   };
00171 
00172 };
00173 
00174 }
00175 
00176 #endif

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7