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

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

- Search for |

- File List
- File Members

# passivemesh.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: passivemesh.h,v $
    00024  *   Revision 1.2  2006/07/14 12:23:33  martius
    00025  *   selforg becomes HEAD
    00026  *
    00027  *   Revision 1.1.2.5  2006/06/29 16:39:55  robot3
    00028  *   -you can now see bounding shapes if you type ./start -drawboundings
    00029  *   -includes cleared up
    00030  *   -abstractobstacle and abstractground have now .cpp-files
    00031  *
    00032  *   Revision 1.1.2.4  2006/06/27 14:14:29  robot3
    00033  *   -optimized mesh and boundingshape code
    00034  *   -other changes
    00035  *
    00036  *   Revision 1.1.2.3  2006/06/23 09:01:14  robot3
    00037  *   made changes on primitive Mesh
    00038  *
    00039  *   Revision 1.1.2.2  2006/06/16 22:27:26  martius
    00040  *   getMainPrimtive
    00041  *
    00042  *   Revision 1.1.2.1  2006/05/29 19:17:41  robot3
    00043  *   first version
    00044  *
    00045  *                                                                         *
    00046  *                                                                         *
    00047  ***************************************************************************/
    00048 #ifndef __PASSIVEMESH_H
    00049 #define __PASSIVEMESH_H
    00050
    00051 #include <stdio.h>
    00052 #include <math.h>
    00053
    00054 #include "primitive.h"
    00055 #include "osgprimitive.h"
    00056 #include "abstractobstacle.h"
    00057
    00058 namespace lpzrobots {
    00059
    00060 /**
    00061  *  (Passive) mesh as obstacle
    00062  */
    00063 class PassiveMesh : public AbstractObstacle{
    00064   std::string filename;
    00065   float scale;
    00066   double mass;
    00067
    00068   Mesh* mesh;
    00069   GlobalData globalData;
    00070
    00071
    00072  public:
    00073
    00074   /**
    00075    * Constructor
    00076    */
    00077   PassiveMesh(const OdeHandle& odeHandle, const OsgHandle& osgHandle,const string& filename,
    00078              GlobalData& globalData, double scale = 1.0, double mass = 1.0):
    00079     AbstractObstacle::AbstractObstacle(odeHandle, osgHandle),
    00080     filename(filename), scale(scale), mass(mass), globalData(globalData) {
    00081     mesh=0;
    00082     obstacle_exists=false;
    00083   };
    00084
    00085   ~PassiveMesh(){
    00086     if(mesh) delete mesh;
    00087   }
    00088
    00089   /**
    00090    * update position of mesh
    00091    */
    00092   virtual void update(){
    00093     if(mesh) mesh->update();
    00094   };
    00095
    00096 /*   virtual void setTexture(const std::string& filename){ */
    00097 /*     if(mesh) mesh->getOSGPrimitive()->setTexture(filename); */
    00098 /*   } */
    00099
    00100   virtual void setPose(const osg::Matrix& pose){
    00101     this->pose = pose;
    00102     if (obstacle_exists){
    00103       destroy();
    00104     }
    00105     create();
    00106   };
    00107
    00108
    00109   virtual Primitive* getMainPrimitive() const { return mesh; }
    00110
    00111  protected:
    00112
    00113   bool drawBoundings;
    00114
    00115   virtual void create(){
    00116     mesh = new Mesh(filename,scale,globalData);
    00117     mesh->init(odeHandle, mass, osgHandle);
    00118     osg::Vec3 pos=pose.getTrans();
    00119     pos[2]+=mesh->getRadius();
    00120     mesh->setPosition(pos);
    00121     obstacle_exists=true;
    00122   };
    00123
    00124
    00125   virtual void destroy(){
    00126     if(mesh) delete mesh;
    00127     obstacle_exists=false;
    00128   };
    00129
    00130 };
    00131
    00132 }
    00133
    00134 #endif