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

Generated on Tue Jan 16 02:14:37 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8