7#if !defined(AFX_3DFACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_)
8#define AFX_3DFACELIST_H__CA6BC2A4_FAC2_11D1_A0DE_000000000000__INCLUDED_
22BEGIN_MOOTOOLS_NAMESPACE
35 frontID = backID = MATERIAL_UNDEFINED;
46 if (frontID == mat.frontID && backID == mat.backID)
54 if (frontID != mat.frontID || backID != mat.backID)
60 inline bool IsUndefined()
const
62 if (frontID == MATERIAL_UNDEFINED && backID == MATERIAL_UNDEFINED)
68 inline bool IsFrontDefined()
const
70 return (frontID != MATERIAL_UNDEFINED);
73 inline bool IsBackDefined()
const
75 return (backID != MATERIAL_UNDEFINED);
78 inline bool IsSingleMaterial()
const
80 return (frontID == backID) || (!IsBackDefined());
98 static inline unsigned int HashValue(
const FBMaterialID& hash)
112 mutable bool hasBackMaterial;
121 unsigned int ReplaceFrontMaterial(MaterialID matid, MaterialID
newmatid);
122 unsigned int ReplaceBackMaterial(MaterialID matid, MaterialID
newmatid);
125 unsigned int GetFaceCount(MaterialID
frontid, MaterialID
backid)
const;
132 DECLARE_SERIAL_XOBJECT(C3DFacePropertyMethods);
134 SIZET GetSizeof()
const;
135 ElementType GetType()
const;
136 void ConstructElement(
void*
pNewData);
139 void Dump(
const void* data)
const
141 XTRACE(
_T(
"Flags: %d - MaterialID : %d\n"), ((C3DFacePropertyData*)data)->flags, ((C3DFacePropertyData *)data)->materialid);
146inline SIZET C3DFacePropertyMethods::GetSizeof()
const
148 return sizeof(C3DFacePropertyData);
151inline ElementType C3DFacePropertyMethods::GetType()
const
153 return MAKE_CUSTOM_ID(
'3',
'D',
'F',
'A');
156inline void C3DFacePropertyMethods::ConstructElement(
void*
pNewData)
158 xConstruct(C3DFacePropertyData,
pNewData);
161typedef enum FaceGridFlags
XEnumType(
unsigned int)
163 FACEGRID_NONE = 0x00,
166 FACEGRID_CACHE_FOR = 0x0FF,
167 FACEGRID_CACHE_FOR_RAYCAST = 0,
168 FACEGRID_CACHE_FOR_GETCLOSESTFACE,
171 FACEGRID_MULTITHREADED = 0x100,
172 FACEGRID_REMOVE_DUPLICATED_FACES = 0x200,
173 FACEGRID_FILL_FULL_BBOX = 0x400,
174 FACEGRID_IGNORE_NODE_TRANSFORM = 0x800,
185 RAYCAST_DEFAULT = 0x00,
206 unsigned int facesize;
215 typedef struct ThreadInfo
223 unsigned int ThreadCount()
const;
224 bool ThreadIsInitialized()
const;
296 void DeleteFaceGridMap();
316 bool HasBackFaceMaterials()
const;
318 void SetBackFaceMaterial(
unsigned int index, MaterialID
id);
319 void SetFaceMaterial(
unsigned int index, MaterialID
id);
320 MaterialID GetFaceMaterial(
unsigned int index)
const;
321 MaterialID GetBackFaceMaterial(
unsigned int index,
bool getFrontIfNeeded =
false)
const;
328 virtual bool UpdateList();
330 virtual void RemoveAll();
343 void CreateFBMaterialsHashMap();
348inline void C3DFaceList::SetFaceMaterial(
unsigned int index, MaterialID
id)
350 C3DFacePropertyData *prop =
static_cast<C3DFacePropertyData *
>(
GetMainDataChunk(index));
351 prop->materialid = id;
354inline MaterialID C3DFaceList::GetFaceMaterial(
unsigned int index)
const
356 C3DFacePropertyData *prop =
static_cast<C3DFacePropertyData *
>(
GetMainDataChunk(index));
358 return prop->materialid;
360 return MATERIAL_UNDEFINED;
369 return GetFaceMaterial(index);
382END_MOOTOOLS_NAMESPACE
C3DBBoxT template class for handling bounding box.
C3DFace class definition for a 3D face, which is a list of indexes that refers to a 3D point list.
RayCastFlags
Definition 3DFaceList.h:184
@ RAYCAST_CHECK_BOTHDIR
Test ray cast in both direction.
Definition 3DFaceList.h:186
@ RAYCAST_TUV_COORDINATE
hitPoint(x, y, z) contains the (t, u, v) coordinates of the found intersection. We can compute the hi...
Definition 3DFaceList.h:187
@ RAYCAST_OPPOSITE_DIRECTION
The provided direction and the normal of the face must have the opposite direction.
Definition 3DFaceList.h:189
@ RAYCAST_SAME_DIRECTION
The provided direction and the normal of the face must have the same direction.
Definition 3DFaceList.h:188
C3DPointList class definition for handling a list of C3DPoint.
CDependentChannels class definition which handles a CChannel array.
FACE_PROPERTIES
Face flags used by any classes that inherit from CFace (C3DFace, CUVWFace...)
Definition Face.h:39
@ FACE_NONE
These flags can be used whatever the face class.
Definition Face.h:40
@ FACE_IS_INVALID
This flag is used when a face a less than 3 indexes or when it is tagged invalid. Geometric faces tha...
Definition Face.h:43
@ FACE_IS_UNUSED
This flag is to be used in a dependent channel, meaning that the face should be ignored and does not ...
Definition Face.h:44
CFaceList class is the base class for different kind of face list.
MapType
This enum allows to know the kind of texture map.
Definition MaterialMap.h:26
C3DFaceGridMap is initialized by C3DFaceList::GetFaceGridMap.
Definition 3DFaceList.h:200
unsigned int GetCellNbr() const
Return the total number of cells that have been defined automatically depending on the input face lis...
C3DBBox GetBBox() const
Return the bounding box of the face list using for creating the grid map.
unsigned int GetFlags() const
return flags used for creating the C3DPointGridMap
ThreadInfo * BeginThread(bool forceSingleThread=false)
Parallel support for GetClosestFace, GetRayCastFace, GetRayCastFace2.
C3DFaceGridMap(CGeomInfo *info, unsigned int faceGridFlags)
Init grid. info contains points and faces list. voxelCountMultiplicationFactor multiply the default n...
const C4x4Matrix & GetTransform() const
Return the matrix used to transform the point of the face grid map.
A 3D face is a list of indexes of C3DPointList object point list.
Definition 3DFace.h:43
C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored i...
Definition 3DFaceList.h:249
bool ReplaceMaterial(MaterialID matid, MaterialID newmatid)
Replace face matid by newmatid and update the material hash map if possible.
unsigned int GetMaterialsHashMap(const CGeomInfo *info, CMaterialHashMap &hashMaterialMap, bool includeBackFace=true, bool reset=true)
Get (MaterialID, facecount) hash. If includeBackFace, the back face material are added to the hash....
virtual CFace * CreateFace() const
<
Definition 3DFaceList.h:260
C3DFaceGridMap * GetFaceGridMap(CGeomInfo *info, unsigned int faceGridFlags=FACEGRID_NONE)
Return or (re-)compute a map that contains each faces sampled in an integer grid, with the given flag...
bool GetBoundingBox(const CGeomInfo *info, C3DPoint &min, C3DPoint &max, unsigned int faceFlags=FACE_NONE, bool set=true, C4x4Matrix *matrix=NULL)
points are transformed by matrix if any provided
C3DFaceList(C3DFaceList *srcFaces=NULL)
Create a new face list. When srcFaces is provided, the data structure (datachunks) is inherited but t...
const CFBMaterialHashMap * GetFBMaterialsHashMap(const CGeomInfo *info)
Return a ((front MaterialID, back MaterialID), facecount) material id hash.
int * Sort(unsigned int sortmode, unsigned int &arraySize, bool &orderChanged)
sortmode contains FACE_SORT_MODE flags. arraySize is the size of the returned index array....
double GetDistanceToFacePlane(CGeomInfo *info, unsigned int index, const C3DPoint &pt, bool absoluteValue=true)
Get the distance from face index to the face plane. The face can be N-Gon but in this case,...
bool Sort(const CGeomInfo *info, unsigned int mode)
Sort the face by changing their order; depenging on the front or back face material (SORT_FRONT_AND_B...
void DeleteFBMaterialsHashMap()
Free the hash material when no longer needed.
unsigned int GetClosestFace(CGeomInfo *info, C3DFaceGridMap *faceGridMap, const C3DPointD &pt, double &distance, double maxdistance=HUGE_VAL)
Return the closest face index to the point pt. If a face is found distance contains the distance of p...
double GetDistanceToFace(CGeomInfo *info, unsigned int index, const C3DPoint &pt)
Get the distance from face index to the given pt. Calculate the projection on the face or on the clos...
FBMaterialID GetFBFaceMaterial(unsigned int index, bool getFrontIfNeeded=false) const
getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true,...
Definition 3DFaceList.h:377
unsigned int GetRayCastFace(CGeomInfo *info, C3DFaceGridMap *faceGridMap, const C3DPointD &eye, const C3DVectorD &dir, C3DPointD &hitPoint, unsigned int rayCastFlags=RAYCAST_DEFAULT, bool *oppositeDir=NULL)
Return the ray cast face index to the point pt, or INVALID_FACE_INDEX if none.
virtual ~C3DFaceList()
Use CFace::Delete should be used because there can be several references to the face list....
unsigned int GetFaceGridMapFlags() const
Return an already computed face grid or null.
static C3DFaceList * Create(C3DFaceList *srcFaces=NULL)
Allocates and creates an empty set of 3d faces. Use C3DFaceList::Delete to delete it.
bool RemoveBackFaceMaterials()
Return true if object had back face materials.
bool HasDifferentFrontAndBackUVChannel(const CGeomInfo *info, MapType type) const
Return true if the object has different front and back UV channels (looking materials front & back UV...
bool CompareBackAndFrontMaterials(bool deleteBackIfSame, bool checkFrontBackMaterialChannel=false, CGeomInfo *info=NULL)
return true if back & front materials are the sames, or if no back materials. deleteBackIfSame = true...
MaterialID GetBackFaceMaterial(unsigned int index, bool getFrontIfNeeded=false) const
getFrontIfNeeded = false return possibly MATERIAL_UNDEFINED. If getFrontIfNeeded = true,...
Definition 3DFaceList.h:363
bool GetBoundingBox(const CGeomInfo *info, C3DBBox &bbox, unsigned int faceFlags=FACE_NONE, bool set=true, C4x4Matrix *matrix=NULL)
points are transformed by matrix if any provided
C3DFaceGridMap * GetFaceGridMap(bool addReferenceCount=true)
Return an already computed map that contains each faces sampled in an integer grid....
C3DPointGridMap is a compact class for retrieving quickly points which are in the same voxel of a pro...
Definition 3DPointList.h:77
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Class for storing the back face material using FACE_BACK_MATERIAL id in C3DFaceList::AddDataChunk.
Definition 3DExtraData.h:78
CBitArray class for handling array of bits.
Definition BitArray.h:18
This class gets an object material hash. It returns front and back material pair. @Note if we have a ...
Definition 3DFaceList.h:108
A CFace contains the information related to a given face in a CFaceList.
Definition Face.h:97
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
CFacePropertyData * GetMainDataChunk(unsigned int index) const
return the main data chunk for index. The main data chunk is a chunk like another one,...
Definition FaceList.h:748
const CDataChunk & GetDataChunks() const
Return the class that handles the data chunks.
Definition FaceList.h:731
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
CHashMap is a template class that associates key to a single value through an hash table.
Definition HashMap.h:42
Definition InstanciatedObject.h:16
Definition XThreadSync.h:20
This class handles two MaterialID that simplifies operation on faces which have front and back materi...
Definition 3DFaceList.h:28