PageRenderTime 46ms CodeModel.GetById 22ms app.highlight 6ms RepoModel.GetById 17ms app.codeStats 0ms

/lib/ode/ode_source/OPCODE/Ice/IceIndexedTriangle.h

http://narutortsproject.googlecode.com/
C++ Header | 76 lines | 50 code | 8 blank | 18 comment | 0 complexity | 94ba4928dcf19373e22e1ececf4cc33f MD5 | raw file
 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 "ode/common.h"
11
12///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
13// Include Guard
14#ifndef __ICEINDEXEDTRIANGLE_H__
15#define __ICEINDEXEDTRIANGLE_H__
16
17	// Forward declarations
18#ifdef _MSC_VER
19	enum CubeIndex;
20#else
21	typedef int CubeIndex;
22#endif
23
24	// An indexed triangle class.
25	class ICEMATHS_API IndexedTriangle
26	{
27		public:
28
29		//! Constructor
30		inline_					IndexedTriangle()									{}
31		//! Constructor
32		inline_					IndexedTriangle(dTriIndex r0, dTriIndex r1, dTriIndex r2)	{ mVRef[0]=r0; mVRef[1]=r1; mVRef[2]=r2; }
33		//! Copy constructor
34		inline_					IndexedTriangle(const IndexedTriangle& triangle)
35								{
36									mVRef[0] = triangle.mVRef[0];
37									mVRef[1] = triangle.mVRef[1];
38									mVRef[2] = triangle.mVRef[2];
39								}
40		//! Destructor
41		inline_					~IndexedTriangle()									{}
42		
43		//! Vertex-references
44				dTriIndex		mVRef[3];
45
46		// Methods
47				void			Flip();
48				float			Area(const Point* verts)											const;
49				float			Perimeter(const Point* verts)										const;
50				float			Compacity(const Point* verts)										const;
51				void			Normal(const Point* verts, Point& normal)							const;
52				void			DenormalizedNormal(const Point* verts, Point& normal)				const;
53				void			Center(const Point* verts, Point& center)							const;
54				void			CenteredNormal(const Point* verts, Point& normal)					const;
55				void			RandomPoint(const Point* verts, Point& random)						const;
56				bool			IsVisible(const Point* verts, const Point& source)					const;
57				bool			BackfaceCulling(const Point* verts, const Point& source)			const;
58				float			ComputeOcclusionPotential(const Point* verts, const Point& view)	const;
59				bool			ReplaceVertex(dTriIndex oldref, dTriIndex newref);
60				bool			IsDegenerate()														const;
61				bool			HasVertex(dTriIndex ref)												const;
62				bool			HasVertex(dTriIndex ref, dTriIndex* index)								const;
63				ubyte			FindEdge(dTriIndex vref0, dTriIndex vref1)								const;
64				dTriIndex		OppositeVertex(dTriIndex vref0, dTriIndex vref1)							const;
65		inline_	dTriIndex		OppositeVertex(ubyte edgenb)										const	{ return mVRef[2-edgenb];	}
66				void			GetVRefs(ubyte edgenb, dTriIndex& vref0, dTriIndex& vref1, dTriIndex& vref2)	const;
67				float			MinEdgeLength(const Point* verts)									const;
68				float			MaxEdgeLength(const Point* verts)									const;
69				void			ComputePoint(const Point* verts, float u, float v, Point& pt, dTriIndex* nearvtx=null)	const;
70				float			Angle(const IndexedTriangle& tri, const Point* verts)				const;
71		inline_	Plane			PlaneEquation(const Point* verts)									const	{ return Plane(verts[mVRef[0]], verts[mVRef[1]], verts[mVRef[2]]);	}
72				bool			Equal(const IndexedTriangle& tri)									const;
73				CubeIndex		ComputeCubeIndex(const Point* verts)								const;
74	};
75
76#endif // __ICEINDEXEDTRIANGLE_H__