Skip to content
Snippets Groups Projects
Commit 7ef6a672 authored by JonShard's avatar JonShard
Browse files

Added angular velocity to direcional light.

parent 57d17165
No related branches found
No related tags found
No related merge requests found
...@@ -240,6 +240,7 @@ hasSun: 1 ...@@ -240,6 +240,7 @@ hasSun: 1
dirlight: distantSunLight dirlight: distantSunLight
rotation: 0 0 0 rotation: 0 0 0
angleVelocity: 0 0 0
intensities: 0.222 0.432 0.534 intensities: 0.222 0.432 0.534
relations: 27 relations: 27
......
...@@ -21,6 +21,7 @@ public: ...@@ -21,6 +21,7 @@ public:
EntityDirectionalLight(C::Tag tag, EntityDirectionalLight(C::Tag tag,
int id, int id,
glm::vec3 rotation, glm::vec3 rotation,
glm::vec3 angVel,
glm::vec3 intensities) glm::vec3 intensities)
:Entity(tag, :Entity(tag,
id, id,
...@@ -28,7 +29,7 @@ public: ...@@ -28,7 +29,7 @@ public:
rotation, rotation,
glm::vec3(0), glm::vec3(0),
glm::vec3(0), glm::vec3(0),
glm::vec3(0)) angVel)
,m_intensities(intensities) ,m_intensities(intensities)
{} {}
......
...@@ -35,10 +35,11 @@ namespace overkill ...@@ -35,10 +35,11 @@ namespace overkill
void EntityDirectionalLight::update(float dt, glm::mat4 parentMatrix) void EntityDirectionalLight::update(float dt, glm::mat4 parentMatrix)
{ {
m_transformMatrix = getModelMatrix(parentMatrix); m_transformMatrix = getModelMatrix(parentMatrix);
m_rotation += m_angularVelocity * dt;
//Renderer::draw(ModelSystem::getById(0), m_transformMatrix); //Renderer::draw(ModelSystem::getById(0), m_transformMatrix);
//m_rotation = glm::vec3(parentMatrix * glm::vec4(m_rotation,1.0f)); //m_rotation = glm::vec3(parentMatrix * glm::vec4(m_rotation,1.0f));
/*
LOG_DEBUG("Update()\n\nentityID %d, entiryTag %s, \nm_position %f, %f, %f\nm_rotation %f, %f, %f\nm_angVel %f, %f, %f\ndeltatime %f\n", LOG_DEBUG("Update()\n\nentityID %d, entiryTag %s, \nm_position %f, %f, %f\nm_rotation %f, %f, %f\nm_angVel %f, %f, %f\ndeltatime %f\n",
m_entityID, m_entityTag.data(), m_entityID, m_entityTag.data(),
m_position.x, m_position.y, m_position.z, m_position.x, m_position.y, m_position.z,
...@@ -48,7 +49,7 @@ namespace overkill ...@@ -48,7 +49,7 @@ namespace overkill
Util::printMatrix(parentMatrix, "ParentMatrix:"); Util::printMatrix(parentMatrix, "ParentMatrix:");
Util::printMatrix(m_transformMatrix, "TransormMatrix:"); Util::printMatrix(m_transformMatrix, "TransormMatrix:");
printf("\n\n"); printf("\n\n");
*/
if (m_childIDs.size() > 0) // If we actually have kids. if (m_childIDs.size() > 0) // If we actually have kids.
{ {
......
...@@ -441,7 +441,7 @@ int Scene::m_lightsCount; ...@@ -441,7 +441,7 @@ int Scene::m_lightsCount;
bool hasSun; bool hasSun;
if (auto[key, sunToggle, err] = p.keyInteger("hasSun"); err) if (auto[key, sunToggle, err] = p.keyInteger("hasSun"); err)
{ {
LOG_ERROR("%s error on key --> %s...", filestring.c_str(), key.data()); LOG_ERROR("%s error on hasSun key --> %s...", filestring.c_str(), key.data());
} }
else else
{ {
...@@ -452,13 +452,14 @@ int Scene::m_lightsCount; ...@@ -452,13 +452,14 @@ int Scene::m_lightsCount;
if (hasSun) { if (hasSun) {
C::Tag lightTag; C::Tag lightTag;
glm::vec3 rot; glm::vec3 rot;
glm::vec3 angVel;
glm::vec3 intensities; glm::vec3 intensities;
// char entityTag. // char entityTag.
if (auto[key, light, err] = p.keyString("dirlight"); err) if (auto[key, light, err] = p.keyString("dirlight"); err)
{ {
LOG_ERROR("%s error on key --> %s...", filestring.c_str(), key.data()); LOG_ERROR("%s error dirLight tag on key --> %s...", filestring.c_str(), key.data());
} }
else else
{ {
...@@ -466,20 +467,30 @@ int Scene::m_lightsCount; ...@@ -466,20 +467,30 @@ int Scene::m_lightsCount;
LOG_INFO("%s: %s", key.data(), lightTag.data()); LOG_INFO("%s: %s", key.data(), lightTag.data());
} }
// vec3 position. // vec3 rotation.
if (auto[key, rotation, err] = p.keyVec3("rotation"); err) if (auto[key, rotation, err] = p.keyVec3("rotation"); err)
{ {
LOG_ERROR("%s error on key --> %s...", filestring.c_str(), key.data()); LOG_ERROR("%s error dirlight rotation on key --> %s...", filestring.c_str(), key.data());
} }
else else
{ {
rot = rotation; rot = rotation;
LOG_INFO("%s: (%f, %f, %f)", key.data(), rotation.x, rotation.y, rotation.z); LOG_INFO("%s: (%f, %f, %f)", key.data(), rotation.x, rotation.y, rotation.z);
} }
// vec3 angularVelocity.
if (auto[key, angleVelocity, err] = p.keyVec3("angleVelocity"); err)
{
LOG_ERROR("%s error on DirectionalLight angle velocity key --> %s...", filestring.c_str(), key.data());
}
else
{
angVel = angleVelocity;
LOG_INFO("%s: (%f, %f, %f)",key.data(), angVel.x, angVel.y, angVel.z);
}
// vec3 intensity. // vec3 intensity.
if (auto[key, intensity, err] = p.keyVec3("intensities"); err) if (auto[key, intensity, err] = p.keyVec3("intensities"); err)
{ {
LOG_ERROR("%s error on key --> %s...", filestring.c_str(), key.data()); LOG_ERROR("%s error on DirectionalLight intensities key --> %s...", filestring.c_str(), key.data());
} }
else else
{ {
...@@ -490,6 +501,7 @@ int Scene::m_lightsCount; ...@@ -490,6 +501,7 @@ int Scene::m_lightsCount;
sunEntity = new EntityDirectionalLight(lightTag, sunEntity = new EntityDirectionalLight(lightTag,
count, count,
rot, rot,
angVel,
intensities intensities
); );
} }
...@@ -497,6 +509,7 @@ int Scene::m_lightsCount; ...@@ -497,6 +509,7 @@ int Scene::m_lightsCount;
sunEntity = new EntityDirectionalLight("NOT_SUN", sunEntity = new EntityDirectionalLight("NOT_SUN",
count, count,
glm::vec3(0), glm::vec3(0),
glm::vec3(0),
glm::vec3(0) glm::vec3(0)
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment