Newton Dynamics  4.00
dPolygonSoupBuilder.h
1 /* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /****************************************************************************
23 *
24 * Visual C++ 6.0 created by: Julio Jerez
25 *
26 ****************************************************************************/
27 #ifndef __D_POLYGONSOUP_BUILDER_H__
28 #define __D_POLYGONSOUP_BUILDER_H__
29 
30 #include "dCoreStdafx.h"
31 #include "dTypes.h"
32 #include "dPlane.h"
33 #include "dArray.h"
34 #include "dVector.h"
35 #include "dMatrix.h"
36 
38 {
39  public:
40  dPlane m_normal;
41  dInt32 m_count;
42  dInt32 *m_index;
43  dInt64 m_edgeMap[256];
44 };
45 
47 {
48  class dgFaceMap;
49  class dgFaceInfo;
50  class dgFaceBucket;
52  public:
53 
54  D_CORE_API dPolygonSoupBuilder ();
55  D_CORE_API dPolygonSoupBuilder (const dPolygonSoupBuilder& sopurce);
56  D_CORE_API ~dPolygonSoupBuilder ();
57 
58  D_CORE_API void Begin();
59  D_CORE_API void End(bool optimize);
60  D_CORE_API void AddFace(const dFloat32* const vertex, dInt32 strideInBytes, dInt32 vertexCount, const dInt32 faceId);
61  D_CORE_API void AddFaceIndirect(const dFloat32* const vertex, dInt32 strideInBytes, dInt32 faceId, const dInt32* const indexArray, dInt32 indexCount);
62 
63  D_CORE_API void SavePLY(const char* const fileName) const;
64 
65  private:
66  void Optimize(dInt32 faceId, const dgFaceBucket& faceBucket, const dPolygonSoupBuilder& source);
67 
68  void Finalize();
69  void OptimizeByIndividualFaces();
70  void FinalizeAndOptimize(dInt32 id);
71  dInt32 FilterFace (dInt32 count, dInt32* const indexArray);
72  dInt32 AddConvexFace (dInt32 count, dInt32* const indexArray, dInt32* const facesArray);
73  void PackArray();
74 
75  public:
76  class dgVertexArray: public dArray<dBigVector>
77  {
78  public:
81  {
82  }
83 
84  dgVertexArray(dInt32 count)
85  :dArray<dBigVector>(count)
86  {
87  }
88 
89  };
90 
91  class dgIndexArray: public dArray<dInt32>
92  {
93  public:
94  dgIndexArray()
96  {
97  }
98 
99  dgIndexArray(dInt32 count)
100  :dArray<dInt32>(count)
101  {
102  }
103 
104  };
105 
106  dgIndexArray m_faceVertexCount;
107  dgIndexArray m_vertexIndex;
108  dgIndexArray m_normalIndex;
109  dgVertexArray m_vertexPoints;
110  dgVertexArray m_normalPoints;
111  dInt32 m_run;
112 };
113 
114 #endif
115 
dPolygonSoupBuilder
Definition: dPolygonSoupBuilder.h:47
dPolygonSoupBuilder::dgFaceMap
Definition: dPolygonSoupBuilder.cpp:58
AdjacentdFace
Definition: dPolygonSoupBuilder.h:38
dArray
Definition: dArray.h:36
dClassAlloc
Base class for providing memory allocation for all other engine classes.
Definition: dClassAlloc.h:29
dPolygonSoupBuilder::dgIndexArray
Definition: dPolygonSoupBuilder.h:92
dPolygonSoupBuilder::dgVertexArray
Definition: dPolygonSoupBuilder.h:77
dPolygonSoupBuilder::dgFaceInfo
Definition: dPolygonSoupBuilder.cpp:42
dPolygonSoupBuilder::dgPolySoupFilterAllocator
Definition: dPolygonSoupBuilder.cpp:90
dPlane
Definition: dPlane.h:35
dPolygonSoupBuilder::dgFaceBucket
Definition: dPolygonSoupBuilder.cpp:49