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};
|
||||
Texture *diffuseTexture = new Texture(f, 1, false);
|
||||
mat->addBoolUniform("texturingEnabled", true);
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
mat->addBoolUniform("lightingEnabled", true);
|
||||
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>
|
||||
|
||||
@@ -123,7 +124,7 @@ namespace battleship{
|
||||
|
||||
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
mat->addBoolUniform("texturingEnabled", true);
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
mat->addBoolUniform("lightingEnabled", true);
|
||||
|
||||
string fr[]{texPath};
|
||||
AssetManager::getSingleton()->load(fr[0]);
|
||||
@@ -230,6 +231,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
|
||||
@@ -294,6 +296,10 @@ namespace battleship{
|
||||
for(int i = 0; i < numWaterbodies; 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
|
||||
|
||||
+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>
|
||||
@@ -291,6 +292,7 @@ namespace battleship{
|
||||
Unit::initProperties();
|
||||
initModel();
|
||||
initHitbox();
|
||||
initLosLight();
|
||||
initSound();
|
||||
initWeapons();
|
||||
placeAt(pos);
|
||||
@@ -306,6 +308,7 @@ namespace battleship{
|
||||
removeBar(hpForegroundNode);
|
||||
destroyWeapons();
|
||||
destroySound();
|
||||
destroyLosLight();
|
||||
destroyHitbox();
|
||||
destroyModel();
|
||||
}
|
||||
@@ -406,6 +409,19 @@ namespace battleship{
|
||||
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(){
|
||||
selectionSfx->stop();
|
||||
delete selectionSfx;
|
||||
|
||||
@@ -161,12 +161,14 @@ namespace battleship{
|
||||
void updateScreenCoordinates();
|
||||
void initWeapons();
|
||||
void destroyWeapons();
|
||||
void initLosLight();
|
||||
void destroyLosLight();
|
||||
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
|
||||
|
||||
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, *lightNode = nullptr;
|
||||
bool vehicle;
|
||||
protected:
|
||||
UnitClass unitClass;
|
||||
|
||||
Reference in New Issue
Block a user