2
0

IceIndexedTriangle.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains a handy indexed triangle class.
  4. * \file IceIndexedTriangle.h
  5. * \author Pierre Terdiman
  6. * \date January, 17, 2000
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // Include Guard
  11. #ifndef __ICEINDEXEDTRIANGLE_H__
  12. #define __ICEINDEXEDTRIANGLE_H__
  13. // An indexed triangle class.
  14. class ICEMATHS_API IndexedTriangle
  15. {
  16. public:
  17. //! Constructor
  18. inline_ IndexedTriangle() { mMatIdx=-1; }
  19. //! Constructor
  20. inline_ IndexedTriangle(udword r0, udword r1, udword r2) { mVRef[0]=r0; mVRef[1]=r1; mVRef[2]=r2; mMatIdx=-1; }
  21. //! Copy constructor
  22. inline_ IndexedTriangle(const IndexedTriangle& triangle)
  23. {
  24. mVRef[0] = triangle.mVRef[0];
  25. mVRef[1] = triangle.mVRef[1];
  26. mVRef[2] = triangle.mVRef[2];
  27. mMatIdx = -1;
  28. }
  29. //! Destructor
  30. inline_ ~IndexedTriangle() {}
  31. //! Vertex-references
  32. udword mVRef[3];
  33. //! Material-reference
  34. udword mMatIdx;
  35. // Methods
  36. void Flip();
  37. float Area(const Point* verts) const;
  38. float Perimeter(const Point* verts) const;
  39. float Compacity(const Point* verts) const;
  40. void Normal(const Point* verts, Point& normal) const;
  41. void DenormalizedNormal(const Point* verts, Point& normal) const;
  42. void Center(const Point* verts, Point& center) const;
  43. void CenteredNormal(const Point* verts, Point& normal) const;
  44. void RandomPoint(const Point* verts, Point& random) const;
  45. bool IsVisible(const Point* verts, const Point& source) const;
  46. bool BackfaceCulling(const Point* verts, const Point& source) const;
  47. float ComputeOcclusionPotential(const Point* verts, const Point& view) const;
  48. bool ReplaceVertex(udword oldref, udword newref);
  49. bool IsDegenerate() const;
  50. bool HasVertex(udword ref) const;
  51. bool HasVertex(udword ref, udword* index) const;
  52. ubyte FindEdge(udword vref0, udword vref1) const;
  53. udword OppositeVertex(udword vref0, udword vref1) const;
  54. inline_ udword OppositeVertex(ubyte edgenb) const { return mVRef[2-edgenb]; }
  55. void GetVRefs(ubyte edgenb, udword& vref0, udword& vref1, udword& vref2) const;
  56. float MinEdgeLength(const Point* verts) const;
  57. float MaxEdgeLength(const Point* verts) const;
  58. void ComputePoint(const Point* verts, float u, float v, Point& pt, udword* nearvtx=null) const;
  59. float Angle(const IndexedTriangle& tri, const Point* verts) const;
  60. inline_ Plane PlaneEquation(const Point* verts) const { return Plane(verts[mVRef[0]], verts[mVRef[1]], verts[mVRef[2]]); }
  61. bool Equal(const IndexedTriangle& tri) const;
  62. };
  63. #endif // __ICEINDEXEDTRIANGLE_H__