mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
Merge pull request #163 from devZoGok/ft-35-fog-of-war
Ft 35 fog of war
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
map = {
|
||||
lights = {
|
||||
{type = 3, color = {x = .9, y = .9, z = .9}},
|
||||
},
|
||||
numWaterBodies = 1,
|
||||
size = {x = 123.000000, y = 100, z = 123.000000},
|
||||
impassibleNodeValue = 65535,
|
||||
@@ -352,5 +355,5 @@ cells = {
|
||||
skybox = "Skybox1",
|
||||
terrain = {model = "111.xml", albedo = "111.jpg"},
|
||||
waterbodies = {
|
||||
{pos = {x = 7.296803, y = -0.948949, z = 6.370515}, size = {x = 42.873222, y = 42.948956}, albedo = "water.jpg"},}
|
||||
{pos = {x = 7.296803, y = -0.948949, z = 6.370515}, size = {x = 42.873222, y = 42.948956}, albedo = "water.png"},}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<node name="terrain">
|
||||
<node name="plane" px="0.0" py="0.0" pz="-0.0" rw="1.0" rx="0.0" ry="0.0" rz="0.0" sx="1.0" sy="1.0" sz="1.0">
|
||||
<mesh name="mesh" num_faces="20402" num_vertex_groups="0" num_shape_keys="0">
|
||||
<mesh name="mesh" num_vertex_pos="61206" num_faces="20402" num_vertex_groups="0" num_shape_keys="0">
|
||||
<vertdata px="-61.5" py="0" pz="-61.5" nx="0" ny="1" nz="0"/>
|
||||
<vertdata px="-60.282177" py="0" pz="-60.282177" nx="0" ny="1" nz="0"/>
|
||||
<vertdata px="-60.282177" py="0" pz="-61.5" nx="0" ny="1" nz="0"/>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
map = {
|
||||
lights = {
|
||||
{type = 3, color = {x = .9, y = .9, z = .9}},
|
||||
},
|
||||
numWaterBodies = 0,
|
||||
size = {x = 123.000000, y = 100, z = 123.000000},
|
||||
impassibleNodeValue = 65535,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<node name="terrain">
|
||||
<node name="plane" px="0.0" py="0.0" pz="-0.0" rw="1.0" rx="0.0" ry="0.0" rz="0.0" sx="1.0" sy="1.0" sz="1.0">
|
||||
<mesh name="mesh" num_faces="20402" num_vertex_groups="0" num_shape_keys="0">
|
||||
<mesh name="mesh" num_vertex_pos="61206" num_faces="20402" num_vertex_groups="0" num_shape_keys="0">
|
||||
<vertdata px="-61.5" py="0" pz="-61.5" nx="0" ny="1" nz="0"/>
|
||||
<vertdata px="-60.282177" py="0" pz="-60.282177" nx="0" ny="1" nz="0"/>
|
||||
<vertdata px="-60.282177" py="0" pz="-61.5" nx="0" ny="1" nz="0"/>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
map = {
|
||||
lights = {
|
||||
{type = 3, color = {x = .9, y = .9, z = .9}},
|
||||
},
|
||||
numWaterBodies = 1,
|
||||
size = {x = 1000.000000, y = 100, z = 1000.000000},
|
||||
impassibleNodeValue = 65535,
|
||||
@@ -11,7 +14,8 @@ players = {
|
||||
resourceDeposits = {
|
||||
},
|
||||
units = {
|
||||
{id = UnitId.TANK, pos = {x = -300.000000, y = 0.000000, z = -50.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TANK, pos = {x = 300.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.LAB, pos = {x = 300.000000, y = 0.000000, z = 100.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
--{id = UnitId.ENGINEER, pos = {x = -10.000000, y = 0.000000, z = -10.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.POINT_DEFENSE, pos = {x = 0.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
}
|
||||
@@ -19,21 +23,21 @@ units = {
|
||||
{
|
||||
resourceDeposits = {},
|
||||
units = {
|
||||
{id = UnitId.WAR_MECH, pos = {x = 300.000000, y = 0.000000, z = 12.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TANK, pos = {x = 400.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.POINT_DEFENSE, pos = {x = 400.000000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.SCOUT_TRANSPORT, pos = {x = 400.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.WAR_MECH, pos = {x = 300.000000, y = 0.000000, z = 220.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.TANK, pos = {x = 400.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.POINT_DEFENSE, pos = {x = 400.000000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
--{id = UnitId.SCOUT_TRANSPORT, pos = {x = 400.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.ENGINEER, pos = {x = 450.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TACTICAL_CRUISER, pos = {x = -60.000000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.CHEAP_CRUISER, pos = {x = -60.000000, y = 0.000000, z = -30.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.DEFENSIVE_CRUISER, pos = {x = -60.00000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TRANSPORT_CRUISER, pos = {x = -60.00000, y = 0.000000, z = 60.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.CHAMPION_CARRIER, pos = {x = -80.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.HEAVY_CARRIER, pos = {x = 0.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.SCOUT_TRANSPORT, pos = {x = 30.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.HOVER_TRANSPORT, pos = {x = 60.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.MISSILE_SUBMARINE, pos = {x = -40.00000, y = 0.000000, z = -50.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.STEALTH_SUBMARINE, pos = {x = -40.00000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.TACTICAL_CRUISER, pos = {x = -60.000000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.CHEAP_CRUISER, pos = {x = -60.000000, y = 0.000000, z = -30.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.DEFENSIVE_CRUISER, pos = {x = -60.00000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.TRANSPORT_CRUISER, pos = {x = -60.00000, y = 0.000000, z = 60.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.CHAMPION_CARRIER, pos = {x = -80.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.HEAVY_CARRIER, pos = {x = 0.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.SCOUT_TRANSPORT, pos = {x = 30.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.HOVER_TRANSPORT, pos = {x = 60.00000, y = 0.000000, z = -80.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.MISSILE_SUBMARINE, pos = {x = -40.00000, y = 0.000000, z = -50.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.STEALTH_SUBMARINE, pos = {x = -40.00000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
--{id = UnitId.EXTRACTOR, pos = {x = 30.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
--{id = UnitId.LAB, pos = {x = 50.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
}
|
||||
|
||||
+32
-13
@@ -225,6 +225,8 @@ namespace battleship{
|
||||
}
|
||||
|
||||
bool ActiveGameState::isGameObjSelectable(GameObject *obj, bool useDragBox){
|
||||
if(!obj->getModel()->isVisible()) return false;
|
||||
|
||||
Node *hitboxNode = obj->getHitbox();
|
||||
Box *hitbox = (Box*)hitboxNode->getMesh(0);
|
||||
|
||||
@@ -310,12 +312,6 @@ namespace battleship{
|
||||
|
||||
//TODO fix fog of war for hostile units
|
||||
void ActiveGameState::renderUnits() {
|
||||
vector<Unit*> units;
|
||||
|
||||
for (Player *p : Game::getSingleton()->getPlayers())
|
||||
for (Unit *u : p->getUnits())
|
||||
units.push_back(u);
|
||||
|
||||
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
|
||||
vector<Listbox*> listboxes{};
|
||||
vector<Checkbox*> checkboxes{};
|
||||
@@ -328,10 +324,23 @@ namespace battleship{
|
||||
guiManager->getText("wealth"),
|
||||
guiManager->getText("research")
|
||||
};
|
||||
|
||||
vector<Unit*> units;
|
||||
|
||||
for (Player *p : Game::getSingleton()->getPlayers())
|
||||
for (Unit *u : p->getUnits())
|
||||
units.push_back(u);
|
||||
|
||||
vector<Unit*> selUnits = mainPlayer->getSelectedUnits();
|
||||
|
||||
for (Unit *u : units) {
|
||||
Node *model = u->getModel();
|
||||
|
||||
if (u->getPlayer() == mainPlayer){
|
||||
if(!u->getLosLightNode()) u->initLosLight();
|
||||
|
||||
model->setVisible(true);
|
||||
|
||||
Vector2 pos = u->getScreenPos();
|
||||
string guiScreen = u->getGuiScreen();
|
||||
|
||||
@@ -341,19 +350,29 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
else{
|
||||
Vector3 rendUnPos = u->getPos();
|
||||
rendUnPos.y = 0;
|
||||
if(u->getLosLightNode()) u->destroyLosLight();
|
||||
|
||||
for (int i = 0; i < units.size() && units[i] != u && units[i]->getPlayer() == mainPlayer; i++) {
|
||||
Vector3 compUnPos = units[i]->getPos();
|
||||
compUnPos.y = 0;
|
||||
float dist = compUnPos.getDistanceFrom(rendUnPos);
|
||||
u->getNode()->setVisible(dist <= units[i]->getLineOfSight() || isInLineOfSight(compUnPos, units[i]->getLineOfSight(), u));
|
||||
model->setVisible(false);
|
||||
|
||||
for (int i = 0; i < units.size(); i++)
|
||||
if(units[i]->getPlayer() == mainPlayer){
|
||||
Vector3 obsUnitPos = units[i]->getPos();
|
||||
obsUnitPos.y = 0;
|
||||
|
||||
Vector3 compUnitPos = u->getPos();
|
||||
compUnitPos.y = 0;
|
||||
float dist = compUnitPos.getDistanceFrom(obsUnitPos);
|
||||
|
||||
if(dist <= units[i]->getLineOfSight()){
|
||||
model->setVisible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO improve this for greater accuracy
|
||||
bool ActiveGameState::isInLineOfSight(Vector3 center, float radius, Unit *u) {
|
||||
bool inside = false;
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
//TODO change unit colors after faction change
|
||||
void Engineer::hack(Order order){
|
||||
Unit *targUnit = order.targets[0].unit;
|
||||
bool withinRange = (targUnit->getPos().getDistanceFrom(pos) < hackRange);
|
||||
|
||||
Vendored
+1
-1
Submodule external/vb01 updated: 44afb4409c...63990e0ef0
+2
-1
@@ -102,7 +102,8 @@ namespace battleship{
|
||||
string f[]{albedoPath == configData::DEFAULT_TEXTURE ? GameManager::getSingleton()->getPath() + albedoPath : basePath + albedoPath};
|
||||
Texture *diffuseTexture = new Texture(f, 1, false);
|
||||
mat->addBoolUniform("texturingEnabled", true);
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
mat->addBoolUniform("lightingEnabled", true);
|
||||
mat->addBoolUniform("constLightingEnabled", false);
|
||||
mat->addTexUniform("textures[0]", diffuseTexture, true);
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <stateManager.h>
|
||||
|
||||
#include <assetManager.h>
|
||||
#include <root.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <root.h>
|
||||
#include <quad.h>
|
||||
#include <model.h>
|
||||
#include <light.h>
|
||||
#include <material.h>
|
||||
#include <assetManager.h>
|
||||
|
||||
@@ -86,6 +87,33 @@ namespace battleship{
|
||||
Root::getSingleton()->createSkybox(path);
|
||||
}
|
||||
|
||||
void Map::loadLights(){
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
sol::table lightsTbl = SOL_LUA_VIEW[mapTable]["lights"];
|
||||
int numLights = lightsTbl.size();
|
||||
|
||||
for(int i = 0; i < numLights; i++){
|
||||
int id = i + 1;
|
||||
Light::Type type = (Light::Type)lightsTbl[id]["type"];
|
||||
sol::table colTbl = lightsTbl[id]["color"];
|
||||
|
||||
Light *light = new Light(type);
|
||||
light->setColor(Vector3(colTbl["x"], colTbl["y"], colTbl["z"]));
|
||||
|
||||
Node *lightNode = new Node();
|
||||
lights.push_back(lightNode);
|
||||
lightNode->addLight(light);
|
||||
|
||||
if(type == Light::Type::DIRECTIONAL){
|
||||
sol::table dirTbl = lightsTbl[id]["dir"];
|
||||
Vector3 dir = Vector3(dirTbl["x"], dirTbl["y"], dirTbl["z"]).norm();
|
||||
lightNode->lookAt(dir);
|
||||
}
|
||||
|
||||
Root::getSingleton()->getRootNode()->attachChild(lightNode);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::loadTerrainObject(int id){
|
||||
string texPath = "", albedoPath = "";
|
||||
Quad *quad = nullptr;
|
||||
@@ -123,7 +151,11 @@ namespace battleship{
|
||||
|
||||
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
mat->addBoolUniform("texturingEnabled", true);
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
mat->addBoolUniform("lightingEnabled", true);
|
||||
mat->addBoolUniform("constLightingEnabled", true);
|
||||
mat->addBoolUniform("normalMapEnabled", false);
|
||||
mat->addBoolUniform("specularMapEnabled", false);
|
||||
mat->addBoolUniform("castShadow", false);
|
||||
|
||||
string fr[]{texPath};
|
||||
AssetManager::getSingleton()->load(fr[0]);
|
||||
@@ -230,6 +262,7 @@ namespace battleship{
|
||||
cam->setFarPlane(600);
|
||||
cam->setPosition(Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
||||
cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm());
|
||||
|
||||
}
|
||||
|
||||
//TODO implement toggleable cell rendering
|
||||
@@ -282,18 +315,32 @@ namespace battleship{
|
||||
|
||||
if(!empty){
|
||||
SOL_LUA_STATE.script_file(path + "Models/Maps/" + mapName + "/" + mapName + ".lua");
|
||||
sol::table sizeTable = SOL_LUA_STATE[mapTable]["size"];
|
||||
mapSize = Vector3(sizeTable["x"], sizeTable["y"], sizeTable["z"]);
|
||||
int numWaterbodies = SOL_LUA_STATE[mapTable]["numWaterBodies"];
|
||||
sol::optional<sol::table> lightsOpt = SOL_LUA_STATE[mapTable]["lights"];
|
||||
|
||||
if(lightsOpt != sol::nullopt)
|
||||
loadLights();
|
||||
|
||||
loadSpawnPoints();
|
||||
loadSkybox();
|
||||
loadCells();
|
||||
loadTerrainObject(-1);
|
||||
|
||||
sol::table sizeTable = SOL_LUA_STATE[mapTable]["size"];
|
||||
mapSize = Vector3(sizeTable["x"], sizeTable["y"], sizeTable["z"]);
|
||||
int numWaterbodies = SOL_LUA_STATE[mapTable]["numWaterBodies"];
|
||||
|
||||
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
|
||||
@@ -301,6 +348,14 @@ namespace battleship{
|
||||
Root::getSingleton()->removeSkybox();
|
||||
}
|
||||
|
||||
void Map::unloadLights(){
|
||||
while(!lights.empty()){
|
||||
Root::getSingleton()->getRootNode()->dettachChild(lights[0]);
|
||||
delete lights[0];
|
||||
lights.erase(lights.begin());
|
||||
}
|
||||
}
|
||||
|
||||
void Map::unloadCells(){
|
||||
while(cellNode->getNumChildren() > 0){
|
||||
Node *node = cellNode->getChild(0);
|
||||
@@ -347,6 +402,7 @@ namespace battleship{
|
||||
|
||||
void Map::unload(){
|
||||
unloadSkybox();
|
||||
unloadLights();
|
||||
unloadCells();
|
||||
unloadTerrainObjects();
|
||||
unloadPlayerObjects();
|
||||
|
||||
@@ -59,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;
|
||||
@@ -67,15 +69,18 @@ namespace battleship{
|
||||
vb01::Vector3 CELL_SIZE = vb01::Vector3(7, 7, 7), mapSize;
|
||||
std::vector<vb01::Vector3> spawnPoints;
|
||||
std::vector<Cell> cells;
|
||||
std::vector<vb01::Node*> lights;
|
||||
|
||||
Map(){}
|
||||
void preprareScene();
|
||||
void loadSpawnPoints();
|
||||
void loadLights();
|
||||
void loadSkybox();
|
||||
void loadCells();
|
||||
void loadTerrainObject(int);
|
||||
void unloadTerrainObjects();
|
||||
void unloadCells();
|
||||
void unloadLights();
|
||||
void unloadSkybox();
|
||||
void unloadPlayerObjects();
|
||||
void destroyScene();
|
||||
|
||||
+16
-1
@@ -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)->getLightType());
|
||||
|
||||
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";
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ namespace battleship{
|
||||
trader(new Trader())
|
||||
{
|
||||
colorMaterial = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
colorMaterial->addBoolUniform("lightingEnabled", false);
|
||||
colorMaterial->addBoolUniform("lightingEnabled", true);
|
||||
colorMaterial->addBoolUniform("texturingEnabled", false);
|
||||
colorMaterial->addVec4Uniform("diffuseColor", Vector4(color.x, color.y, color.z, 1));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include <model.h>
|
||||
#include <quad.h>
|
||||
#include <box.h>
|
||||
#include <quad.h>
|
||||
#include <model.h>
|
||||
#include <light.h>
|
||||
#include <texture.h>
|
||||
#include <material.h>
|
||||
#include <particleEmitter.h>
|
||||
#include <texture.h>
|
||||
|
||||
#include <stateManager.h>
|
||||
#include <solUtil.h>
|
||||
@@ -406,6 +407,25 @@ namespace battleship{
|
||||
weapons.clear();
|
||||
}
|
||||
|
||||
void Unit::initLosLight(){
|
||||
Light *light = new Light(Light::Type::POINT);
|
||||
light->setAttenuation(Light::Attenuation::NONE);
|
||||
light->setRadius(lineOfSight);
|
||||
light->setColor(Vector3::VEC_IJK * .3);
|
||||
light->setAdditiveLighting(false);
|
||||
light->setUseAngle(false);
|
||||
|
||||
losLightNode = new Node(Vector3::VEC_J * 5);
|
||||
losLightNode->addLight(light);
|
||||
model->attachChild(losLightNode);
|
||||
}
|
||||
|
||||
void Unit::destroyLosLight(){
|
||||
model->dettachChild(losLightNode);
|
||||
delete losLightNode;
|
||||
losLightNode = nullptr;
|
||||
}
|
||||
|
||||
void Unit::destroySound(){
|
||||
selectionSfx->stop();
|
||||
delete selectionSfx;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace vb01{
|
||||
class Mesh;
|
||||
class Quad;
|
||||
class Node;
|
||||
class Light;
|
||||
class Camera;
|
||||
}
|
||||
|
||||
@@ -134,6 +135,8 @@ namespace battleship{
|
||||
std::vector<Projectile*> getProjectiles();
|
||||
virtual void addOrder(Order);
|
||||
bool canGarrison(Vehicle*);
|
||||
void initLosLight();
|
||||
void destroyLosLight();
|
||||
inline void setState(State s){state = s;}
|
||||
inline Engineer* toEngineer(){return (Engineer*)this;}
|
||||
inline Structure* toStructure(){return (Structure*)this;}
|
||||
@@ -143,7 +146,6 @@ namespace battleship{
|
||||
inline int getNumGarrisonSlots(){return garrisonSlots.size();}
|
||||
inline const std::vector<GarrisonSlot>& getGarrisonSlots(){return garrisonSlots;}
|
||||
inline float getLineOfSight() {return lineOfSight;}
|
||||
inline vb01::Model* getNode() {return model;}
|
||||
inline UnitType getType() {return type;}
|
||||
inline UnitClass getUnitClass() {return unitClass;}
|
||||
inline void takeDamage(int damage) {health -= damage;}
|
||||
@@ -156,6 +158,7 @@ namespace battleship{
|
||||
inline int getNumOrders(){return orders.size();}
|
||||
inline std::string getGuiScreen(){return guiScreen;}
|
||||
inline BuildableUnit getBuildableUnit(int i){return buildableUnits[i];}
|
||||
inline vb01::Node* getLosLightNode(){return losLightNode;}
|
||||
private:
|
||||
void renderOrderLine(bool);
|
||||
void updateScreenCoordinates();
|
||||
@@ -166,7 +169,7 @@ namespace battleship{
|
||||
const int orderVecDispLength = 2000, DEATH_HP = 0;
|
||||
sf::SoundBuffer *selectionSfxBuffer;
|
||||
sf::Sound *selectionSfx = nullptr;
|
||||
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr;
|
||||
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr, *losLightNode = nullptr;
|
||||
bool vehicle;
|
||||
protected:
|
||||
UnitClass unitClass;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ namespace battleship{
|
||||
void Vehicle::update(){
|
||||
Unit::update();
|
||||
|
||||
model->setVisible(!garrisonable);
|
||||
if(garrisonable) model->setVisible(false);
|
||||
}
|
||||
|
||||
void Vehicle::halt(){
|
||||
|
||||
Reference in New Issue
Block a user