Planeshift

colldet.h

Go to the documentation of this file.
00001 /*
00002   Crystal Space Entity Layer
00003   Copyright (C) 2001 PlaneShift Team ([email protected],
00004   Copyright (C) 2001-2003 by Jorrit Tyberghein
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public
00017   License along with this library; if not, write to the Free
00018   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 */
00020 
00021 /*
00022  * This code is heavily based on pslinmove from the PlaneShift project.
00023  * Thanks a lot for making this!
00024  */
00025 
00026 #ifndef __CEL_PF_COLL_DET_FACT__
00027 #define __CEL_PF_COLL_DET_FACT__
00028 
00029 //CS Includes
00030 #include <cstypes.h>
00031 #include <iutil/comp.h>
00032 #include <iutil/eventh.h>
00033 #include <csutil/scf.h>
00034 #include <csutil/stringarray.h>
00035 #include <csutil/sysfunc.h>
00036 #include <cstool/collider.h>
00037 #include <ivaria/collider.h>
00038 
00039 
00040 struct iObjectRegistry;
00041 struct iVirtualClock;
00042 struct iCollider;
00043 struct iCollideSystem;
00044 struct iSector;
00045 struct iPath;
00046 
00047 class csReversibleTransform;
00048 class csObject;
00049 class csColliderWrapper;
00050 
00051 
00056 class psCollisionDetection
00057 {
00058 public:
00059     psCollisionDetection(iObjectRegistry* object_reg);
00060     virtual ~psCollisionDetection();
00061 
00062     virtual bool Init(const csVector3 &body, const csVector3 &legs, const csVector3 &shift, iMeshWrapper* mesh);
00063 
00064     virtual bool IsOnGround() const;
00065     virtual void SetOnGround(bool flag);
00066     virtual void UseCD(bool flag);
00067 
00068     virtual bool AdjustForCollisions(csVector3 &oldpos,
00069                                      csVector3 &newpos,
00070                                      csVector3 &vel,
00071                                      float delta,
00072                                      iMovable* movable);
00073 
00074 protected:
00075     csRef<iMeshWrapper> mesh;
00076 
00077     csColliderActor colliderActor;
00078 
00079     bool useCD;           
00080 
00081     //Collision vars
00082     csVector3 shift;
00083     csVector3 topSize;
00084     csVector3 bottomSize;
00085 
00086     // Try to find the collider for an object. Can return 0 if there is none.
00087     // This function uses csColliderWrapper if present. If not it will try
00088     // if there is a pcsolid to get a collider from.
00089     iCollider* FindCollider(iObject* object);
00090 
00091 };
00092 
00093 #endif
00094