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

sphere.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                        sphere.h  -  Sphere bounding volume
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, sphere.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 __NESPHERE_H
00028 #define __NESPHERE_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 Sphere : public BoundingVolume
00056 {
00057     public:
00058 
00063         enum SPHEREDEFS
00064         {
00066           OUTLINEPOINTS                               = 16
00067         };
00068 
00069 
00071         float                                         m_fRadius;
00072 
00076                                                       Sphere( float fRadius = 0.0f );
00077 
00081                                                       Sphere( const Sphere &rkSphere ) : BoundingVolume( rkSphere ), m_fRadius( rkSphere.m_fRadius ) {}
00082 
00090         inline virtual bool                           Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0, bool bInvertNormal = false )
00091         {
00092             BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00093 
00094             if( eType == BV_AABB )
00095                 return NeoEngine::Intersection( (AABB*)pkObj, this, pkContactSet, !bInvertNormal );
00096             else if( eType == BV_OBB )
00097                 return NeoEngine::Intersection( (OBB*)pkObj, this, pkContactSet, !bInvertNormal );
00098             else if( eType == BV_SPHERE )
00099                 return NeoEngine::Intersection( this, (Sphere*)pkObj, pkContactSet, bInvertNormal );
00100             else // BV_CAPSULE
00101                 return NeoEngine::Intersection( this, (Capsule*)pkObj, pkContactSet, bInvertNormal );
00102         }
00103 
00111         inline virtual bool                           Intersection( AABB *pkAABB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkAABB, this, pkContactSet, !bInvertNormal ); }
00112 
00120         inline virtual bool                           Intersection( OBB *pkOBB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkOBB, this, pkContactSet, !bInvertNormal ); }
00121 
00129         inline virtual bool                           Intersection( Sphere *pkSphere, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkSphere, pkContactSet, bInvertNormal ); }
00130 
00138         inline virtual bool                           Intersection( Capsule *pkCapsule, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkCapsule, pkContactSet, bInvertNormal ); }
00139 
00145         inline virtual bool                           Intersection( Frustum *pkFrustum ) { return NeoEngine::Intersection( this, pkFrustum ); }
00146 
00157         virtual bool                                  Intersection( const Vector3d &rkV0, const Vector3d &rkV1, const Vector3d &rkV2, ContactSet *pkContactSet = 0, bool bForceTriNormal = true, const Vector3d &rkNormal = Vector3d::ZERO );
00158 
00164         virtual bool                                  Intersection( const Vector3d &rkPoint );
00165 
00172         virtual bool                                  Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 );
00173 
00179         virtual bool                                  Intersection( const Line &rkLine );
00180 
00186         virtual bool                                  Intersection( const Plane &rkPlane );
00187 
00192         virtual void                                  Generate( AABB *pkAABB );
00193 
00198         virtual void                                  Generate( OBB *pkOBB );
00199 
00204         virtual void                                  Generate( Sphere *pkSphere );
00205 
00210         virtual void                                  Generate( Capsule *pkCapsule );
00211 
00216         virtual void                                  Generate( VertexBufferPtr &pkVertexBuffer );
00217 
00222         virtual void                                  Merge( AABB *pkAABB );
00223 
00228         virtual void                                  Merge( OBB *pkOBB );
00229 
00234         virtual void                                  Merge( Sphere *pkSphere );
00235 
00240         virtual void                                  Merge( Capsule *pkCapsule );
00241 
00245         inline virtual BOUNDINGVOLUMETYPE             GetType() { return BV_SPHERE; }
00246 
00250         virtual BoundingVolume                       *Duplicate() const;
00251 
00256         virtual void                                  RenderOutlines( const Color &rkColor = Color::GREEN ) const;
00257 };
00258 
00259 
00260 };
00261 
00262 
00263 #endif

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