mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
enabled lighting
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ namespace battleship{
|
|||||||
string f[]{albedoPath == configData::DEFAULT_TEXTURE ? GameManager::getSingleton()->getPath() + albedoPath : basePath + albedoPath};
|
string f[]{albedoPath == configData::DEFAULT_TEXTURE ? GameManager::getSingleton()->getPath() + albedoPath : basePath + albedoPath};
|
||||||
Texture *diffuseTexture = new Texture(f, 1, false);
|
Texture *diffuseTexture = new Texture(f, 1, false);
|
||||||
mat->addBoolUniform("texturingEnabled", true);
|
mat->addBoolUniform("texturingEnabled", true);
|
||||||
mat->addBoolUniform("lightingEnabled", false);
|
mat->addBoolUniform("lightingEnabled", true);
|
||||||
mat->addTexUniform("textures[0]", diffuseTexture, true);
|
mat->addTexUniform("textures[0]", diffuseTexture, true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
|
|
||||||
#include <assetManager.h>
|
#include <assetManager.h>
|
||||||
|
#include <root.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <root.h>
|
#include <root.h>
|
||||||
#include <quad.h>
|
#include <quad.h>
|
||||||
#include <model.h>
|
#include <model.h>
|
||||||
|
#include <light.h>
|
||||||
#include <material.h>
|
#include <material.h>
|
||||||
#include <assetManager.h>
|
#include <assetManager.h>
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ namespace battleship{
|
|||||||
|
|
||||||
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||||
mat->addBoolUniform("texturingEnabled", true);
|
mat->addBoolUniform("texturingEnabled", true);
|
||||||
mat->addBoolUniform("lightingEnabled", false);
|
mat->addBoolUniform("lightingEnabled", true);
|
||||||
|
|
||||||
string fr[]{texPath};
|
string fr[]{texPath};
|
||||||
AssetManager::getSingleton()->load(fr[0]);
|
AssetManager::getSingleton()->load(fr[0]);
|
||||||
@@ -230,6 +231,7 @@ namespace battleship{
|
|||||||
cam->setFarPlane(600);
|
cam->setFarPlane(600);
|
||||||
cam->setPosition(Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
cam->setPosition(Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
||||||
cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm());
|
cam->lookAt(Vector3(-1, -1, -1).norm(), Vector3(-1, 1, -1).norm());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement toggleable cell rendering
|
//TODO implement toggleable cell rendering
|
||||||
@@ -294,6 +296,10 @@ namespace battleship{
|
|||||||
for(int i = 0; i < numWaterbodies; i++)
|
for(int i = 0; i < numWaterbodies; i++)
|
||||||
loadTerrainObject(i);
|
loadTerrainObject(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node *lightNode = new Node(Vector3::VEC_ZERO, Quaternion(1.57, Vector3::VEC_I));
|
||||||
|
lightNode->addLight(new Light(Light::Type::DIRECTIONAL));
|
||||||
|
Root::getSingleton()->getRootNode()->attachChild(lightNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO unload skybox assets
|
//TODO unload skybox assets
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ namespace battleship{
|
|||||||
trader(new Trader())
|
trader(new Trader())
|
||||||
{
|
{
|
||||||
colorMaterial = new Material(Root::getSingleton()->getLibPath() + "texture");
|
colorMaterial = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||||
colorMaterial->addBoolUniform("lightingEnabled", false);
|
colorMaterial->addBoolUniform("lightingEnabled", true);
|
||||||
colorMaterial->addBoolUniform("texturingEnabled", false);
|
colorMaterial->addBoolUniform("texturingEnabled", false);
|
||||||
colorMaterial->addVec4Uniform("diffuseColor", Vector4(color.x, color.y, color.z, 1));
|
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 <box.h>
|
||||||
|
#include <quad.h>
|
||||||
|
#include <model.h>
|
||||||
|
#include <light.h>
|
||||||
|
#include <texture.h>
|
||||||
#include <material.h>
|
#include <material.h>
|
||||||
#include <particleEmitter.h>
|
#include <particleEmitter.h>
|
||||||
#include <texture.h>
|
|
||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
#include <solUtil.h>
|
#include <solUtil.h>
|
||||||
@@ -291,6 +292,7 @@ namespace battleship{
|
|||||||
Unit::initProperties();
|
Unit::initProperties();
|
||||||
initModel();
|
initModel();
|
||||||
initHitbox();
|
initHitbox();
|
||||||
|
initLosLight();
|
||||||
initSound();
|
initSound();
|
||||||
initWeapons();
|
initWeapons();
|
||||||
placeAt(pos);
|
placeAt(pos);
|
||||||
@@ -306,6 +308,7 @@ namespace battleship{
|
|||||||
removeBar(hpForegroundNode);
|
removeBar(hpForegroundNode);
|
||||||
destroyWeapons();
|
destroyWeapons();
|
||||||
destroySound();
|
destroySound();
|
||||||
|
destroyLosLight();
|
||||||
destroyHitbox();
|
destroyHitbox();
|
||||||
destroyModel();
|
destroyModel();
|
||||||
}
|
}
|
||||||
@@ -405,6 +408,19 @@ namespace battleship{
|
|||||||
|
|
||||||
weapons.clear();
|
weapons.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::initLosLight(){
|
||||||
|
lightNode = new Node();
|
||||||
|
Light *light = new Light(Light::Type::POINT);
|
||||||
|
//light->setAttenuationValues(1, 1, 1);
|
||||||
|
model->attachChild(lightNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unit::destroyLosLight(){
|
||||||
|
model->dettachChild(lightNode);
|
||||||
|
delete lightNode;
|
||||||
|
lightNode = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::destroySound(){
|
void Unit::destroySound(){
|
||||||
selectionSfx->stop();
|
selectionSfx->stop();
|
||||||
|
|||||||
@@ -161,12 +161,14 @@ namespace battleship{
|
|||||||
void updateScreenCoordinates();
|
void updateScreenCoordinates();
|
||||||
void initWeapons();
|
void initWeapons();
|
||||||
void destroyWeapons();
|
void destroyWeapons();
|
||||||
|
void initLosLight();
|
||||||
|
void destroyLosLight();
|
||||||
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
|
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
|
||||||
|
|
||||||
const int orderVecDispLength = 2000, DEATH_HP = 0;
|
const int orderVecDispLength = 2000, DEATH_HP = 0;
|
||||||
sf::SoundBuffer *selectionSfxBuffer;
|
sf::SoundBuffer *selectionSfxBuffer;
|
||||||
sf::Sound *selectionSfx = nullptr;
|
sf::Sound *selectionSfx = nullptr;
|
||||||
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr;
|
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr, *lightNode = nullptr;
|
||||||
bool vehicle;
|
bool vehicle;
|
||||||
protected:
|
protected:
|
||||||
UnitClass unitClass;
|
UnitClass unitClass;
|
||||||
|
|||||||
Reference in New Issue
Block a user