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 
00032 struct iPolygonMesh;
00033 struct iTerraFormer;
00034 struct iMeshObject;
00035 class csReversibleTransform;
00036 
00041 struct csCollisionPair
00042 {
00044 
00045   csVector3 a1, b1, c1; 
00047 
00048   // Second triangle
00049   csVector3 a2, b2, c2; 
00051 };
00052 
00056 struct csIntersectingTriangle
00057 {
00058   csVector3 a, b, c;
00059 };
00060 
00061 
00062 
00063 enum csColliderType
00064 {
00065   CS_MESH_COLLIDER = 0,
00066   CS_TERRAFORMER_COLLIDER
00067 };
00068 
00081 struct iCollider : public virtual iBase
00082 {
00083   SCF_INTERFACE (iCollider, 0, 2, 0);
00084   virtual csColliderType GetColliderType () = 0;
00085 };
00086 
00103 struct iCollideSystem : public virtual iBase
00104 {
00105   SCF_INTERFACE (iCollideSystem, 2, 0, 0);
00115   virtual csPtr<iCollider> CreateCollider (iPolygonMesh* mesh) = 0;
00116 
00122   virtual csPtr<iCollider> CreateCollider (iTerraFormer* mesh) = 0;
00123   
00145   virtual bool Collide (
00146         iCollider* collider1, const csReversibleTransform* trans1,
00147         iCollider* collider2, const csReversibleTransform* trans2) = 0;
00148 
00157   virtual csCollisionPair* GetCollisionPairs () = 0;
00158 
00163   virtual size_t GetCollisionPairCount () = 0;
00164 
00170   virtual void ResetCollisionPairs () = 0;
00171 
00183   virtual bool CollideRay (
00184         iCollider* collider, const csReversibleTransform* trans,
00185         const csVector3& start, const csVector3& end) = 0;
00186 
00199   virtual bool CollideSegment (
00200         iCollider* collider, const csReversibleTransform* trans,
00201         const csVector3& start, const csVector3& end) = 0;
00202 
00208   virtual const csArray<csIntersectingTriangle>& GetIntersectingTriangles ()
00209         const = 0;
00210 
00219   virtual void SetOneHitOnly (bool o) = 0;
00220 
00229   virtual bool GetOneHitOnly () = 0;
00230 };
00231 
00232 #endif // __CS_IVARIA_COLLIDER_H__
00233 

Generated for Crystal Space by doxygen 1.4.7