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

obb.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                        obb.h  -  Oriented 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, obb.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 __NEOBB_H
00028 #define __NEOBB_H
00029 
00030 
00031 #include "base.h"
00032 #include "boundingvolume.h"
00033 
00034 
00041 namespace NeoEngine
00042 {
00043 
00044 
00045 // External classes
00046 class Line;
00047 class Plane;
00048 class CollSet;
00049 
00050 
00055 class NEOENGINE_API OBB : public BoundingVolume
00056 {
00057     protected:
00058 
00060         Vector3d                                      m_kDim;
00061 
00063         float                                         m_fRadius;
00064 
00065 
00066     public:
00067 
00068     
00072                                                       OBB( const Vector3d &rkDim = Vector3d::ZERO );
00073 
00077                                                       OBB( const OBB &rkOBB ) : BoundingVolume( rkOBB ), m_kDim( rkOBB.m_kDim ) {}
00078 
00086         inline virtual bool                           Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0, bool bInvertNormal = false )
00087         {
00088             BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00089 
00090             if( eType == BV_AABB )
00091                 return NeoEngine::Intersection( (AABB*)pkObj, this, pkContactSet, !bInvertNormal );
00092             else if( eType == BV_OBB )
00093                 return NeoEngine::Intersection( this, (OBB*)pkObj, pkContactSet, bInvertNormal );
00094             else if( eType == BV_SPHERE )
00095                 return NeoEngine::Intersection( this, (Sphere*)pkObj, pkContactSet, bInvertNormal );
00096             else // BV_CAPSULE
00097                 return NeoEngine::Intersection( this, (Capsule*)pkObj, pkContactSet, bInvertNormal );
00098         }
00099 
00107         inline virtual bool                           Intersection( AABB *pkAABB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkAABB, this, pkContactSet, !bInvertNormal ); }
00108 
00116         inline virtual bool                           Intersection( OBB *pkOBB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkOBB, pkContactSet, bInvertNormal ); }
00117 
00125         inline virtual bool                           Intersection( Sphere *pkSphere, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkSphere, pkContactSet, bInvertNormal ); }
00126 
00134         inline virtual bool                           Intersection( Capsule *pkCapsule, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkCapsule, pkContactSet, bInvertNormal ); }
00135 
00141         inline virtual bool                           Intersection( Frustum *pkFrustum ) { return NeoEngine::Intersection( this, pkFrustum ); }
00142 
00153         virtual bool                                  Intersection( const Vector3d &rkV0, const Vector3d &rkV1, const Vector3d &rkV2, ContactSet *pkContactSet = 0, bool bForceTriNormal = true, const Vector3d &rkNormal = Vector3d::ZERO );
00154 
00160         virtual bool                                  Intersection( const Vector3d &rkPoint );
00161 
00168         virtual bool                                  Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 );
00169 
00175         virtual bool                                  Intersection( const Line &rkLine );
00176 
00182         virtual bool                                  Intersection( const Plane &rkPlane );
00183 
00188         virtual void                                  Generate( AABB *pkAABB );
00189 
00194         virtual void                                  Generate( OBB *pkOBB );
00195 
00200         virtual void                                  Generate( Sphere *pkSphere );
00201 
00206         virtual void                                  Generate( Capsule *pkCapsule );
00207 
00212         virtual void                                  Generate( VertexBufferPtr &pkVertexBuffer );
00213 
00218         virtual void                                  Merge( AABB *pkAABB );
00219 
00224         virtual void                                  Merge( OBB *pkOBB );
00225 
00230         virtual void                                  Merge( Sphere *pkSphere );
00231 
00236         virtual void                                  Merge( Capsule *pkCapsule );
00237 
00242         virtual void                                  SetDim( const Vector3d &rkDim );
00243 
00247         inline const Vector3d                        &GetDim() const { return m_kDim; }
00248 
00252         inline float                                  GetRadius() const { return m_fRadius; }
00253 
00257         inline virtual BOUNDINGVOLUMETYPE             GetType() { return BV_OBB; }
00258 
00262         virtual BoundingVolume                       *Duplicate() const;
00263 
00268         virtual void                                  RenderOutlines( const Color &rkColor = Color::GREEN ) const;
00269 };
00270 
00271 
00272 };
00273 
00274 
00275 #endif

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