22 #ifndef __dgMeshEffect_H__ 23 #define __dgMeshEffect_H__ 25 #include "hpl1/engine/libraries/newton/core/dg.h" 31 class dgMeshTreeCSGEdgePool;
33 #define DG_MESH_EFFECT_INITIAL_VERTEX_SIZE 8 34 #define DG_MESH_EFFECT_BOLLEAN_STACK 512 35 #define DG_MESH_EFFECT_POINT_SPLITED 512 36 #define DG_MESH_EFFECT_POLYGON_SPLITED 256 37 #define DG_MESH_EFFECT_FLAT_CUT_BORDER_EDGE 0x01 38 #define DG_VERTEXLIST_INDEXLIST_TOL (dgFloat64(0.0f)) 40 #define DG_MESH_EFFECT_PRECISION_BITS 30 41 #define DG_MESH_EFFECT_PRECISION_SCALE dgFloat64(1 << DG_MESH_EFFECT_PRECISION_BITS) 42 #define DG_MESH_EFFECT_PRECISION_SCALE_INV (dgFloat64(1.0f) / DG_MESH_EFFECT_PRECISION_SCALE) 44 #define DG_MESG_EFFECT_BOOLEAN_INIT() \ 45 dgMeshEffect *result = NULL; \ 46 dgMeshEffect *sourceCoplanar = NULL; \ 47 dgMeshEffect *leftMeshSource = NULL; \ 48 dgMeshEffect *rightMeshSource = NULL; \ 49 dgMeshEffect *clipperCoplanar = NULL; \ 50 dgMeshEffect *leftMeshClipper = NULL; \ 51 dgMeshEffect *rightMeshClipper = NULL; 53 #define DG_MESG_EFFECT_BOOLEAN_FINISH() \ 54 if (sourceCoplanar) { \ 55 sourceCoplanar->Release(); \ 57 if (clipperCoplanar) { \ 58 clipperCoplanar->Release(); \ 60 if (leftMeshClipper) { \ 61 leftMeshClipper->Release(); \ 63 if (rightMeshClipper) { \ 64 rightMeshClipper->Release(); \ 66 if (leftMeshSource) { \ 67 leftMeshSource->Release(); \ 69 if (rightMeshSource) { \ 70 rightMeshSource->Release(); \ 73 result->ConvertToPolygons(); \ 74 dgStack<dgInt32> map(result->m_pointCount + 1); \ 75 result->RemoveUnusedVertices(&map[0]); \ 107 dgInt32 m_materialCount;
108 dgInt32 m_indexCount;
109 dgInt32 m_materials[256];
110 dgInt32 m_materialsIndexCount[256];
111 dgInt32 *m_indexList;
120 dgMeshEffect(
dgMemoryAllocator *
const allocator,
const dgFloat64 *
const vertexCloud, dgInt32 count, dgInt32 strideInByte, dgFloat64 distTol);
129 void ApplyTransform(
const dgMatrix &matrix);
133 void CalculateNormals(dgFloat64 angleInRadians);
134 void SphericalMapping(dgInt32 material);
135 void BoxMapping(dgInt32 front, dgInt32 side, dgInt32 top);
136 void UniformBoxMapping(dgInt32 material,
const dgMatrix &textruMatrix);
137 void CylindricalMapping(dgInt32 cylinderMaterial, dgInt32 capMaterial);
139 dgEdge *InsertEdgeVertex(
dgEdge *
const edge, dgFloat64 param);
156 void ConvertToPolygons();
158 void RemoveUnusedVertices(dgInt32 *
const vertexRemapTable);
161 void AddPolygon(dgInt32 count,
const dgFloat32 *
const vertexList, dgInt32 stride, dgInt32 material);
162 #ifndef __USE_DOUBLE_PRECISION__ 163 void AddPolygon(dgInt32 count,
const dgFloat64 *
const vertexList, dgInt32 stride, dgInt32 material);
165 void EndPolygon(dgFloat64 tol);
167 void PackVertexArrays();
169 void BuildFromVertexListIndexList(dgInt32 faceCount,
const dgInt32 *
const faceIndexCount,
const dgInt32 *
const faceMaterialIndex,
170 const dgFloat32 *
const vertex, dgInt32 vertexStrideInBytes,
const dgInt32 *
const vertexIndex,
171 const dgFloat32 *
const normal, dgInt32 normalStrideInBytes,
const dgInt32 *
const normalIndex,
172 const dgFloat32 *
const uv0, dgInt32 uv0StrideInBytes,
const dgInt32 *
const uv0Index,
173 const dgFloat32 *
const uv1, dgInt32 uv1StrideInBytes,
const dgInt32 *
const uv1Index);
175 dgInt32 GetVertexCount()
const;
176 dgInt32 GetVertexStrideInByte()
const;
177 dgFloat64 *GetVertexPool()
const;
179 dgInt32 GetPropertiesCount()
const;
180 dgInt32 GetPropertiesStrideInByte()
const;
181 dgFloat64 *GetAttributePool()
const;
182 dgFloat64 *GetNormalPool()
const;
183 dgFloat64 *GetUV0Pool()
const;
184 dgFloat64 *GetUV1Pool()
const;
188 dgInt32 GetTotalFaceCount()
const;
189 dgInt32 GetTotalIndexCount()
const;
190 void GetFaces(dgInt32 *
const faceCount, dgInt32 *
const materials,
void **
const faceNodeList)
const;
192 void RepairTJoints(
bool triangulate);
193 bool SeparateDuplicateLoops(
dgEdge *
const edge);
194 bool HasOpenEdges()
const;
195 dgFloat64 CalculateVolume()
const;
197 void GetVertexStreams(dgInt32 vetexStrideInByte, dgFloat32 *
const vertex,
198 dgInt32 normalStrideInByte, dgFloat32 *
const normal,
199 dgInt32 uvStrideInByte0, dgFloat32 *
const uv0,
200 dgInt32 uvStrideInByte1, dgFloat32 *
const uv1)
const;
202 void GetIndirectVertexStreams(dgInt32 vetexStrideInByte, dgFloat64 *
const vertex, dgInt32 *
const vertexIndices, dgInt32 *
const vertexCount,
203 dgInt32 normalStrideInByte, dgFloat64 *
const normal, dgInt32 *
const normalIndices, dgInt32 *
const normalCount,
204 dgInt32 uvStrideInByte0, dgFloat64 *
const uv0, dgInt32 *
const uvIndices0, dgInt32 *
const uvCount0,
205 dgInt32 uvStrideInByte1, dgFloat64 *
const uv1, dgInt32 *
const uvIndices1, dgInt32 *
const uvCount1);
208 void MaterialGeomteryEnd(
dgIndexArray *
const handle)
const;
209 dgInt32 GetFirstMaterial(
dgIndexArray *
const handle)
const;
210 dgInt32 GetNextMaterial(
dgIndexArray *
const handle, dgInt32 materialHandle)
const;
211 dgInt32 GetMaterialID(
dgIndexArray *
const handle, dgInt32 materialHandle)
const;
212 dgInt32 GetMaterialIndexCount(
dgIndexArray *
const handle, dgInt32 materialHandle)
const;
213 void GetMaterialGetIndexStream(
dgIndexArray *
const handle, dgInt32 materialHandle, dgInt32 *
const index)
const;
214 void GetMaterialGetIndexStreamShort(
dgIndexArray *
const handle, dgInt32 materialHandle, dgInt16 *
const index)
const;
216 dgCollision *CreateCollisionTree(dgInt32 shapeID)
const;
217 dgCollision *CreateConvexCollision(dgFloat64 tolerance, dgInt32 shapeID,
const dgMatrix &matrix = dgGetIdentityMatrix())
const;
219 dgMeshEffect *CreateConvexApproximation(dgFloat32 maxConcavity, dgInt32 maxCount = 32)
const;
220 dgMeshEffect *CreateDelanayTretrahedralization(dgInt32 interionMaterial,
dgMatrix &matrix)
const;
221 dgMeshEffect *CreateVoronoiPartition(dgInt32 pointsCount, dgInt32 pointStrideInBytes,
const dgFloat32 *
const pointCloud, dgInt32 interionMaterial,
dgMatrix &matrix)
const;
226 void TransformMesh(
const dgMatrix &matrix);
228 void *GetFirstVertex()
const;
229 void *GetNextVertex(
void *
const vertex)
const;
230 dgInt32 GetVertexIndex(
void *
const vertex)
const;
232 void *GetFirstPoint()
const;
233 void *GetNextPoint(
void *
const point)
const;
234 dgInt32 GetPointIndex(
const void *
const point)
const;
235 dgInt32 GetVertexIndexFromPoint(
void *
const point)
const;
237 void *GetFirstEdge()
const;
238 void *GetNextEdge(
void *
const edge)
const;
239 void GetEdgeIndex(
const void *
const edge, dgInt32 &v0, dgInt32 &v1)
const;
242 void *GetFirstFace()
const;
243 void *GetNextFace(
void *
const face)
const;
244 dgInt32 IsFaceOpen(
const void *
const face)
const;
245 dgInt32 GetFaceMaterial(
const void *
const face)
const;
246 dgInt32 GetFaceIndexCount(
const void *
const face)
const;
247 void GetFaceIndex(
const void *
const face,
int *
const indices)
const;
248 void GetFaceAttributeIndex(
const void *
const face,
int *
const indices)
const;
253 void Init(
bool preAllocaBuffers);
255 dgInt32 CalculateMaxAttributes()
const;
256 dgFloat64 QuantizeCordinade(dgFloat64 val)
const;
261 void AddPoint(
const dgFloat64 *vertexList, dgInt32 material);
271 void FilterCoplanarFaces(
const dgMeshEffect *
const otherCap, dgFloat32 sign);
280 bool CheckSingleMesh()
const;
282 dgInt32 m_pointCount;
283 dgInt32 m_maxPointCount;
285 dgInt32 m_atribCount;
286 dgInt32 m_maxAtribCount;
297 inline dgInt32 dgMeshEffect::GetVertexCount()
const {
301 inline dgInt32 dgMeshEffect::GetPropertiesCount()
const {
305 inline dgInt32 dgMeshEffect::GetMaterialID(
dgIndexArray *
const handle, dgInt32 materialHandle)
const {
306 return handle->m_materials[materialHandle];
309 inline dgInt32 dgMeshEffect::GetMaterialIndexCount(
dgIndexArray *
const handle, dgInt32 materialHandle)
const {
310 return handle->m_materialsIndexCount[materialHandle];
314 return m_attib[index];
317 inline dgInt32 dgMeshEffect::GetPropertiesStrideInByte()
const {
321 inline dgFloat64 *dgMeshEffect::GetAttributePool()
const {
322 return &m_attib->m_vertex.m_x;
325 inline dgFloat64 *dgMeshEffect::GetNormalPool()
const {
326 return &m_attib->m_normal_x;
329 inline dgFloat64 *dgMeshEffect::GetUV0Pool()
const {
330 return &m_attib->m_u0;
333 inline dgFloat64 *dgMeshEffect::GetUV1Pool()
const {
334 return &m_attib->m_u1;
338 return (meshA->CheckIntersection(solidTreeB, scale) || meshB->CheckIntersection(solidTreeA, scale));
341 inline dgInt32 dgMeshEffect::GetVertexStrideInByte()
const {
345 inline dgFloat64 *dgMeshEffect::GetVertexPool()
const {
346 return &m_points[0].m_x;
349 inline dgMeshEffect *dgMeshEffect::GetFirstLayer()
const {
350 return GetNextLayer(IncLRU());
357 return GetNextLayer(layerSegment->IncLRU() - 1);
360 inline dgFloat64 dgMeshEffect::QuantizeCordinade(dgFloat64 x)
const {
362 dgFloat64 mantissa = frexp(x, &exp);
363 mantissa = DG_MESH_EFFECT_PRECISION_SCALE_INV * floor(mantissa * DG_MESH_EFFECT_PRECISION_SCALE);
365 dgFloat64 x1 = ldexp(mantissa, exp);
Definition: dgConvexHull3d.h:52
Definition: dgRefCounter.h:25
Definition: dgPolyhedra.h:61
Definition: dgMeshEffect.h:78
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: dgPolyhedra.h:76
Definition: dgMeshEffect.h:80
Definition: dgConvexHull4d.h:96
Definition: dgMeshEffect.h:105
Definition: dgCollision.h:178
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgWorld.h:118
Definition: dgMeshEffectSolidTree.h:58
Definition: dgMeshEffectSolidTree.h:31
Definition: dgVector.h:104