terrain.hh
来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· HH 代码 · 共 211 行
HH
211 行
/* * Gazebo - Outdoor Multi-Robot Simulator * Copyright (C) 2003 * Nate Koenig & Andrew Howard * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *//* Desc: Terrain main class * Author: Nate Keonig * Date: 05 Nov 2004 * CVS: $Id: Terrain.hh,v 1.7 2005/10/12 15:46:29 natepak Exp $ */#ifndef TERRAIN_HH#define TERRAIN_HH#include <gdal_priv.h>#include <GL/gl.h>class TerrainPatch;class IndexNode;class IndexList;class Terrain{ public: Terrain(); public: virtual ~Terrain(); // Load a data file, and modify it according to the set values public: int Load( const char *filename); // Write the terrain data to a file public: void Write(const char *outputFilename); // Output some useful information public: void PrintInfo(); ///////////////////////////////////////////////////////////////////////////// // Mutators ///////////////////////////////////////////////////////////////////////////// public: void SetUTMZone(int zone); public: void SetXOffset( double x ); public: void SetYOffset( double y ); public: void SetZOffset( double z ); public: void SetScale( float horzScale, float vertScale ); public: void SetHorzScale( float horzScale); public: void SetVertScale( float vertScale); public: void SetNormalizeZ( bool normalize ); public: void SetTextureSize( float s, float t ); public: void SetSTextureSize( float s ); public: void SetTTextureSize( float t ); public: void SetErrorBound( double err ); ///////////////////////////////////////////////////////////////////////////// // Accessors ///////////////////////////////////////////////////////////////////////////// public: int GetUTMZone(); public: float GetEasting(); public: float GetNorthing(); public: void GetOffsets( double &x, double &y, double &z ); public: void GetScale( float &horzScale, float &vertScale ); public: bool GetNormalizeZ(); public: void GetTextureSize( float &s, float &t ); public: double GetErrorBound(); public: void GetOrigDataSize( double &width, double &height ); public: void GetModDataSize( double &width, double &height ); public: void GetMapSize( double &width, double &height ); public: void GetNumPatches( double &xCount, double &yCount ); public: int GetVertexStride(); public: int GetReducedVertexCount(); public: int GetReducedIndexCount(); public: const GLfloat *GetReducedVertices(); public: const GLuint *GetReducedIndices(); ///////////////////////////////////////////////////////////////////////////// // Helper Routines ///////////////////////////////////////////////////////////////////////////// // Cleanup all the old stuff private: void Cleanup(); // Convert to UTM coordinates private: int Warp( const char *filename ); // Initialize all the varables private: void Initialize(); // Load the data private: void LoadData(); // Reduce the data to it finall patchified form private: void Reduce(); ///////////////////////////////////////////////////////////////////////////// // Attributes ///////////////////////////////////////////////////////////////////////////// // GDAL data file descriptor private: GDALDataset *dataSet; // UTM Coord private: float easting, northing; // Width x Length of the data points private: double dataSizeOrigX; private: double dataSizeOrigY; private: double dataSizeOrigZ; private: double dataSizeModX; private: double dataSizeModY; private: double dataSizeModZ; // Width(x) x Length(y) x Height(z) private: double mapSizeX; private: double mapSizeY; private: double mapSizeZ; // Coverage size of each pixel (eg 10m x 10m) private: double pixelSizeX; private: double pixelSizeY; // Number of patches private: double numPatchesX; private: double numPatchesY; // Location offset values private: double offsetsX; private: double offsetsY; private: double offsetsZ; // Size of each patch (in data points). A patch is square private: unsigned int patchSize; // UTM Zone private: int utmZone; // Scaling factors private: float horzScale, vertScale; // Should we normalize the z-values before applying vertScale private: bool normalizeZ; // Size of the s and t texture spacings private: float sTextureSize, tTextureSize; // Error Bound private: double errBound; // Array of all the patches private: TerrainPatch **patches; // Packed vertex array private: GLfloat *vertices; private: IndexList *indexList; private: IndexList *odeIndexList; private: GLfloat *reducedVertices; private: GLuint reducedVertexCount; private: GLuint *reducedIndices; private: GLuint reducedIndexCount; private: GLuint *reducedODEIndices; private: GLuint reducedODEIndexCount;};class IndexNode{ public: IndexNode(); public: IndexNode *next; public: IndexNode *prev; public: GLuint index;};class IndexList{ public: IndexList(); public: virtual ~IndexList(); public: void Push( GLuint index ); public: IndexNode *head; public: IndexNode *tail; public: unsigned int size; public: GLuint max;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?