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

boundingvolume.h

Go to the documentation of this file.
00001 /***************************************************************************
00002               boundingvolume.h  -  Base interface for bounding volumes
00003                              -------------------
00004     begin                : Sat Jan 26 2003
00005     copyright            : (C) 2003 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, boundingvolume.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2003
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 #ifndef __NEBOUNDINGVOLUME_H
00028 #define __NEBOUNDINGVOLUME_H
00029 
00030 
00031 #include "base.h"
00032 #include "collision.h"
00033 #include "node.h"
00034 #include "pointer.h"
00035 #include "color.h"
00036 
00037 
00043 namespace NeoEngine
00044 {
00045 
00046 
00047 // External classes
00048 class AABB;
00049 class OBB;
00050 class Sphere;
00051 class VertexBuffer;
00052 
00053 typedef Pointer< VertexBuffer > VertexBufferPtr;
00054 
00055 
00062 class NEOENGINE_API BoundingVolume : public SRTNode
00063 {
00064     public:
00065 
00069         enum BOUNDINGVOLUMETYPE
00070         {
00072           BV_AABB,
00073         
00075           BV_OBB,
00076 
00078           BV_SPHERE,
00079 
00081           BV_CAPSULE
00082         };
00083 
00084 
00085     public:
00086 
00089                                                       BoundingVolume() : SRTNode() {}
00090 
00095                                                       BoundingVolume( const BoundingVolume &rkVolume ) : SRTNode( rkVolume ) {}
00096 
00104         virtual bool                                  Intersection( AABB *pkAABB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) = 0;
00105 
00113         virtual bool                                  Intersection( OBB *pkOBB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) = 0;
00114 
00122         virtual bool                                  Intersection( Sphere *pkSphere, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) = 0;
00123 
00131         virtual bool                                  Intersection( Capsule *pkCapsule, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) = 0;
00132 
00138         virtual bool                                  Intersection( Frustum *pkFrustum ) = 0;
00139 
00150         virtual bool                                  Intersection( const Vector3d &rkV0, const Vector3d &rkV1, const Vector3d &rkV2, ContactSet *pkContactSet = 0, bool bForceTriNormal = true, const Vector3d &rkNormal = Vector3d::ZERO ) = 0;
00151 
00159         virtual bool                                  Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) = 0;
00160 
00166         virtual bool                                  Intersection( const Vector3d &rkPoint ) = 0;
00167 
00174         virtual bool                                  Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 ) = 0;
00175 
00181         virtual bool                                  Intersection( const Line &rkLine ) = 0;
00182 
00188         virtual bool                                  Intersection( const Plane &rkPlane ) = 0;
00189 
00194         virtual void                                  Generate( AABB *pkAABB ) = 0;
00195 
00200         virtual void                                  Generate( OBB *pkOBB ) = 0;
00201 
00206         virtual void                                  Generate( Sphere *pkSphere ) = 0;
00207 
00212         virtual void                                  Generate( Capsule *pkCapsule ) = 0;
00213 
00218         inline void                                   Generate( BoundingVolume *pkObj )
00219         {
00220             BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00221 
00222             if( eType == BV_AABB )
00223                 Generate( (AABB*)pkObj );
00224             else if( eType == BV_OBB )
00225                 Generate( (OBB*)pkObj );
00226             else if( eType == BV_SPHERE )
00227                 Generate( (Sphere*)pkObj );
00228             else // BV_CAPSULE
00229                 Generate( (Capsule*)pkObj );
00230         }
00231 
00236         virtual void                                  Generate( VertexBufferPtr &pkVertexBuffer ) = 0;
00237 
00242         virtual void                                  Merge( AABB *pkAABB ) = 0;
00243 
00248         virtual void                                  Merge( OBB *pkOBB ) = 0;
00249 
00254         virtual void                                  Merge( Sphere *pkSphere ) = 0;
00255 
00260         virtual void                                  Merge( Capsule *pkCapsule ) = 0;
00261 
00266         inline void                                   Merge( BoundingVolume *pkObj )
00267         {
00268             BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00269 
00270             if( eType == BV_AABB )
00271                 Merge( (AABB*)pkObj );
00272             else if( eType == BV_OBB )
00273                 Merge( (OBB*)pkObj );
00274             else if( eType == BV_SPHERE )
00275                 Merge( (Sphere*)pkObj );
00276             else // BV_CAPSULE
00277                 Merge( (Capsule*)pkObj );
00278         }
00279 
00283         virtual BOUNDINGVOLUMETYPE                    GetType() = 0;
00284 
00289         virtual BoundingVolume                       *Duplicate() const = 0;
00290 
00295         virtual void                                  RenderOutlines( const Color &rkColor = Color::GREEN ) const = 0;
00296 };
00297 
00298 
00299 };
00300 
00301 
00302 #endif
00303 

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