00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEAABB_H
00028 #define __NEAABB_H
00029
00030
00031 #include "base.h"
00032 #include "boundingvolume.h"
00033
00034
00041 namespace NeoEngine
00042 {
00043
00044
00051 class NEOENGINE_API AABB : public BoundingVolume
00052 {
00053 protected:
00054
00056 Vector3d m_kRealDim;
00057
00059 Vector3d m_kDim;
00060
00062 float m_fRadius;
00063
00065 void RecalcDim();
00066
00067
00068
00069 public:
00070
00074 AABB( const Vector3d &rkDim = Vector3d::ZERO );
00075
00079 AABB( const AABB &rkAABB ) : BoundingVolume( rkAABB ), m_kDim( rkAABB.m_kDim ) {}
00080
00088 inline virtual bool Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0, bool bInvertNormal = false )
00089 {
00090 BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00091
00092 if( eType == BV_AABB )
00093 return NeoEngine::Intersection( this, (AABB*)pkObj, pkContactSet, bInvertNormal );
00094 else if( eType == BV_OBB )
00095 return NeoEngine::Intersection( this, (OBB*)pkObj, pkContactSet, bInvertNormal );
00096 else if( eType == BV_SPHERE )
00097 return NeoEngine::Intersection( this, (Sphere*)pkObj, pkContactSet, bInvertNormal );
00098 else
00099 return NeoEngine::Intersection( this, (Capsule*)pkObj, pkContactSet, bInvertNormal );
00100 }
00101
00109 inline virtual bool Intersection( AABB *pkAABB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkAABB, pkContactSet, bInvertNormal ); }
00110
00118 inline virtual bool Intersection( OBB *pkOBB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkOBB, pkContactSet, bInvertNormal ); }
00119
00127 inline virtual bool Intersection( Sphere *pkSphere, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkSphere, pkContactSet, bInvertNormal ); }
00128
00136 inline virtual bool Intersection( Capsule *pkCapsule, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkCapsule, pkContactSet, bInvertNormal ); }
00137
00143 inline virtual bool Intersection( Frustum *pkFrustum ) { return NeoEngine::Intersection( this, pkFrustum ); }
00144
00155 virtual bool Intersection( const Vector3d &rkV0, const Vector3d &rkV1, const Vector3d &rkV2, ContactSet *pkContactSet = 0, bool bForceTriNormal = true, const Vector3d &rkNormal = Vector3d::ZERO );
00156
00162 virtual bool Intersection( const Vector3d &rkPoint );
00163
00170 virtual bool Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 );
00171
00177 virtual bool Intersection( const Line &rkLine );
00178
00184 virtual bool Intersection( const Plane &rkPlane );
00185
00190 virtual void Generate( AABB *pkAABB );
00191
00196 virtual void Generate( OBB *pkOBB );
00197
00202 virtual void Generate( Sphere *pkSphere );
00203
00208 virtual void Generate( Capsule *pkCapsule );
00209
00214 virtual void Generate( VertexBufferPtr &pkVertexBuffer );
00215
00220 virtual void Merge( AABB *pkAABB );
00221
00226 virtual void Merge( OBB *pkOBB );
00227
00232 virtual void Merge( Sphere *pkSphere );
00233
00238 virtual void Merge( Capsule *pkCapsule );
00239
00244 virtual void SetDim( const Vector3d &rkDim );
00245
00251 virtual void SetRotation( const Quaternion &rkRotation, bool bNotifyUpdate = true );
00252
00256 inline const Vector3d &GetDim() const { return m_kDim; }
00257
00261 inline const Vector3d &GetRealDim() const { return m_kRealDim; }
00262
00266 inline float GetRadius() const { return m_fRadius; }
00267
00271 inline virtual BOUNDINGVOLUMETYPE GetType() { return BV_AABB; }
00272
00276 virtual BoundingVolume *Duplicate() const;
00277
00282 virtual void RenderOutlines( const Color &rkColor = Color::GREEN ) const;
00283 };
00284
00285
00286 };
00287
00288
00289 #endif // __NEAABB_H
00290