diff --git a/activeGameState.cpp b/activeGameState.cpp index 9d9e9d4..57a4d44 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -254,7 +254,7 @@ namespace battleship{ vector results; Vector3 rayDir = (endPos - camPos).norm(); - Ray::retrieveCollisions(camPos, rayDir, map->getWaterNode(), results); + Ray::retrieveCollisions(camPos, rayDir, map->getNodeParent(), results); std::map unitData; Ray::sortResults(results); diff --git a/map.cpp b/map.cpp index 53ab60b..8200a61 100755 --- a/map.cpp +++ b/map.cpp @@ -66,6 +66,7 @@ namespace battleship{ mat->addTexUniform("textures[0]", t, true); model->setMaterial(mat); root->getRootNode()->attachChild(model); + nodeParent->attachChild(model); } void Map::loadWaterbodies(LuaManager *luaManager){ @@ -89,7 +90,7 @@ namespace battleship{ mat->addTexUniform("textures[0]", t, true); quad->setMaterial(mat); - waterNode = new Node(); + Node *waterNode = new Node(); waterNode->attachMesh(quad); root->getRootNode()->attachChild(waterNode); float posX = luaManager->getFloatFromTable(table, vector{Index("posX", true)}); @@ -97,6 +98,7 @@ namespace battleship{ float posZ = luaManager->getFloatFromTable(table, vector{Index("posZ", true)}); waterNode->setPosition(Vector3(posX, posY, posZ)); waterNode->setOrientation(Quaternion(-1.57, Vector3::VEC_I)); + nodeParent->attachChild(waterNode); } } @@ -104,13 +106,15 @@ namespace battleship{ LuaManager *luaManager = LuaManager::getSingleton(); luaManager->buildScript(vector{GameManager::getSingleton()->getPath() + "Models/Maps/" + mapName + "/" + mapName + ".lua"}); + nodeParent = new Node(); + Root *root = Root::getSingleton(); + root->getRootNode()->attachChild(nodeParent); + loadSkybox(luaManager); loadTerrain(luaManager); loadWaterbodies(luaManager); - generateCells(); - - Camera *cam = Root::getSingleton()->getCamera(); + Camera *cam = root->getCamera(); cam->setPosition(Vector3(1, 1, 1) * 10); cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm()); } diff --git a/map.h b/map.h index 5da0b39..d362a1c 100755 --- a/map.h +++ b/map.h @@ -25,13 +25,13 @@ namespace battleship{ void update(); void load(); void unload(); - inline vb01::Node* getWaterNode(){return waterNode;} + inline vb01::Node* getNodeParent(){return nodeParent;} private: - vb01::Node *waterNode = nullptr; - std::string mapName; - float cellSize = 1; - GraphNode*** cells = nullptr; - int **weights = nullptr; + vb01::Node *nodeParent = nullptr; + std::string mapName; + float cellSize = 1; + GraphNode*** cells = nullptr; + int **weights = nullptr; void loadSkybox(gameBase::LuaManager*); void loadTerrain(gameBase::LuaManager*); diff --git a/pathfinder.cpp b/pathfinder.cpp index 9a42d86..8d9abbc 100644 --- a/pathfinder.cpp +++ b/pathfinder.cpp @@ -40,6 +40,7 @@ namespace battleship{ vertStrich = i; initVertStrichSet = true; } + if(initVertStrichSet && (distances[vertStrich] > distances[i])) vertStrich = i; } @@ -60,4 +61,7 @@ namespace battleship{ return paths[dest]; } + + void Pathfinder::generateWeights(u32 **weights, int &size, Vector3* verts[], Vector2 mapSize){ + } } diff --git a/pathfinder.h b/pathfinder.h index dc1f5b1..8022974 100644 --- a/pathfinder.h +++ b/pathfinder.h @@ -10,6 +10,7 @@ namespace battleship{ public: static Pathfinder* getSingleton(); std::vector findPath(vb01::u32**, int, int, int); + void generateWeights(vb01::u32**, int&, vb01::Vector3*[], vb01::Vector2); private: Pathfinder(); }; diff --git a/pathfinderTest.cpp b/pathfinderTest.cpp index 24a7d4e..37dcd7d 100644 --- a/pathfinderTest.cpp +++ b/pathfinderTest.cpp @@ -41,6 +41,9 @@ namespace battleship{ CPPUNIT_ASSERT(sumPathWeights == 9); } + void PathfinderTest::testGenerateWeights(){ + } + void PathfinderTest::setUp(){ pathfinder = Pathfinder::getSingleton(); } diff --git a/pathfinderTest.h b/pathfinderTest.h index 2cc4f09..b8aa2a2 100644 --- a/pathfinderTest.h +++ b/pathfinderTest.h @@ -15,6 +15,7 @@ namespace battleship{ public: PathfinderTest(){} void testFindPath(); + void testGenerateWeights(); void setUp(); void tearDown(); private: