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

capsule.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     capsule.h  -  Capsule bounding volume
00003                              -------------------
00004     begin                : Sun Jul 13 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, capsule.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 __NECAPSULE_H
00028 #define __NECAPSULE_H
00029 
00030 
00031 
00032 #include "base.h"
00033 #include "boundingvolume.h"
00034 
00035 
00042 namespace NeoEngine
00043 {
00044 
00045 
00046 
00051 class NEOENGINE_API Capsule : public BoundingVolume
00052 {
00053     public:
00054 
00056         float                                         m_fLength;
00057 
00058         /* ! Radius of cylinder and end half-spheres*/
00059         float                                         m_fRadius;
00060 
00061 
00062 
00067                                                       Capsule( float fLength = 0.0f, float fRadius = 0.0f );
00068 
00072                                                       Capsule( const Capsule &rkCapsule ) : BoundingVolume( rkCapsule ), m_fLength( rkCapsule.m_fLength ), m_fRadius( m_fRadius ) {}
00073 
00081         inline virtual bool                           Intersection( BoundingVolume *pkObj, ContactSet *pkContactSet = 0, bool bInvertNormal = false )
00082         {
00083             BOUNDINGVOLUMETYPE eType = pkObj->GetType();
00084 
00085             if( eType == BV_AABB )
00086                 return NeoEngine::Intersection( (AABB*)pkObj, this, pkContactSet, !bInvertNormal );
00087             else if( eType == BV_OBB )
00088                 return NeoEngine::Intersection( (OBB*)pkObj, this, pkContactSet, !bInvertNormal );
00089             else if( eType == BV_SPHERE )
00090                 return NeoEngine::Intersection( (Sphere*)pkObj, this, pkContactSet, !bInvertNormal );
00091             else // BV_CAPSULE
00092                 return NeoEngine::Intersection( this, (Capsule*)pkObj, pkContactSet, bInvertNormal );
00093         }
00094 
00102         inline virtual bool                           Intersection( AABB *pkAABB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkAABB, this, pkContactSet, !bInvertNormal ); }
00103     
00111         inline virtual bool                           Intersection( OBB *pkOBB, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkOBB, this, pkContactSet, bInvertNormal ); }
00112 
00120         inline virtual bool                           Intersection( Sphere *pkSphere, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( pkSphere, this, pkContactSet, !bInvertNormal ); }
00121 
00129         inline virtual bool                           Intersection( Capsule *pkCapsule, ContactSet *pkContactSet = 0, bool bInvertNormal = false ) { return NeoEngine::Intersection( this, pkCapsule, pkContactSet, bInvertNormal ); }
00130 
00136         inline virtual bool                           Intersection( Frustum *pkFrustum ) { return NeoEngine::Intersection( this, pkFrustum ); }
00137 
00148         virtual bool                                  Intersection( const Vector3d &rkV0, const Vector3d &rkV1, const Vector3d &rkV2, ContactSet *pkContactSet = 0, bool bForceTriNormal = true, const Vector3d &rkNormal = Vector3d::ZERO );
00149 
00155         virtual bool                                  Intersection( const Vector3d &rkPoint );
00156 
00163         virtual bool                                  Intersection( const Ray &rkRay, ContactSet *pkContactSet = 0 );
00164 
00170         virtual bool                                  Intersection( const Line &rkLine );
00171 
00177         virtual bool                                  Intersection( const Plane &rkPlane );
00178 
00183         virtual void                                  Generate( AABB *pkAABB );
00184 
00189         virtual void                                  Generate( OBB *pkOBB );
00190 
00195         virtual void                                  Generate( Sphere *pkSphere );
00196 
00201         virtual void                                  Generate( Capsule *pkCapsule );
00202 
00207         virtual void                                  Generate( VertexBufferPtr &pkVertexBuffer );
00208 
00213         virtual void                                  Merge( AABB *pkAABB );
00214 
00219         virtual void                                  Merge( OBB *pkOBB );
00220 
00225         virtual void                                  Merge( Sphere *pkSphere );
00226 
00231         virtual void                                  Merge( Capsule *pkCapsule );
00232 
00236         inline virtual BOUNDINGVOLUMETYPE             GetType() { return BV_CAPSULE; }
00237 
00241         virtual BoundingVolume                       *Duplicate() const;
00242 
00247         virtual void                                  RenderOutlines( const Color &rkColor = Color::GREEN ) const;
00248 };
00249 
00250 
00251 }; // namespace NeoEngine
00252 
00253 
00254 
00255 #endif
00256 

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