Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

aabb.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     aabb.h  -  Axis-aligned bounding box
00003                              -------------------
00004     begin                : Wed Sep 18 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, aabb.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
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 // BV_CAPSULE
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 }; // namespace NeoEngine
00287 
00288 
00289 #endif // __NEAABB_H
00290 

Generated on Wed Jan 21 14:21:06 2004 for NeoEngine by doxygen 1.3.5