Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 #ifndef __KX_NAVMESHOBJECT 00028 #define __KX_NAVMESHOBJECT 00029 #include "DetourStatNavMesh.h" 00030 #include "KX_GameObject.h" 00031 #include "PyObjectPlus.h" 00032 #include <vector> 00033 00034 class RAS_MeshObject; 00035 class MT_Transform; 00036 00037 class KX_NavMeshObject: public KX_GameObject 00038 { 00039 Py_Header 00040 00041 protected: 00042 dtStatNavMesh* m_navMesh; 00043 00044 bool BuildVertIndArrays(float *&vertices, int& nverts, 00045 unsigned short* &polys, int& npolys, unsigned short *&dmeshes, 00046 float *&dvertices, int &ndvertsuniq, unsigned short* &dtris, 00047 int& ndtris, int &vertsPerPoly); 00048 00049 public: 00050 KX_NavMeshObject(void* sgReplicationInfo, SG_Callbacks callbacks); 00051 ~KX_NavMeshObject(); 00052 00053 virtual CValue* GetReplica(); 00054 virtual void ProcessReplica(); 00055 00056 00057 bool BuildNavMesh(); 00058 dtStatNavMesh* GetNavMesh(); 00059 int FindPath(const MT_Point3& from, const MT_Point3& to, float* path, int maxPathLen); 00060 float Raycast(const MT_Point3& from, const MT_Point3& to); 00061 00062 enum NavMeshRenderMode {RM_WALLS, RM_POLYS, RM_TRIS, RM_MAX}; 00063 void DrawNavMesh(NavMeshRenderMode mode); 00064 void DrawPath(const float *path, int pathLen, const MT_Vector3& color); 00065 00066 MT_Point3 TransformToLocalCoords(const MT_Point3& wpos); 00067 MT_Point3 TransformToWorldCoords(const MT_Point3& lpos); 00068 #ifndef DISABLE_PYTHON 00069 /* --------------------------------------------------------------------- */ 00070 /* Python interface ---------------------------------------------------- */ 00071 /* --------------------------------------------------------------------- */ 00072 00073 KX_PYMETHOD_DOC(KX_NavMeshObject, findPath); 00074 KX_PYMETHOD_DOC(KX_NavMeshObject, raycast); 00075 KX_PYMETHOD_DOC(KX_NavMeshObject, draw); 00076 KX_PYMETHOD_DOC_NOARGS(KX_NavMeshObject, rebuild); 00077 #endif 00078 }; 00079 00080 #endif //__KX_NAVMESHOBJECT 00081