terrainpatch.hh

来自「机器人人3D仿真工具,可以加入到Simbad仿真环境下应用。」· HH 代码 · 共 110 行

HH
110
字号
/* *  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: A single patch of terrain * Author: Nate Keonig * Date: 30 April 2004 * CVS: $Id: TerrainPatch.hh,v 1.3 2004/11/15 17:11:45 natepak Exp $ */#ifndef TERRAINPATCH_HH#define TERRAINPATCH_HH#include "Vector.hh"class Terrain;class TerrainPatch{  // Directions of other patches  public: enum Direction {TOP, RIGHT, BOTTOM, LEFT};  public: TerrainPatch(unsigned int size, double err, GLfloat *vertices);  public: virtual ~TerrainPatch();  public: void Init();  // Attach a neighbor to a direction  public: void SetNeighbor( TerrainPatch *neigh, Direction dir);  // Set the vertex index for the local x,y coordinate inside the patch  public: void SetVertex(short x, short y, unsigned int vertex);  // Create the triangle strip for this patch  public: void CreateStrip(unsigned int index, IndexList *indexList,              IndexList *odeIndexList, bool &facing);  // Return the tesselation level  public: unsigned short GetTessLevel();  public: void Render();  // Fix the border vertices to prevent gaps  private: void FixBorders();  // Add a vertex to the index array  private: void AddStripIndex(unsigned int index, IndexList *indexList);  // Return the coordinates of the vertex[index]  private: double GetVertexPosX(unsigned int index);  private: double GetVertexPosY(unsigned int index);  private: double GetVertexPosZ(unsigned int index);  // Calcuate the normal for a single triangle  private: void CalcNormal(unsigned int one, unsigned int two,                unsigned int three);  // Is the triangle valid (not degenerate)?  private: bool IsValidTriangle( int i1, int i2, int i3 );  // Our neighbors  private: TerrainPatch *neighbors[4];  // Size of the square patch (just on side)  public: unsigned int size;  private: double errBound;  // The center of the patch  private: double minCoordsX;  private: double minCoordsY;  private: double minCoordsZ;  private: double maxCoordsX;  private: double maxCoordsY;  private: double maxCoordsZ;  // The vertex data. The vertices array holds indexes into the main  // vertex array that is maintained by TerainGeom  private: int *allIndices;  private: unsigned short tessLevel;  private: GLuint *finalIndices;  private: int numFinalIndices;  private: int maxFinalIndices;   // Packed vertex array  private: GLfloat *vertices;};#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?