## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csgeom/trimeshlod.h

Go to the documentation of this file.

    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
    00033 class csTriangleVerticesCost;
    00034
    00040 class CS_CRYSTALSPACE_EXPORT csTriangleVertexCost : public csTriangleVertex
    00041 {
    00042 public:
    00044   bool deleted;
    00045
    00047   float cost;
    00049   int to_vertex;
    00050
    00052   csTriangleVertexCost () : deleted (false) { }
    00054   ~csTriangleVertexCost () { }
    00056   bool DelVertex (int idx);
    00058   void ReplaceVertex (int old, int replace);
    00059 };
    00060
    00064 class CS_CRYSTALSPACE_EXPORT csTriangleLODAlgo
    00065 {
    00066 public:
    00067   virtual ~csTriangleLODAlgo () { }
    00068
    00073   virtual void CalculateCost (csTriangleVerticesCost* vertices,
    00074         csTriangleVertexCost* vertex) = 0;
    00075 };
    00076
    00082 class CS_CRYSTALSPACE_EXPORT csTriangleLODAlgoEdge : public csTriangleLODAlgo
    00083 {
    00084 public:
    00085   virtual ~csTriangleLODAlgoEdge () { }
    00086   virtual void CalculateCost (csTriangleVerticesCost* vertices,
    00087         csTriangleVertexCost* vertex);
    00088 };
    00089
    00094 class CS_CRYSTALSPACE_EXPORT csTriangleVerticesSorted
    00095 {
    00096 private:
    00097   int num_vertices;
    00098   csTriangleVerticesCost* vertices;
    00099   csTriangleVertexCost* verts;
    00100
    00101   csList<int> sorted_list;
    00102   csList<int>::Iterator* entry_per_vertex;
    00103
    00104 public:
    00105   csTriangleVerticesSorted (csTriangleVerticesCost* vertices);
    00106   ~csTriangleVerticesSorted ();
    00107
    00114   int GetLowestCostVertex ();
    00115
    00120   void ChangeCostVertex (int vtidx);
    00121 };
    00122
    00129 class CS_CRYSTALSPACE_EXPORT csTriangleVerticesCost
    00130 {
    00131 private:
    00132   csTriangleVertexCost* vertices;
    00133   int num_vertices;
    00134
    00135 public:
    00144   csTriangleVerticesCost (csTriangleMesh* mesh, csVector3* verts,
    00145         int num_verts);
    00147   ~csTriangleVerticesCost ();
    00152   void UpdateVertices (csVector3* verts);
    00153
    00155   int GetVertexCount () const { return num_vertices; }
    00157   csTriangleVertexCost* GetVertices () const { return vertices; }
    00159   csTriangleVertexCost& GetVertex (int idx) { return vertices[idx]; }
    00160
    00162   void CalculateCost (csTriangleLODAlgo* lodalgo);
    00163
    00165   int GetMinimalCostVertex (float& min_cost);
    00166
    00170   csTriangleVerticesSorted* SortVertices ();
    00171
    00173   void Dump ();
    00174 };
    00175
    00180 class CS_CRYSTALSPACE_EXPORT csTriangleMeshLOD
    00181 {
    00182 public:
    00203   static void CalculateLOD (csTriangleMesh* mesh,
    00204         csTriangleVerticesCost* verts,
    00205         int* translate, int* emerge_from, csTriangleLODAlgo* lodalgo);
    00206
    00222   static csTriangle* CalculateLOD (csTriangleMesh* mesh,
    00223         csTriangleVerticesCost* verts, float max_cost, int& num_triangles,
    00224         csTriangleLODAlgo* lodalgo);
    00225
    00241   static csTriangle* CalculateLODFast (csTriangleMesh* mesh,
    00242         csTriangleVerticesCost* verts, float max_cost, int& num_triangles,
    00243         csTriangleLODAlgo* lodalgo);
    00244 };
    00245
    00248 #endif // __CS_TRIMESHLOD_H__