weights generation first commit

This commit is contained in:
devZoGok
2022-08-13 15:43:33 +03:00
parent 0c3be67065
commit f5a3b162f3
7 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -254,7 +254,7 @@ namespace battleship{
vector<Ray::CollisionResult> results;
Vector3 rayDir = (endPos - camPos).norm();
Ray::retrieveCollisions(camPos, rayDir, map->getWaterNode(), results);
Ray::retrieveCollisions(camPos, rayDir, map->getNodeParent(), results);
std::map<Node*, Unit*> unitData;
Ray::sortResults(results);
+8 -4
View File
@@ -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>{Index("posX", true)});
@@ -97,6 +98,7 @@ namespace battleship{
float posZ = luaManager->getFloatFromTable(table, vector<Index>{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<string>{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());
}
+2 -2
View File
@@ -25,9 +25,9 @@ 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;
vb01::Node *nodeParent = nullptr;
std::string mapName;
float cellSize = 1;
GraphNode*** cells = nullptr;
+4
View File
@@ -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){
}
}
+1
View File
@@ -10,6 +10,7 @@ namespace battleship{
public:
static Pathfinder* getSingleton();
std::vector<int> findPath(vb01::u32**, int, int, int);
void generateWeights(vb01::u32**, int&, vb01::Vector3*[], vb01::Vector2);
private:
Pathfinder();
};
+3
View File
@@ -41,6 +41,9 @@ namespace battleship{
CPPUNIT_ASSERT(sumPathWeights == 9);
}
void PathfinderTest::testGenerateWeights(){
}
void PathfinderTest::setUp(){
pathfinder = Pathfinder::getSingleton();
}
+1
View File
@@ -15,6 +15,7 @@ namespace battleship{
public:
PathfinderTest(){}
void testFindPath();
void testGenerateWeights();
void setUp();
void tearDown();
private: