Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
MultiresolutionObject.h
Go to the documentation of this file.
1//! @file MultiresolutionObject.h
2//! The CMultiresolutionObject class is a kind of object that can be used to modify the level of detail in real time.
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_MULTIRESOLUTIONOBJECT_H__D5DC4844_4F14_11D3_A382_E4DDA37A4B21__INCLUDED_)
7#define AFX_MULTIRESOLUTIONOBJECT_H__D5DC4844_4F14_11D3_A382_E4DDA37A4B21__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "3DObject.h"
14#include "SceneOptimizer.h"
15#include "MRCommon.h"
16#ifndef MOOTOOLS_NO_MR
17#include "MRBaseObject.h"
18#endif
19
20BEGIN_MOOTOOLS_NAMESPACE
21
22class C3DExtObject;
23class CSceneOptimizer;
24class CTrackContractions;
25
26//! @class CMultiresolutionObject
27//! @brief CMultiresolutionObject is the base class for multiresolution object.
28//! There is two kind of multiresolution object:
29//! * CMultiresolutionObject1 which is provided by CSceneOptimizer::GetScene.
30//! * CMultiresolutionObject2 which offers capability to stream a 3D mesh over the network.
31//!
32class DLLFUNCTION CMultiresolutionObject : public C3DObject
33{
34protected:
35 C3DSceneNode *refSrcNode;
36 C3DExtObject *refExtObject;
37 CSceneOptimizer *sceneOptimizer;
38
39 CUVWFaceList **uvChnFaces;
40 CUVWPointList **uvChnPoints;
41
42 unsigned int magicTarget;
43 bool unknownRatio;
44 double currentRatio;
45
46 virtual bool InternalCopy(C3DBaseObject *&dstObject, int flags = OBJECT_COPY_DEFAULT, C3DObjectCreator *objectCreator = NULL) const;
47 virtual void Init();
48
49public:
50 DECLARE_DYNAMIC_XOBJECT(CMultiresolutionObject);
51
54
55 CSceneOptimizer *GetOptimizer() { return sceneOptimizer; }
56 void DetachOptimizer();
57
58 C3DSceneNode *GetSrcNode() const { return refSrcNode; } //!< Return the node of the original scene (if any) to which the object refers. (note: if the original scene has been deleted the node pointer might be invalid, and should not be used.)
59 C3DExtObject *GetExtObject() const { return refExtObject; } //!< Return the optimized undynamic object (if any)
60
61 void SetExtObject(C3DExtObject *object);
62 void SetSrcNode(C3DSceneNode *node);
63
64 void SetOptimizer(CSceneOptimizer *sceneOptimizer) { this->sceneOptimizer = sceneOptimizer; }
65
66 ///////////////////////////////////////////////////////////////
67 // Information about geometry
68 virtual unsigned int GetMagicTarget() const = 0;
69 virtual void SetMagicTarget(unsigned int ratio) = 0;
70 virtual double GetCurrentRatio() const = 0;
71 virtual int GetRemovableFaceNbr() const = 0;
72 virtual int GetRemovablePtNbr() const = 0;
73 virtual void GetMinSize(int& minFaceSize, int& minPointSize) const = 0;
74 virtual void GetMaxSize(int& maxFaceSize, int& maxPointSize) const = 0;
75 virtual void GetCurrentSize(int& currentFaceSize, int& currentPointSize) const = 0;
76 virtual int GetTargetCount(double ratio, unsigned int mode, bool& canBeOptimizedButleftUnoptimized) const = 0; //!< return the approx. final number of point or faces giving a ratio accordingly to target mode (OPTIMIZE_TO_POINT | OPTIMIZE_TO_FACE).
77 virtual void SetMinSize(int minFaceSize, int minPointSize) = 0; //!< Set the minimum point/face size the objet have at lowest ratio
78 virtual void SetMaxSize(int maxFaceSize, int maxPointSize) = 0; //!< Set the maximum point/face size the objet have at highest ratio
79
80 virtual void LockRatio(bool lock) = 0; //!< the ratio is locked and cannot be changed
81 virtual bool IsRatioLocked() const = 0;
82
83 virtual bool IsMultiResFlagSet(MROBJECT_PROPERTIES flag) const = 0;
84 virtual void SetMultiResFlag(MROBJECT_PROPERTIES flag, bool set) = 0;
85
86 virtual void SetProgressive(bool set) = 0; //!< The object uses the provided progressive threshold (set MROBJECT_PROGRESSIVE_RATIO flag which is used only if the MRObject is used directly without the optimizer)
87 virtual void SetProgressiveThreshold(double threshold) = 0;
88 virtual double GetProgressiveThreshold() const = 0;
89
90 // virtual void ShowSelectedFaces(bool hideFrozenFaces);
91 virtual int SetObjectRatio(double ratio, int requiredNbr, unsigned int mode = OPTIMIZE_TO_FACE|OPTIMIZE_TO_RATIO) = 0;
92 virtual void FreezeObject(); //!< This remove the multiresolution data, freezes the object at its given level of details and clean it, removing some invalid faces. SetObjectRatio cannot be called anymore.
93
94 virtual double GetLastKnownRatio(bool& unknownRatio) const; //!< Return the last requested ratio used with OPTIMIZE_TO_RATIO (progressiveThreshold adjustement is not taken into account)
95};
96
97//! @class CMultiresolutionObject1
98//! @brief CMultiresolutionObject1 is a the multiresolution object class computed from C3DSceneOptimizer::GetScene
99//!
100class CTrackContractions;
102{
103 friend C3DExtObject;
104 friend CSceneOptimizer;
105
106private:
107 CTrackContractions *trackInfo;
108
109 double progressiveThreshold;
110 unsigned int multiresFlags;
111
112 int maxFaceSize; // Maximum face number
113 int minFaceSize; // Minimum face number (can be greater than 0, if some faces are "outstream")
114 int currentFaceSize; // Current face number
115
116 int maxPointSize; // Maximum point number for the object
117 int minPointSize; // Minimum point number (can be greater than 0, if some points are "outstream")
118 int currentPointSize; // Current point number for the object
119
120#ifdef _DEBUG
121 bool keepOrder;
122#endif
123
124 bool firstTime, lockSetObjectRatio;
125 bool increase;
126
127protected:
128 void Init();
129
130 virtual void Clean(); //!< Override C3DGeomObject::Clean
131
132 //virtual unsigned int *AddFace(unsigned int index) { return NULL; }
133 //virtual unsigned int *GetFaceIndexes(unsigned int index) { return NULL; };
134 //virtual void SetFaceMaterial(unsigned int index, unsigned short material) {};
135 //virtual MRMaterialID GetFaceMaterial(unsigned int index) const { return MATERIAL_UNDEFINED; }
136
137 //virtual float *AddPoint(unsigned int index) { return NULL; };
138 //virtual float *GetPoint(unsigned int index) { return NULL; };
139
140 //virtual unsigned int *AddUVFace(unsigned char channel, unsigned int index, bool unused) { return NULL; }
141 //virtual unsigned int *GetUVIndexes(unsigned char channel, unsigned int index) { return NULL; };
142 //virtual float *AddUVPoint(unsigned char channel, unsigned int index) { return NULL; };
143 //virtual float *GetUVPoint(unsigned char channel, unsigned int index) { return NULL; };
144
145public:
146 DECLARE_DYNAMIC_XOBJECT(CMultiresolutionObject1);
147
148 CMultiresolutionObject1(CSceneOptimizer *optimizer = NULL, C3DExtObject *extObject = NULL, C3DSceneNode *srcNode = NULL); //!< CMultiresolutionObject is usually created using CSceneOptimizer::GetScene or C3DExtObject::GetMultiresolutionObject
149 virtual ~CMultiresolutionObject1();
150
151 virtual unsigned int GetMagicTarget() const; //!< Called by MagicCruncher which set the ratio found to be optimal.
152 virtual void SetMagicTarget(unsigned int ratio); //!< Get the optimal MagicCruncher found giving the MagicCruncher parameters.
153 virtual double GetCurrentRatio() const; //!< Current optimization ratio
154 virtual int GetRemovableFaceNbr() const; //!< Number of removable faces
155 virtual int GetRemovablePtNbr() const; //!< Number of removable points
156 virtual void GetMinSize(int& minFaceSize, int& minPointSize) const; //!< Minimal number of points and faces
157 virtual void GetMaxSize(int& maxFaceSize, int& maxPointSize) const; //!< Maximal number of points and faces
158 virtual void GetCurrentSize(int& currentFaceSize, int& currentPointSize) const; //!< Current number of points and faces
159 virtual int GetTargetCount(double ratio, unsigned int mode, bool& canBeOptimizedButleftUnoptimized) const; //!< return the approx. final number of point or faces giving a ratio accordingly to target mode (OPTIMIZE_TO_POINT | OPTIMIZE_TO_FACE).
160 virtual void SetMinSize(int minFaceSize, int minPointSize); //!< Set the minimum point/face size the objet have at lowest ratio
161 virtual void SetMaxSize(int maxFaceSize, int maxPointSize); //!< Set the maximum point/face size the objet have at highest ratio
162
163 virtual void LockRatio(bool lock); //!< the ratio is locked and cannot be changed
164 virtual bool IsRatioLocked() const;
165
166 virtual bool IsMultiResFlagSet(MROBJECT_PROPERTIES flag) const; //!< Set one of the
167 virtual void SetMultiResFlag(MROBJECT_PROPERTIES flag, bool set);
168
169 virtual void SetProgressive(bool set); //!< The object uses the provided progressive threshold (set MROBJECT_PROGRESSIVE_RATIO flag which is used only if the MRObject is used directly without the optimizer)
170 virtual void SetProgressiveThreshold(double threshold);
171 virtual double GetProgressiveThreshold() const;
172
173 // virtual void ShowSelectedFaces(bool hideFrozenFaces);
174
175 bool PrepareGeometry(bool serializedTrackInfo);
176
177 int SetObjectRatio(double ratio, int requiredNbr, unsigned int mode = OPTIMIZE_TO_FACE|OPTIMIZE_TO_RATIO); //!< Modify the level of details of the object using a ratio and/or mode defined by MRRATIO_MODE
178 void FreezeObject(); //!< Freeze the object at a given ratio and clean the object. Removes any multiresolution data and further ability to change the LOD. override C3DGeomObject::FreezeObject.
179
180 // Specifics
181 void SetTrackInfo(CTrackContractions *info);
182 const CTrackContractions *GetTrackInfo() const { return trackInfo; }
183};
184
185#ifndef MOOTOOLS_NO_MR
186class CMRManager;
188//! @class CMultiresolutionObject2
189//! CMultiresolutionObject2 provides a streamable 3D mesh using data provided by C3DExtObject
190//!
191class DLLFUNCTION CMultiresolutionObject2 : public CMultiresolutionObject, public CMRBaseObject
192{
193 friend C3DExtObject;
194
195protected:
196 virtual void FreezeObject();
197 virtual bool PrepareGeometry();
198 virtual bool AdjustGeometry();
199 virtual void PrepareChanges(CMRContractions::ParsingInfo& parsing, unsigned int targetPointSize, bool rebuild);
200 virtual void ReleaseChanges(CMRContractions::ParsingInfo& parsing);
201
202 virtual void MaterialChanged(MRMaterialID matid);
203
204 virtual unsigned int *AddFace(unsigned int index);
205 virtual unsigned int *GetFaceIndexes(unsigned int index);
206
207 virtual void SetFaceMaterial(unsigned int index, unsigned short material);
208 virtual MRMaterialID GetFaceMaterial(unsigned int index) const;
209
210 virtual float *AddPoint(unsigned int index);
211 virtual float *GetPoint(unsigned int index);
212
213 virtual unsigned int *AddUVFace(unsigned char channel, unsigned int index, bool unused);
214 virtual unsigned int *GetUVIndexes(unsigned char channel, unsigned int index);
215 virtual float *AddUVPoint(unsigned char channel, unsigned int index);
216 virtual float *GetUVPoint(unsigned char channel, unsigned int index);
217
218public:
219 DECLARE_DYNAMIC_XOBJECT(CMultiresolutionObject2);
220
222 virtual ~CMultiresolutionObject2();
223
224 virtual double GetMagicRatio() const;
225 virtual unsigned int GetMagicTarget() const;
226 virtual void SetMagicTarget(unsigned int ratio);
227 virtual double GetCurrentRatio() const;
228 virtual double GetPreviousRatio() const;
229 virtual int GetRemovableFaceNbr() const;
230 virtual int GetRemovablePtNbr() const;
231 virtual void GetMinSize(int& minFaceSize, int& minPointSize) const;
232 virtual void GetMaxSize(int& maxFaceSize, int& maxPointSize) const;
233 virtual void GetCurrentSize(int& currentFaceSize, int& currentPointSize) const;
234 virtual int GetTargetCount(double ratio, unsigned int mode, bool& canBeOptimizedButleftUnoptimized) const; // return the approx. final number of point or faces giving a ratio accordingly to target mode (OPTIMIZE_TO_POINT | OPTIMIZE_TO_FACE).
235 virtual void SetMinSize(int minFaceSize, int minPointSize); // Set the minimum point/face size the objet have at lowest ratio
236 virtual void SetMaxSize(int maxFaceSize, int maxPointSize); // Set the maximum point/face size the objet have at highest ratio
237
238 virtual void LockRatio(bool lock); // the ratio is locked and cannot be changed
239 virtual bool IsRatioLocked() const;
240
241 virtual bool IsMultiResFlagSet(MROBJECT_PROPERTIES flag) const;
242 virtual void SetMultiResFlag(MROBJECT_PROPERTIES flag, bool set);
243
244 virtual void SetProgressive(bool set); // The object uses the provided progressive threshold (set MROBJECT_PROGRESSIVE_RATIO flag which is used only if the MRObject is used directly without the optimizer)
245 virtual void SetProgressiveThreshold(double threshold);
246 virtual double GetProgressiveThreshold() const;
247
248 bool NeedUpdate() const;
249 bool Update(C3DScene *scene, unsigned int updateMode);
250
251 int SetObjectRatio(double ratio, int requiredNbr, unsigned int mode = OPTIMIZE_TO_FACE|OPTIMIZE_TO_RATIO);
252
253 virtual void Clean();
254};
255#endif
256
257END_MOOTOOLS_NAMESPACE
258
259#endif // !defined(AFX_MULTIRESOLUTIONOBJECT_H__D5DC4844_4F14_11D3_A382_E4DDA37A4B21__INCLUDED_)
The file contains C3DObject class definition which handles N-Gons polygonal object.
This is the base class for any kind of object.
Definition 3DBaseObject.h:106
This class handles static optimization of an object.
Definition 3DExtObject.h:66
virtual bool Update(C3DScene *scene, unsigned int updateMode)
Information that have been invalidated are recomputed when calling this method.IsInstanciated.
virtual void Clean()
Clean the object by faces and points which flag have been set to invalid. Update channels accordingly...
This class can be provided in C3DScene::Copy operations and allows to modify the created kind of clas...
Definition 3DScene.h:47
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
A node matches one element that is part of the C3DScene graph. It references a C3DBaseObject and has ...
Definition 3DSceneNode.h:64
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CMultiresolutionObject1 is a the multiresolution object class computed from C3DSceneOptimizer::GetSce...
Definition MultiresolutionObject.h:102
virtual void GetCurrentSize(int &currentFaceSize, int &currentPointSize) const
Current number of points and faces.
virtual void SetMagicTarget(unsigned int ratio)
Get the optimal MagicCruncher found giving the MagicCruncher parameters.
virtual bool IsMultiResFlagSet(MROBJECT_PROPERTIES flag) const
Set one of the.
virtual int GetRemovableFaceNbr() const
Number of removable faces.
virtual void LockRatio(bool lock)
the ratio is locked and cannot be changed
virtual void GetMaxSize(int &maxFaceSize, int &maxPointSize) const
Maximal number of points and faces.
virtual void SetMaxSize(int maxFaceSize, int maxPointSize)
Set the maximum point/face size the objet have at highest ratio.
virtual void SetMinSize(int minFaceSize, int minPointSize)
Set the minimum point/face size the objet have at lowest ratio.
int SetObjectRatio(double ratio, int requiredNbr, unsigned int mode=OPTIMIZE_TO_FACE|OPTIMIZE_TO_RATIO)
Modify the level of details of the object using a ratio and/or mode defined by MRRATIO_MODE.
virtual unsigned int GetMagicTarget() const
Called by MagicCruncher which set the ratio found to be optimal.
CMultiresolutionObject1(CSceneOptimizer *optimizer=NULL, C3DExtObject *extObject=NULL, C3DSceneNode *srcNode=NULL)
CMultiresolutionObject is usually created using CSceneOptimizer::GetScene or C3DExtObject::GetMultire...
virtual int GetRemovablePtNbr() const
Number of removable points.
virtual double GetCurrentRatio() const
Current optimization ratio.
virtual void SetProgressive(bool set)
The object uses the provided progressive threshold (set MROBJECT_PROGRESSIVE_RATIO flag which is used...
virtual int GetTargetCount(double ratio, unsigned int mode, bool &canBeOptimizedButleftUnoptimized) const
return the approx. final number of point or faces giving a ratio accordingly to target mode (OPTIMIZE...
virtual void GetMinSize(int &minFaceSize, int &minPointSize) const
Minimal number of points and faces.
void FreezeObject()
Freeze the object at a given ratio and clean the object. Removes any multiresolution data and further...
CMultiresolutionObject is the base class for multiresolution object. There is two kind of multiresolu...
Definition MultiresolutionObject.h:33
virtual void FreezeObject()
This remove the multiresolution data, freezes the object at its given level of details and clean it,...
virtual void SetMaxSize(int maxFaceSize, int maxPointSize)=0
Set the maximum point/face size the objet have at highest ratio.
virtual void LockRatio(bool lock)=0
the ratio is locked and cannot be changed
virtual int GetTargetCount(double ratio, unsigned int mode, bool &canBeOptimizedButleftUnoptimized) const =0
return the approx. final number of point or faces giving a ratio accordingly to target mode (OPTIMIZE...
C3DSceneNode * GetSrcNode() const
Return the node of the original scene (if any) to which the object refers. (note: if the original sce...
Definition MultiresolutionObject.h:58
virtual void SetProgressive(bool set)=0
The object uses the provided progressive threshold (set MROBJECT_PROGRESSIVE_RATIO flag which is used...
virtual double GetLastKnownRatio(bool &unknownRatio) const
Return the last requested ratio used with OPTIMIZE_TO_RATIO (progressiveThreshold adjustement is not ...
C3DExtObject * GetExtObject() const
Return the optimized undynamic object (if any)
Definition MultiresolutionObject.h:59
virtual void SetMinSize(int minFaceSize, int minPointSize)=0
Set the minimum point/face size the objet have at lowest ratio.
CSceneOptimizer is the main entry to optimize a scene. There are various optimization modes and which...
Definition SceneOptimizer.h:147
CUVWFaceList is a CFaceList that contains CUVWFace. It usually belongs to a CUVWChannel.
Definition UVWFaceList.h:21
CUVWPointList is an array of CUVWPoint. It usually belongs to a CUVWChannel.
Definition UVWPointList.h:46