2010-05-19 01:42:17 +00:00
|
|
|
/**
|
2010-05-27 20:18:56 +00:00
|
|
|
* $Id$
|
2010-05-19 01:42:17 +00:00
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
#ifndef __KX_PATHFINDER
|
|
|
|
#define __KX_PATHFINDER
|
|
|
|
#include "DetourStatNavMesh.h"
|
2010-05-27 20:18:56 +00:00
|
|
|
#include "KX_GameObject.h"
|
|
|
|
#include "PyObjectPlus.h"
|
2010-05-19 01:42:17 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class RAS_MeshObject;
|
2010-05-27 20:18:56 +00:00
|
|
|
class MT_Transform;
|
2010-05-19 01:42:17 +00:00
|
|
|
|
2010-05-31 22:35:22 +00:00
|
|
|
class KX_NavMeshObject: public KX_GameObject
|
2010-05-19 01:42:17 +00:00
|
|
|
{
|
2010-05-27 20:18:56 +00:00
|
|
|
Py_Header;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
dtStatNavMesh* m_navMesh;
|
|
|
|
|
|
|
|
bool BuildVertIndArrays(RAS_MeshObject* meshobj, float *&vertices, int& nverts,
|
|
|
|
unsigned short *&faces, int& npolys);
|
|
|
|
|
2010-05-19 01:42:17 +00:00
|
|
|
public:
|
2010-05-31 22:35:22 +00:00
|
|
|
KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks);
|
|
|
|
~KX_NavMeshObject();
|
|
|
|
|
|
|
|
virtual CValue* GetReplica();
|
|
|
|
virtual void ProcessReplica();
|
|
|
|
|
|
|
|
|
2010-05-27 20:18:56 +00:00
|
|
|
bool BuildNavMesh();
|
2010-06-07 23:09:50 +00:00
|
|
|
dtStatNavMesh* GetNavMesh();
|
2010-05-31 22:35:22 +00:00
|
|
|
int FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen);
|
|
|
|
float Raycast(const MT_Point3& from, const MT_Point3& to);
|
|
|
|
void DrawNavMesh();
|
|
|
|
void DrawPath(const float *path, int pathLen, const MT_Vector3& color);
|
2010-05-19 01:42:17 +00:00
|
|
|
|
2010-05-27 20:18:56 +00:00
|
|
|
|
|
|
|
#ifndef DISABLE_PYTHON
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* Python interface ---------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2010-05-31 22:35:22 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_NavMeshObject, findPath);
|
|
|
|
KX_PYMETHOD_DOC(KX_NavMeshObject, raycast);
|
|
|
|
KX_PYMETHOD_DOC_NOARGS(KX_NavMeshObject, draw);
|
2010-05-27 20:18:56 +00:00
|
|
|
#endif
|
2010-05-19 01:42:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__KX_PATHFINDER
|
|
|
|
|