2011-10-23 17:52:20 +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 *****
|
|
|
|
*/
|
2012-02-23 10:41:31 +00:00
|
|
|
#ifndef __KX_NAVMESHOBJECT_H__
|
|
|
|
#define __KX_NAVMESHOBJECT_H__
|
2010-05-19 01:42:17 +00:00
|
|
|
#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
|
|
|
{
|
2011-11-06 01:39:36 +00:00
|
|
|
Py_Header
|
2010-05-27 20:18:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
dtStatNavMesh* m_navMesh;
|
|
|
|
|
2010-07-27 21:01:00 +00:00
|
|
|
bool BuildVertIndArrays(float *&vertices, int& nverts,
|
2010-07-09 22:22:51 +00:00
|
|
|
unsigned short* &polys, int& npolys, unsigned short *&dmeshes,
|
|
|
|
float *&dvertices, int &ndvertsuniq, unsigned short* &dtris,
|
|
|
|
int& ndtris, int &vertsPerPoly);
|
|
|
|
|
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);
|
2010-07-15 18:41:29 +00:00
|
|
|
|
2010-07-21 09:16:27 +00:00
|
|
|
enum NavMeshRenderMode {RM_WALLS, RM_POLYS, RM_TRIS, RM_MAX};
|
2010-07-15 18:41:29 +00:00
|
|
|
void DrawNavMesh(NavMeshRenderMode mode);
|
2010-05-31 22:35:22 +00:00
|
|
|
void DrawPath(const float *path, int pathLen, const MT_Vector3& color);
|
2010-05-19 01:42:17 +00:00
|
|
|
|
2010-07-09 22:22:51 +00:00
|
|
|
MT_Point3 TransformToLocalCoords(const MT_Point3& wpos);
|
|
|
|
MT_Point3 TransformToWorldCoords(const MT_Point3& lpos);
|
2012-03-08 03:05:57 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2010-05-27 20:18:56 +00:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* Python interface ---------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2010-05-31 22:35:22 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_NavMeshObject, findPath);
|
|
|
|
KX_PYMETHOD_DOC(KX_NavMeshObject, raycast);
|
2010-07-15 18:41:29 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_NavMeshObject, draw);
|
|
|
|
KX_PYMETHOD_DOC_NOARGS(KX_NavMeshObject, rebuild);
|
2012-10-09 13:36:42 +00:00
|
|
|
#endif /* WITH_PYTHON */
|
2010-05-19 01:42:17 +00:00
|
|
|
};
|
|
|
|
|
2012-10-09 13:36:42 +00:00
|
|
|
#endif /* __KX_NAVMESHOBJECT_H__ */
|