exporting lighting data

This commit is contained in:
devZoGok
2024-09-13 20:20:06 +03:00
parent bd0c4a4f55
commit 999bd77d8f
3 changed files with 29 additions and 5 deletions
+10 -2
View File
@@ -101,8 +101,8 @@ namespace battleship{
light->setColor(Vector3(colTbl["x"], colTbl["y"], colTbl["z"]));
Node *lightNode = new Node();
lights.push_back(lightNode);
lightNode->addLight(light);
lights.push_back(light);
if(type == Light::Type::DIRECTIONAL){
sol::table dirTbl = lightsTbl[id]["dir"];
@@ -332,7 +332,15 @@ namespace battleship{
for(int i = 0; i < numWaterbodies; i++)
loadTerrainObject(i);
}
else{
Light *light = new Light(Light::Type::AMBIENT);
light->setColor(Vector3::VEC_IJK * .9);
Node *node = new Node();
node->addLight(light);
Root::getSingleton()->getRootNode()->attachChild(node);
lights.push_back(node);
}
}
//TODO unload skybox assets
@@ -342,7 +350,7 @@ namespace battleship{
void Map::unloadLights(){
while(!lights.empty()){
Root::getSingleton()->getRootNode()->removeLight(lights[0]);
Root::getSingleton()->getRootNode()->dettachChild(lights[0]);
delete lights[0];
lights.erase(lights.begin());
}
+3 -2
View File
@@ -12,7 +12,6 @@ namespace vb01{
class Model;
class Material;
class Node;
class Light;
}
namespace battleship{
@@ -60,6 +59,8 @@ namespace battleship{
inline vb01::Vector3 getMapSize(){return mapSize;}
inline void addSpawnPoint(vb01::Vector3 sp){spawnPoints.push_back(sp);}
inline std::vector<Map::Cell>& getCells(){return cells;}
inline vb01::Node* getLight(int i){return lights[i];}
inline std::vector<vb01::Node*> getLights(){return lights;}
private:
std::string mapTable = "map";
vb01::Node *terrainNode = nullptr, *cellNode = nullptr;
@@ -68,7 +69,7 @@ namespace battleship{
vb01::Vector3 CELL_SIZE = vb01::Vector3(7, 7, 7), mapSize;
std::vector<vb01::Vector3> spawnPoints;
std::vector<Cell> cells;
std::vector<vb01::Light*> lights;
std::vector<vb01::Node*> lights;
Map(){}
void preprareScene();
+16 -1
View File
@@ -14,6 +14,7 @@
#include <text.h>
#include <node.h>
#include <quad.h>
#include <light.h>
#include <model.h>
#include <texture.h>
#include <assetManager.h>
@@ -394,7 +395,21 @@ namespace battleship{
vector<Player*> players = Game::getSingleton()->getPlayers();
Vector3 mapSize = map->getMapSize();
string mapScript = "map = {\nnumWaterBodies = " + to_string(numWaterBodies) + ",\n";
string mapScript = "map = {\nlights = {\n";
for(Node *light : map->getLights()){
mapScript += "{type = " + to_string((int)light->getLight(0)->getType());
if(light->getLight(0)->getLightType() == Light::Type::DIRECTIONAL){
Vector3 dir = light->getGlobalAxis(2);
mapScript += ", dir = {x = " + to_string(dir.x) + ", y = " + to_string(dir.y) + "z = " + to_string(dir.z) + "}";
}
Vector3 color = light->getLight(0)->getColor();
mapScript += ", color = {x = " + to_string(color.x) + ", y = " + to_string(color.y) + ", z = " + to_string(color.z) + "}},";
}
mapScript += "}\nnumWaterBodies = " + to_string(numWaterBodies) + ",\n";
mapScript += "size = {x = " + to_string(mapSize.x) + ", y = 100, z = " + to_string(mapSize.z) + "},\n";
mapScript += "impassibleNodeValue = " + to_string(IMPASS_NODE_VAL) + ",\n";
mapScript += "numPlayers = " + to_string(players.size()) + ",\n";