Gazebo

HeightmapGeom.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: Trimesh geometry
00022  * Author: Nate Keonig, Andrew Howard
00023  * Date: 8 May 2003
00024  * CVS: $Id: HeightmapGeom.hh 273 2008-02-22 21:16:15Z natepak $
00025  */
00026 
00027 #ifndef HEIGHTMAPGEOM_HH
00028 #define HEIGHTMAPGEOM_HH
00029 
00030 #include <Ogre.h>
00031 
00032 #include "Vector2.hh"
00033 #include "Geom.hh"
00034 
00035 namespace gazebo
00036 {
00039 
00071 
00072 
00073 
00074 
00075 
00077   class HeightmapGeom : public Geom, public Ogre::RaySceneQueryListener
00078   {
00080     public: HeightmapGeom(Body *body);
00081 
00083     public: virtual ~HeightmapGeom();
00084 
00086     public: void UpdateChild();
00087 
00089     public: float GetHeightAt(const Vector2<float> &pos);
00090 
00092     public: virtual bool queryResult(Ogre::MovableObject *obj, Ogre::Real dist);
00093 
00095     public: virtual bool queryResult(Ogre::SceneQuery::WorldFragment *frag, Ogre::Real dist);
00096 
00098     protected: virtual void LoadChild(XMLConfigNode *node);
00099 
00101     private: void FillHeightMap();
00102 
00104     private: static dReal GetHeightCallback(void *data, int x, int y);
00105 
00106     private: dHeightfieldDataID odeData;
00107 
00108     private: Vector3 terrainSize;
00109     private: Vector3 terrainScale;
00110 
00111     private: unsigned int odeVertSize;
00112     private: Vector3 odeScale;
00113 
00114     private: unsigned int terrainVertSize;
00115     private: std::string terrainImage;
00116 
00117     private: Ogre::Ray ray;
00118     private: Ogre::RaySceneQuery *rayQuery;
00119 
00120     private: double distToTerrain;
00121 
00122     private: std::vector<double> heights;
00123   };
00124 
00126 }
00127 
00128 #endif

Last updated Aug 04 2007