Main Page Class Hierarchy Compound List File List Compound Members File Members

MRModel.h

Go to the documentation of this file.
00001 /*
00002 File: MRModel.h
00003 
00004 Function: Implements edge-contraction multires polygonal model
00005 
00006 Author: Andrew Willmott
00007 
00008 Copyright: (c) 1997-2000, Andrew Willmott
00009 */
00010 
00011 #ifndef __MRModel__
00012 #define __MRModel__
00013 
00014 #include "gcl/MRVertex.h"
00015 #include "gcl/MRFaceCluster.h"
00016 #include "gcl/Renderer.h"
00017 
00018  typedef Array<Byte> ActList;
00019 
00020  enum MRM_Flags
00021 {
00022 MRM_MemMapped = 0x0001,
00023 MRM_Ordered = 0x0002,
00024 MRM_End
00025 };
00026 
00027  class MRModel
00033 {
00034 public:
00035 MRModel();
00036 ~MRModel();
00037 
00038 // Adaption routines
00039 Void SimplestModel();
00041 Void MostComplexModel();
00043 
00044 Void AdaptFaces(Int targetFaces);
00046 Void AdaptClusters(Int targetClusters);
00048 Void AdaptComplexity(GCLReal complexity);
00051 
00052 Void AdaptLength(
00053 GCLReal threshold, 
00054 const Transform &M, 
00055 const Transform &P, 
00056 Float timeLimit = vl_inf 
00057 );
00059 
00060 // Parsing
00061 Bool Parse(StrConst filename);
00062 Bool ParseBinary();
00063 Bool ParseText();
00064 Void WriteBinary();
00065 
00066 // Drawing
00067 Void Draw(Renderer &r);
00068 
00069 // Internal utility routines
00070 Void PrepareModel();
00071 Void AdjustLeafFaces();
00072 
00073 Void PrepareClusters();
00074 Void PrepareVertices();
00075 
00076 Void DrawClusterFaces(Int i, Renderer &r);
00077 Void DrawClusters(Renderer &r);
00078 Void DrawVertices(Renderer &r);
00079 
00080 Vector FaceAreaNormal(Int faceIdx);
00081 Int ReorderLeafClusters(Int ic, FaceIdxArray &newFaces);
00082 Void CropClusters(Int numClusters);
00083 Void CreateClusterColours();
00084 Void DumpFCH(StrConst filename);
00085 Void UpdateBounds(Point &min, Point &max,
00086 const Transform &t);
00087 
00088 Void AddContraction(
00089 Int child0,
00090 Int child1,
00091 Int face1,
00092 Int face2,
00093 GCLReal error,
00094 const Point &p,
00095 Int delta
00096 );
00097 
00098 Void AddCluster(
00099 Int child0,
00100 Int child1,
00101 Point &centre,
00102 VecTrans &axis,
00103 Vector &fitNormal,
00104 GCLReal d,
00105 Point &clusMin,
00106 Point &clusMax,
00107  Int clusID
00108  );
00109  
00110  // basic model
00111 PointList *points; 
00112 ColourList *colours; 
00113  Colour colour; 
00114  FaceIdxArray faces; 
00115  
00116  // vertex-contraction stuff
00117  Int currentFaces; 
00118  IndexList rootVertices; 
00119  MRVertexes vertices; 
00120 MRCodesList vtxCodes; 
00121 MRFlagsList vtxFlags; 
00122  FaceIdxArray vtxFaces; 
00123  Bool verticesPrepped;
00124  
00125  // face cluster stuff
00126  Int currentClusters;
00127  Bool clustersPrepped;
00128  IndexList rootClusters; 
00129  FaceClusList clusters; 
00130  ActList clustersActive; 
00131 ColourList clusterColours; 
00132  NormalList faceNormals; 
00133 Int firstClusterID; 
00134 Int lastClusterID; 
00135  
00136 Bool IsFace(Int i)
00138 { return(i < faces.NumItems()); };
00139  FaceCluster &Cluster(Int i)
00141  { return(clusters[firstClusterID - i]); };
00142 
00143  Bool showMeta; 
00144 Bool showFaces; 
00145  Bool colourFaces; 
00146  
00147  FileName modelFile; 
00148 
00149 Flags32 flags; 
00150 GCLReal lastComplexity; 
00151 static Bool sAvgClusColours;
00152 };
00153 
00154 
00155 // --- Integration into GCL scenes ---------------------------------------------
00156 
00157 #include "gcl/SceneObjects.h"
00158 
00159  class scMRModel : public scPrimitive
00161 {
00162 public:
00163 
00164 scMRModel();
00165 
00166 Void Draw(Renderer &r, SLContext *context);
00167  StrConst Label() const
00168 { return "MR Model"; };
00169 
00170  Object *Clone() const
00171 { return new scMRModel(*this); };
00172 
00173 Void DecimateSelf(Decimator &dec);
00174 Void UpdateBounds(Point &min, Point &max,
00175 const Transform &t);
00176 
00177  MRModel model;
00178 
00179 static Void SetComplexity(GCLReal comp);
00180 static GCLReal GetComplexity();
00181 
00182 protected:
00183  static GCLReal complexity;
00184  GCLReal currentComplexity;
00185 };
00186 
00187  class MRModelsFinder : public scSceneAction
00189 {
00190 public:
00191 Void Start();
00192 Void Primitive(scPrimitive *sp);
00193 
00194  PtrArray<MRModel> models;
00195 
00196  Int NumModels() const
00197 { return(models.NumItems()); }
00198  MRModel *Model(Int i) const
00199 { return(models[i]); }
00200 };
00201 
00202 // MRB stuff
00203 
00204  enum MRB_Flags
00205 {
00206 MRB_HasVH = 0x0001,
00207 MRB_HasFH = 0x0002,
00208 MRB_Float = 0x0004,
00209 MRB_Ordered = 0x0008,
00210 MRB_End
00211 };
00212 
00213  struct MRB_Header
00214 {
00215  Int version;
00216  Flags32 flags;
00217 };
00218 
00219 #endif

Generated at Sat Aug 5 00:17:01 2000 for Graphics Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000

AltStyle によって変換されたページ (->オリジナル) /