| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: progressivemesh.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00018 // $Date: 2007-08-09 09:51:16 +0200 (Thu, 09 Aug 2007) $ 00019 // $Revision: 6014 $ 00020 // $State$ 00021 // $Author: Konstantin_Baumann $ 00022 // 00023 // $Log$ 00024 // Revision 1.18 2005/01/03 01:43:08 klimetschek 00025 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00026 // - removed vrs.vcproj 00027 // minor things: 00028 // - added all glutexamples to vrs4glut.sln 00029 // - fixed some problems in glutexamples 00030 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00031 // 00032 // Revision 1.17 2004/07/09 09:29:27 kirsch 00033 // Doxygen fix: moved comments behind method declarations 00034 // 00035 // Revision 1.16 2004/03/12 16:28:39 baumann 00036 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00037 // 00038 // Revision 1.15 2004/01/19 11:43:57 baumann 00039 // serialization mechanism improved 00040 // 00041 // Revision 1.14 2004/01/19 07:28:03 baumann 00042 // serialization mechanism improved 00043 // 00044 // Revision 1.13 2003/11/07 14:19:24 kirsch 00045 // removed leading underscore from include guards 00046 // 00047 // Revision 1.12 2003/07/23 17:04:49 baumann 00048 // code cleanup (especially untabified) 00049 // 00050 // Revision 1.11 2002/11/06 13:40:51 buchholz 00051 // default value of refinementSpeed is changed to 5. 00052 // 00053 // Revision 1.10 2002/10/29 10:32:52 baumann 00054 // macros VRS_CLASSNAME_* and VRS_IMPL_TYPEINFO_* removed 00055 // 00056 // Revision 1.9 2002/10/23 11:56:21 buchholz 00057 // comment on setRefinementSpeed() method changed (value 0 is now accepted) 00058 // 00059 // Revision 1.8 2002/10/22 12:03:29 buchholz 00060 // Bugfix: 2 methods were not defined, but declared. 00061 // 00062 // Revision 1.7 2002/10/22 09:42:02 kersting 00063 // added classname to enums 00064 // 00065 // Revision 1.6 2002/10/21 15:44:37 buchholz 00066 // serialization capability included 00067 // 00068 // Revision 1.5 2002/10/17 11:46:06 kirsch 00069 // dos2unix conversion 00070 // 00071 // Revision 1.4 2002/10/17 10:39:35 buchholz 00072 // full version of progressive mesh class. 00073 // changes: 00074 // - constructor takes an arbitrary polygonset and converts it 00075 // from its current form into an indexed vertex-array. This 00076 // is done by the new class PMInputConverter 00077 // - normalManager has been removed: vertex-normals are assumed 00078 // - texture and color support 00079 // - View-dependent and selective refinement included. Including the facility to 00080 // control the refinement speed. 00081 // 00082 // Revision 1.3 2002/09/05 08:33:55 kersting 00083 // added VRS_CORE_API 00084 // 00085 // Revision 1.2 2002/05/22 15:27:53 kersting 00086 // added classname to defaultvalue 00087 // 00088 // Revision 1.1 2002/04/24 15:15:58 baumann 00089 // initial version of ProgressiveMesh 00090 // 00091 00092 #ifndef VRS_PROGRESSIVEMESH_H 00093 #define VRS_PROGRESSIVEMESH_H 00094 00095 #include <vrs/shape.h> 00096 #include <vrs/container/iterator.h> 00097 #include <vrs/container/staticarray.h> 00098 #include <vrs/polygonset.h> 00099 #include <vrs/engine.h> 00100 00101 namespace VRS { 00102 00103 class ProgressiveMeshSRPMData; 00104 00105 class VRS_CORE_API ProgressiveMesh : public Shape { 00106 00107 public: 00108 00109 enum LoDControlMode { ViewIndependent, ViewDependent, 00110 ViewDependentAndSelective }; 00111 VRS_SERIALIZABLE_CLASS_ENUM(LoDControlMode); 00112 00113 enum PlacementPolicy { Optimal, Subset }; 00114 VRS_SERIALIZABLE_CLASS_ENUM(PlacementPolicy); 00115 00116 00117 ProgressiveMesh(const PolygonSet* source = 0, 00118 LoDControlMode mode = ProgressiveMesh::ViewDependent, 00119 double vertexPairTreshold = 0.0, 00120 bool preserveTopology = true, 00121 PlacementPolicy placement = ProgressiveMesh::Subset); 00258 virtual ~ProgressiveMesh(); 00259 00260 void setMode(LoDControlMode mode); 00261 LoDControlMode getMode() const; 00268 void setMaxDetail(); 00269 void setMinDetail(); 00274 bool split(UINT steps = 1); 00275 // Refines the model by undoing the last "steps" collapses. 00276 // Returns false, if the full model is achieved after less 00277 // than "steps" steps. 00278 00279 bool collapse(UINT steps = 1); 00280 // Reduces the number of vertices and triangles of the 00281 // model by applying the next n collapses of the 00282 // precalculated collapse-array. 00283 00284 void setScreenSpaceErrorTolerance(double t); 00285 double getScreenSpaceErrorTolerance() const; 00298 PolygonSet* getSnapshot() const; 00302 UINT getDetailLevel() const; 00303 UINT getMaxDetailLevel() const; 00308 UINT getNumActiveVertices() const; 00309 UINT getNumActiveTriangles() const; 00310 UINT getNumVertices() const; 00311 UINT getNumTriangles() const; 00315 bool hasPreservedTopology() const; 00316 PlacementPolicy getPlacementPolicy() const; 00322 bool consistent() const; 00323 UINT getNumBoundaryVertices() const; 00324 UINT getNumBoundaryEdges() const; 00330 Iterator<Vector>* newVertexIterator() const; 00331 Iterator<Vector>* newNormalIterator() const; 00332 Iterator<Vector>* newTextureIterator() const; 00333 Iterator<Color>* newColorIterator() const; 00334 Iterator<UINT>* newIndexIterator() const; 00338 void setRefinementSpeed(UINT frames = 5); 00339 UINT getRefinementSpeed() const; 00352 void adaptLevelOfDetail(Engine* E); 00355 virtual Bounds boundingBox() const; 00356 00357 VRS_TYPEINFO(ProgressiveMesh, Shape); 00358 VRS_SERIALIZABLE(ProgressiveMesh); 00359 00360 private: 00361 00362 LoDControlMode mode_; 00363 bool optimalPlacement_; 00364 00366 SO< StaticArray<Vector> > vertices_; 00367 SO< StaticArray<Vector> > normals_; 00368 SO< StaticArray<Vector> > textures_; 00369 SO< StaticArray<Color> > colors_; 00370 SO< StaticArray<UINT> > indices_; 00371 Bounds bounds_; 00372 00374 SO< StaticArray<UINT> > replaceBy_; 00375 SO< StaticArray<UINT> > numLostIndices_; 00376 SO< StaticArray<UINT> > numLostVertices_; 00377 SO< StaticArray<UINT> > numIndexChanges_; 00378 SO< StaticArray<Vector> > newPositions_; 00379 SO< StaticArray<UINT> > indexChanges_; 00380 00382 SO< Iterator<double> > geometricErrors_; 00383 00385 UINT numActiveIndices_; 00386 UINT numActiveVertices_; 00387 UINT nextIndexChange_; 00388 UINT currentCollapse_; 00389 00391 bool preservedTopology_; 00392 bool consistent_; 00393 UINT numBoundaryVertices_; 00394 UINT numBoundaryEdges_; 00395 00397 double tolerance_; 00398 Vector referencePoint_; 00399 00401 ProgressiveMeshSRPMData* srpmdata_; 00402 }; 00403 00404 } // namespace VRS 00405 00406 #endif // VRS_PROGRESSIVEMESH_H