True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

ConvexHull.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: ConvexHull.h
00003 // Description:
00004 //
00005 // Copyright (C) 2004 - 2006 True Axis Pty Ltd, Australia. 
00006 // All Rights Reserved.
00007 //
00008 // History:
00009 //      Created File.
00010 //---------------------------------------------------------------------------------
00011 
00012 #ifndef TA_CONVEXHULL_H
00013 #define TA_CONVEXHULL_H
00014 
00015 #ifndef TA_ARRAY_H
00016 #include "Array.h"
00017 #endif // TA_ARRAY_H
00018 
00019 #ifndef TA_VECTOR_H
00020 #include "Vector.h"
00021 #endif // TA_VECTOR_H
00022 
00023 TA_OBFUSCATION_SKIP_PASS_2
00024 
00025 namespace TA
00026 {
00027 
00028 struct Vec3;
00029 
00030 class TACOMMON_CLASS ConvexHull
00031 {
00032 public:
00033     // A virtual structure
00034     struct Polygon
00035     {
00036         TA_OBFUSCATION_RESERVED_ON
00037         int GetNumVertices() const;
00038         int GetVertexPositionIndex(int nVertexIndex) const;
00039         int GetVertexAdjacentPolygonIndex(int nVertexIndex) const;
00040         TA_OBFUSCATION_RESERVED_OFF
00041 
00042         struct Vertex
00043         {
00044             int nPositionIndex;
00045             int nAdjacentPolygonIndex;
00046         };
00047         int nNumVertices;
00048         Vertex pVertexList[16]; // Ignore the size 16 on this member.
00049     };
00050 
00051     TA_OBFUSCATION_RESERVED_ON
00052 
00053     ConvexHull();
00054     ~ConvexHull();
00055 
00056     bool Initialise(const Vec3* v3PointList, int nNumPoints, int nMaxNumVerticesInPolygon);
00057     bool Initialise(    
00058         const Vec3* pv3PlaneNormalList, 
00059         const Vec3* pv3PlanePointList, 
00060         int nNumPlanes);
00061 
00062     void Finalise();
00063 
00064     int GetNumPoints() const;
00065     const Vec3& GetPoint(int nIndex) const;
00066 
00067     int GetNumPolygons() const;
00068     const Polygon& GetPolygon(int nIndex) const;
00069 
00070     TA_OBFUSCATION_RESERVED_OFF
00071     
00072 private:
00073     struct Triangle;
00074     class BSP;
00075     
00076     bool m_bTryAgain;
00077     bool m_bTooManyFaceMerges;
00078     float m_fMinDistance;
00079     Array<int> m_polygonData;
00080     Array<int> m_polygonOffsetArray;
00081     Array<Vec3, false> m_pointArray;
00082     //const Vec3* m_pPointArray;
00083     //Array<int> m_indexArray;
00084     //BSP* m_pBSP;
00085 
00086     bool Initialise(BSP& bsp);
00087     bool InitialiseInternal(const Vec3* pPointArrayIn, int nNumPointsIn, int nMaxNumVerticesInPolygon, float fRandomness, float fMergeFactor);
00088 };
00089 
00090 inline int ConvexHull::Polygon::GetNumVertices() const { return nNumVertices; }
00091 inline int ConvexHull::Polygon::GetVertexPositionIndex(int nVertexIndex) const { return pVertexList[nVertexIndex].nPositionIndex; }
00092 inline int ConvexHull::Polygon::GetVertexAdjacentPolygonIndex(int nVertexIndex) const { return pVertexList[nVertexIndex].nAdjacentPolygonIndex; }
00093 inline int ConvexHull::GetNumPoints() const { return m_pointArray.GetSize(); }
00094 inline const Vec3& ConvexHull::GetPoint(int nIndex) const { return m_pointArray[nIndex]; }
00095 inline int ConvexHull::GetNumPolygons() const { return m_polygonOffsetArray.GetSize(); }
00096 inline const ConvexHull::Polygon& ConvexHull::GetPolygon(int nIndex) const { return *(Polygon*)&m_polygonData[m_polygonOffsetArray[nIndex]]; }
00097 
00098 }
00099 #endif //  TA_CONVEXHULL_H


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.