CrystalSpace

Public API Reference

ivaria/collider.h
Go to the documentation of this file.
00001 /*
00002     Crystal Space 3D engine
00003     Copyright (C) 2000 by Jorrit Tyberghein
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_IVARIA_COLLIDER_H__
00021 #define __CS_IVARIA_COLLIDER_H__
00022 
00027 #include "csutil/scf_interface.h"
00028 #include "csgeom/vector3.h"
00029 #include "csutil/array.h"
00030 #include "csutil/ref.h"
00031 #include "iutil/strset.h"
00032 
00033 struct iTriangleMesh;
00034 struct iTerraFormer;
00035 struct iMeshObject;
00036 class csReversibleTransform;
00037 struct iTerrainSystem;
00038 
00043 struct csCollisionPair
00044 {
00046 
00047   csVector3 a1, b1, c1; 
00049 
00050   // Second triangle
00051   csVector3 a2, b2, c2; 
00053 
00055   bool operator==(const csCollisionPair& p) const
00056   {
00057     return (a1 == p.a1 && b1 == p.b1 && c1 == p.c1 &&
00058             a2 == p.a2 && b2 == p.b2 && c2 == p.c2);
00059   }
00060 };
00061 
00065 struct csIntersectingTriangle
00066 {
00067   csVector3 a, b, c;
00068 };
00069 
00070 
00071 
00072 enum csColliderType
00073 {
00074   CS_MESH_COLLIDER = 0,
00075   CS_TERRAFORMER_COLLIDER,
00076   CS_TERRAIN_COLLIDER
00077 };
00078 
00091 struct iCollider : public virtual iBase
00092 {
00093   SCF_INTERFACE (iCollider, 0, 2, 0);
00094   virtual csColliderType GetColliderType () = 0;
00095 };
00096 
00113 struct iCollideSystem : public virtual iBase
00114 {
00115   SCF_INTERFACE (iCollideSystem, 2, 2, 1);
00116 
00123   virtual csStringID GetTriangleDataID () = 0;
00124 
00131   virtual csStringID GetBaseDataID () = 0;
00132 
00144   virtual csPtr<iCollider> CreateCollider (iTriangleMesh* mesh) = 0;
00145 
00151   virtual csPtr<iCollider> CreateCollider (iTerraFormer* mesh) = 0;
00152   
00156   virtual csPtr<iCollider> CreateCollider (iTerrainSystem* mesh) = 0;
00157 
00179   virtual bool Collide (
00180         iCollider* collider1, const csReversibleTransform* trans1,
00181         iCollider* collider2, const csReversibleTransform* trans2) = 0;
00182 
00191   virtual csCollisionPair* GetCollisionPairs () = 0;
00192 
00197   virtual size_t GetCollisionPairCount () = 0;
00198 
00204   virtual void ResetCollisionPairs () = 0;
00205 
00218   virtual bool CollideRay (
00219         iCollider* collider, const csReversibleTransform* trans,
00220         const csVector3& start, const csVector3& pointOnRay) = 0;
00221 
00234   virtual bool CollideSegment (
00235         iCollider* collider, const csReversibleTransform* trans,
00236         const csVector3& start, const csVector3& end) = 0;
00237 
00243   virtual const csArray<csIntersectingTriangle>& GetIntersectingTriangles ()
00244         const = 0;
00245 
00254   virtual void SetOneHitOnly (bool o) = 0;
00255 
00264   virtual bool GetOneHitOnly () = 0;
00265 };
00266 
00267 #endif // __CS_IVARIA_COLLIDER_H__
00268 

Generated for Crystal Space 2.0 by doxygen 1.7.6.1