www.pudn.com > Gimcrack-v0.0051-Source.zip > obb.h


 //////////////////////////////////////////////////// 
// Oriented Bounding Box handler 
// 2003-02-21 
// 
// 2003-04-16 Added support dynamic collision detection 
//////////////////////////////////////////////////// 
#ifndef _OBB_H_ 
#define _OBB_H_ 
#include "../entity/trsnode.h" 
#include "plane.h" 
#include "triangle.h" 
 
class GcOBB : public GcTRSNode 
{ 
	public: 
		GcOBB(); 
		GcOBB( GcVector3 & extents ); 
		GcOBB( GcVector3 & extents, GcVector3 & position ); 
 
		void RenderOutlines(); 
		 
		const bool Intersects( const GcPlane & plane ); 
		const bool Intersects( const GcTriangle & tri ); 
		const bool Intersects( GcAABB & box ); 
		const bool Intersects( GcOBB & box ); 
 
		const bool Collides( GcVector3 & thisVel, GcTriangle & tri, GcVector3 & triVel, float maxT, float & first, float & last ); 
		const bool Collides( GcVector3 & thisVel, GcOBB & box, GcVector3 & boxVel, float maxT, float & firstT, float & lastT ); 
 
		float Extent( int i ) { return m_extents[i]; } 
		GcVector3 & Extents() { return m_extents; } 
		void SetExtents( GcVector3 & v ) { m_extents = v; } 
		GcVector3 Center() { return GetWorldTranslation(); } 
		 
		//const GcVector3 & Extents() { return m_extents; } 
		 
		GcVector3 * GetOrthogonal() { return m_orthogonal; } 
 
	protected: 
		GcVector3 m_extents; 
		GcVector3 m_orthogonal[3]; 
		static bool NoIntersect( float maxT, float speed, float min0, float max0, float min1, float max1, float & firstT, float & lastT ); 
 
}; 
 
#endif /* _OBB_H_ */