invisibleprimitive.cpp

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  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                         *
00022  ***************************************************************************
00023  *                                                                         *
00024  *   $Log: invisibleprimitive.cpp,v $
00025  *   Revision 1.1.2.1  2006/01/12 14:22:49  martius
00026  *   invisibles
00027  *
00028  *                                                                 *
00029  *                                                                         *
00030  ***************************************************************************/
00031 
00032 #include <assert.h>
00033 #include <ode/ode.h>
00034 
00035 #include "invisibleprimitive.h"
00036 
00037 namespace lpzrobots{
00038 
00039   /******************************************************************************/
00040   InvisibleBox::InvisibleBox(float lengthX, float lengthY, float lengthZ) 
00041     : lengthX(lengthX), lengthY(lengthY), lengthZ(lengthZ){
00042   }
00043 
00044   void InvisibleBox::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00045                     char mode) {
00046     assert(mode & Body || mode & Geom);
00047     this->mode=mode;
00048     if (mode & Body){
00049       body = dBodyCreate (odeHandle.world);
00050       dMass m;
00051       // fake the mass of the plane with a thin box
00052       dMassSetBox(&m, 1, lengthX, lengthY, lengthZ);
00053       dMassAdjust (&m, mass); 
00054       dBodySetMass (body,&m); //assign the mass to the body      
00055     }  
00056     if (mode & Geom){    
00057       geom = dCreateBox ( odeHandle.space , lengthX, lengthY, lengthZ);
00058       if (mode & Body){
00059         dGeomSetBody (geom, body); // geom is assigned to body
00060       }
00061     }
00062   }
00063 
00064 
00065   /******************************************************************************/
00066   InvisibleSphere::InvisibleSphere(float radius) 
00067     : radius(radius)  {    
00068   }
00069   
00070   void InvisibleSphere::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00071                     char mode) {
00072     assert(mode & Body || mode & Geom);
00073     this->mode=mode;
00074     if (mode & Body){
00075       body = dBodyCreate (odeHandle.world);
00076       dMass m;
00077       dMassSetSphere(&m, 1, radius);
00078       dMassAdjust (&m, mass); 
00079       dBodySetMass (body,&m); //assign the mass to the body
00080     }  
00081     if (mode & Geom){
00082       geom = dCreateSphere ( odeHandle.space , radius);
00083       if (mode & Body)
00084         dGeomSetBody (geom, body); // geom is assigned to body
00085     }
00086     
00087   }
00088   
00089   /******************************************************************************/
00090   InvisibleCapsule::InvisibleCapsule(float radius, float height)
00091     : radius(radius), height(height) { 
00092   }
00093   
00094   void InvisibleCapsule::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
00095                     char mode) {
00096     assert(mode & Body || mode & Geom);
00097     this->mode=mode;
00098     if (mode & Body){
00099       body = dBodyCreate (odeHandle.world);
00100       dMass m;
00101       dMassSetCappedCylinder(&m, 1.0, 3 , radius, height); 
00102       dMassAdjust (&m, mass); 
00103       dBodySetMass (body,&m); //assign the mass to the body
00104     }  
00105     if (mode & Geom){    
00106       geom = dCreateCCylinder ( odeHandle.space , radius, height); 
00107       if (mode & Body)
00108         dGeomSetBody (geom, body); // geom is assigned to body      
00109     }
00110   }
00111 
00112 }

Generated on Tue Apr 4 19:05:03 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5