Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
trimeshlod.h
00001 /* 00002 Copyright (C) 1998,2001 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_TRIMESHLOD_H__ 00020 #define __CS_TRIMESHLOD_H__ 00021 00022 #include "csextern.h" 00023 00024 #include "csgeom/trimesh.h" 00025 #include "csutil/list.h" 00026 00027 class csTriangleVerticesCost; 00028 00034 class CS_CRYSTALSPACE_EXPORT csTriangleVertexCost : public csTriangleVertex 00035 { 00036 public: 00038 bool deleted; 00039 00041 float cost; 00043 int to_vertex; 00044 00046 csTriangleVertexCost () : deleted (false) { } 00048 ~csTriangleVertexCost () { } 00050 bool DelVertex (int idx); 00052 void ReplaceVertex (int old, int replace); 00053 }; 00054 00058 class CS_CRYSTALSPACE_EXPORT csTriangleLODAlgo 00059 { 00060 public: 00061 virtual ~csTriangleLODAlgo () { } 00062 00067 virtual void CalculateCost (csTriangleVerticesCost* vertices, 00068 csTriangleVertexCost* vertex) = 0; 00069 }; 00070 00076 class CS_CRYSTALSPACE_EXPORT csTriangleLODAlgoEdge : public csTriangleLODAlgo 00077 { 00078 public: 00079 virtual ~csTriangleLODAlgoEdge () { } 00080 virtual void CalculateCost (csTriangleVerticesCost* vertices, 00081 csTriangleVertexCost* vertex); 00082 }; 00083 00088 class CS_CRYSTALSPACE_EXPORT csTriangleVerticesSorted 00089 { 00090 private: 00091 int num_vertices; 00092 csTriangleVerticesCost* vertices; 00093 csTriangleVertexCost* verts; 00094 00095 csList<int> sorted_list; 00096 csList<int>::Iterator* entry_per_vertex; 00097 00098 public: 00099 csTriangleVerticesSorted (csTriangleVerticesCost* vertices); 00100 ~csTriangleVerticesSorted (); 00101 00108 int GetLowestCostVertex (); 00109 00114 void ChangeCostVertex (int vtidx); 00115 }; 00116 00123 class CS_CRYSTALSPACE_EXPORT csTriangleVerticesCost 00124 { 00125 private: 00126 csTriangleVertexCost* vertices; 00127 int num_vertices; 00128 00129 public: 00138 csTriangleVerticesCost (csTriangleMesh* mesh, csVector3* verts, 00139 int num_verts); 00141 ~csTriangleVerticesCost (); 00146 void UpdateVertices (csVector3* verts); 00147 00149 int GetVertexCount () const { return num_vertices; } 00151 csTriangleVertexCost* GetVertices () const { return vertices; } 00153 csTriangleVertexCost& GetVertex (int idx) { return vertices[idx]; } 00154 00156 void CalculateCost (csTriangleLODAlgo* lodalgo); 00157 00159 int GetMinimalCostVertex (float& min_cost); 00160 00164 csTriangleVerticesSorted* SortVertices (); 00165 00167 void Dump (); 00168 }; 00169 00174 class CS_CRYSTALSPACE_EXPORT csTriangleMeshLOD 00175 { 00176 public: 00197 static void CalculateLOD (csTriangleMesh* mesh, 00198 csTriangleVerticesCost* verts, 00199 int* translate, int* emerge_from, csTriangleLODAlgo* lodalgo); 00200 00216 static csTriangle* CalculateLOD (csTriangleMesh* mesh, 00217 csTriangleVerticesCost* verts, float max_cost, int& num_triangles, 00218 csTriangleLODAlgo* lodalgo); 00219 00235 static csTriangle* CalculateLODFast (csTriangleMesh* mesh, 00236 csTriangleVerticesCost* verts, float max_cost, int& num_triangles, 00237 csTriangleLODAlgo* lodalgo); 00238 }; 00239 00240 #endif // __CS_TRIMESHLOD_H__
Generated for Crystal Space by doxygen 1.4.4