2 * Add steering behaviors
4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is: all of this file.
22 * Contributor(s): none yet.
24 * ***** END GPL LICENSE BLOCK *****
27 #ifndef __KX_STEERINGACTUATOR_H__
28 #define __KX_STEERINGACTUATOR_H__
30 #include "SCA_IActuator.h"
31 #include "SCA_LogicManager.h"
32 #include "MT_Matrix3x3.h"
35 class KX_NavMeshObject;
37 class KX_ObstacleSimulation;
38 const int MAX_PATH_LENGTH = 128;
40 class KX_SteeringActuator : public SCA_IActuator
45 KX_GameObject *m_target;
46 KX_NavMeshObject *m_navmesh;
52 KX_ObstacleSimulation* m_simulation;
55 KX_Obstacle* m_obstacle;
57 bool m_isSelfTerminated;
58 bool m_enableVisualization;
61 float m_path[MAX_PATH_LENGTH*3];
63 int m_pathUpdatePeriod;
64 double m_pathUpdateTime;
66 MT_Matrix3x3 m_parentlocalmat;
67 MT_Vector3 m_steerVec;
68 void HandleActorFace(MT_Vector3& velocity);
70 enum KX_STEERINGACT_MODE
72 KX_STEERING_NODEF = 0,
75 KX_STEERING_PATHFOLLOWING,
79 KX_SteeringActuator(class SCA_IObject* gameobj,
81 KX_GameObject *target,
82 KX_GameObject *navmesh,
87 bool isSelfTerminated,
89 KX_ObstacleSimulation* simulation,
92 bool enableVisualization);
93 virtual ~KX_SteeringActuator();
94 virtual bool Update(double curtime, bool frame);
96 virtual CValue* GetReplica();
97 virtual void ProcessReplica();
98 virtual void Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map);
99 virtual bool UnlinkObject(SCA_IObject* clientobj);
100 const MT_Vector3& GetSteeringVec();
104 /* --------------------------------------------------------------------- */
105 /* Python interface ---------------------------------------------------- */
106 /* --------------------------------------------------------------------- */
108 /* These are used to get and set m_target */
109 static PyObject* pyattr_get_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
110 static int pyattr_set_target(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
111 static PyObject* pyattr_get_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
112 static int pyattr_set_navmesh(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
113 static PyObject* pyattr_get_steeringVec(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
116 #endif // WITH_PYTHON
118 }; /* end of class KX_SteeringActuator : public SCA_PropertyActuator */