synched with trunk at revision 30243
[blender.git] / source / gameengine / Converter / BL_BlenderDataConversion.cpp
index fa32cfd..832e33c 100644 (file)
@@ -172,6 +172,9 @@ extern "C" {
 #include "BL_ArmatureObject.h"
 #include "BL_DeformableGameObject.h"
 
+#include "KX_NavMeshObject.h"
+#include "KX_ObstacleSimulation.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -1713,6 +1716,13 @@ static KX_GameObject *gameobject_from_blenderobject(
                // needed for python scripting
                kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
        
+               if (ob->gameflag & OB_NAVMESH)
+               {
+                       gameobj = new KX_NavMeshObject(kxscene,KX_Scene::m_callbacks);
+                       gameobj->AddMesh(meshobj);
+                       break;
+               }
+                       
                gameobj = new BL_DeformableGameObject(ob,kxscene,KX_Scene::m_callbacks);
        
                // set transformation
@@ -2629,6 +2639,47 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
        converter->RegisterWorldInfo(worldinfo);
        kxscene->SetWorldInfo(worldinfo);
 
+
+       //create object representations for obstacle simulation
+       KX_ObstacleSimulation* obssimulation = kxscene->GetObstacleSimulation();
+       if (obssimulation)
+       {
+               for ( i=0;i<objectlist->GetCount();i++)
+               {
+                       KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
+                       struct Object* blenderobject = gameobj->GetBlenderObject();
+                       if (blenderobject->gameflag & OB_HASOBSTACLE)
+                       {
+                               obssimulation->AddObstacleForObj(gameobj);
+                       }
+               }
+       }
+
+       //process navigation mesh objects
+       for ( i=0; i<objectlist->GetCount();i++)
+       {
+               KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
+               struct Object* blenderobject = gameobj->GetBlenderObject();
+               if (blenderobject->type==OB_MESH && (blenderobject->gameflag & OB_NAVMESH))
+               {
+                       KX_NavMeshObject* navmesh = static_cast<KX_NavMeshObject*>(gameobj);
+                       navmesh->SetVisible(0, true);
+                       navmesh->BuildNavMesh();
+                       if (obssimulation)
+                               obssimulation->AddObstaclesForNavMesh(navmesh);
+               }
+       }
+       for ( i=0; i<inactivelist->GetCount();i++)
+       {
+               KX_GameObject* gameobj = static_cast<KX_GameObject*>(inactivelist->GetValue(i));
+               struct Object* blenderobject = gameobj->GetBlenderObject();
+               if (blenderobject->type==OB_MESH && (blenderobject->gameflag & OB_NAVMESH))
+               {
+                       KX_NavMeshObject* navmesh = static_cast<KX_NavMeshObject*>(gameobj);
+                       navmesh->SetVisible(0, true);
+               }
+       }
+
 #define CONVERT_LOGIC
 #ifdef CONVERT_LOGIC
        // convert logic bricks, sensors, controllers and actuators
@@ -2669,6 +2720,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
 
        logicbrick_conversionlist->Release();
        
+
        // Calculate the scene btree -
        // too slow - commented out.
        //kxscene->SetNodeTree(tf.MakeTree());