Planeshift
colldet.h
Go to the documentation of this file.
1 /*
2  Crystal Space Entity Layer
3  Copyright (C) 2001 PlaneShift Team (info@planeshift.it,
4  Copyright (C) 2001-2003 by Jorrit Tyberghein
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public
17  License along with this library; if not, write to the Free
18  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20 
21 /*
22  * This code is heavily based on pslinmove from the PlaneShift project.
23  * Thanks a lot for making this!
24  */
25 
26 #ifndef __CEL_PF_COLL_DET_FACT__
27 #define __CEL_PF_COLL_DET_FACT__
28 
29 //CS Includes
30 #include <cstypes.h>
31 #include <iutil/comp.h>
32 #include <iutil/eventh.h>
33 #include <csutil/scf.h>
34 #include <csutil/stringarray.h>
35 #include <csutil/sysfunc.h>
36 #include <cstool/collider.h>
37 #include <ivaria/collider.h>
38 
39 
40 struct iObjectRegistry;
41 struct iVirtualClock;
42 struct iCollider;
43 struct iCollideSystem;
44 struct iSector;
45 struct iPath;
46 
47 class csReversibleTransform;
48 class csObject;
49 class csColliderWrapper;
50 
51 
57 {
58 public:
59  psCollisionDetection(iObjectRegistry* object_reg);
60  virtual ~psCollisionDetection();
61 
62  virtual bool Init(const csVector3 &body, const csVector3 &legs, const csVector3 &shift, iMeshWrapper* mesh);
63 
64  virtual bool IsOnGround() const;
65  virtual void SetOnGround(bool flag);
66  virtual void UseCD(bool flag);
67 
68  virtual bool AdjustForCollisions(csVector3 &oldpos,
69  csVector3 &newpos,
70  csVector3 &vel,
71  float delta,
72  iMovable* movable);
73 
74 protected:
75  csRef<iMeshWrapper> mesh;
76 
77  csColliderActor colliderActor;
78 
79  bool useCD;
80 
81  //Collision vars
82  csVector3 shift;
83  csVector3 topSize;
84  csVector3 bottomSize;
85 
86  // Try to find the collider for an object. Can return 0 if there is none.
87  // This function uses csColliderWrapper if present. If not it will try
88  // if there is a pcsolid to get a collider from.
89  iCollider* FindCollider(iObject* object);
90 
91 };
92 
93 #endif
94 
virtual bool AdjustForCollisions(csVector3 &oldpos, csVector3 &newpos, csVector3 &vel, float delta, iMovable *movable)
virtual void UseCD(bool flag)
virtual void SetOnGround(bool flag)
csRef< iMeshWrapper > mesh
Definition: colldet.h:75
iCollider * FindCollider(iObject *object)
csVector3 topSize
Definition: colldet.h:83
csColliderActor colliderActor
Definition: colldet.h:77
virtual ~psCollisionDetection()
Collision Detection (CD) related class.
Definition: colldet.h:56
virtual bool Init(const csVector3 &body, const csVector3 &legs, const csVector3 &shift, iMeshWrapper *mesh)
bool useCD
Enable collision detection flag.
Definition: colldet.h:79
csVector3 shift
Definition: colldet.h:82
virtual bool IsOnGround() const
csVector3 bottomSize
Definition: colldet.h:84
psCollisionDetection(iObjectRegistry *object_reg)