passivecapsule.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: passivecapsule.h,v $ 00024 * Revision 1.2 2006/07/14 12:23:33 martius 00025 * selforg becomes HEAD 00026 * 00027 * Revision 1.1.2.4 2006/06/16 22:27:26 martius 00028 * getMainPrimtive 00029 * 00030 * Revision 1.1.2.3 2006/05/18 15:40:32 robot3 00031 * fixed setPose 00032 * 00033 * Revision 1.1.2.2 2006/05/18 15:36:15 robot3 00034 * fixed compiling bug 00035 * 00036 * Revision 1.1.2.1 2006/05/18 13:06:51 robot3 00037 * added a passive passive capsule 00038 * 00039 * 00040 * * 00041 * * 00042 ***************************************************************************/ 00043 #ifndef __PASSIVECAPSULE_H 00044 #define __PASSIVECAPSULE_H 00045 00046 #include <stdio.h> 00047 #include <math.h> 00048 00049 #include "primitive.h" 00050 #include "abstractobstacle.h" 00051 00052 namespace lpzrobots { 00053 00054 /** 00055 * (Passive) capsule as obstacle 00056 */ 00057 class PassiveCapsule : public AbstractObstacle{ 00058 float radius; 00059 float height; 00060 double mass; 00061 00062 Capsule* capsule; 00063 00064 00065 public: 00066 00067 /** 00068 * Constructor 00069 */ 00070 PassiveCapsule(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00071 float radius=1.0, float height=1.0, double mass = 1.0): 00072 AbstractObstacle::AbstractObstacle(odeHandle, osgHandle), radius(radius), height(height), mass(mass) { 00073 capsule=0; 00074 obstacle_exists=false; 00075 }; 00076 00077 ~PassiveCapsule(){ 00078 if(capsule) delete capsule; 00079 } 00080 00081 /** 00082 * update position of box 00083 */ 00084 virtual void update(){ 00085 if(capsule) capsule->update(); 00086 }; 00087 00088 virtual void setTexture(const std::string& filename){ 00089 if(capsule) capsule->getOSGPrimitive()->setTexture(filename); 00090 } 00091 00092 virtual void setPose(const osg::Matrix& pose){ 00093 this->pose = osg::Matrix::translate(0,0,height*0.5f+radius) * pose; 00094 if (obstacle_exists){ 00095 destroy(); 00096 } 00097 create(); 00098 }; 00099 00100 virtual Primitive* getMainPrimitive() const { return capsule; } 00101 00102 protected: 00103 virtual void create(){ 00104 capsule = new Capsule(radius,height); 00105 capsule->init(odeHandle, mass, osgHandle); 00106 osg::Vec3 pos=pose.getTrans(); 00107 capsule->setPosition(pos); 00108 00109 obstacle_exists=true; 00110 }; 00111 00112 virtual void destroy(){ 00113 if(capsule) delete capsule; 00114 obstacle_exists=false; 00115 }; 00116 00117 }; 00118 00119 } 00120 00121 #endif 00122

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