Added UniformScale component which keeps an entity's scale at a uniform value relative to the screen.

This commit is contained in:
2016-01-17 06:22:35 +01:00
parent 9f447afbdb
commit 6ec2258758
6 changed files with 68 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "Core/UniformScaleSystem.h"
UniformScaleSystem::UniformScaleSystem(EventBroker* eventBroker)
: System(eventBroker)
, PureSystem("UniformScale")
{
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &UniformScaleSystem::OnSetCamera);
}
void UniformScaleSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& cUniformScale, double dt)
{
if (!m_Camera.Valid()) {
return;
}
float distance = glm::length((glm::vec3)entity["Transform"]["Position"] - (glm::vec3&)m_Camera["Transform"]["Position"]);
entity["Transform"]["Scale"] = (glm::vec3&)cUniformScale["Scale"] * distance;
}
bool UniformScaleSystem::OnSetCamera(const Events::SetCamera& e)
{
m_Camera = e.CameraEntity;
return false;
}