Pre bindless
This commit is contained in:
@@ -5,7 +5,23 @@ using namespace Seele;
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene) : Actor(scene) { attachComponent<Component::DirectionalLight>(); }
|
||||
|
||||
DirectionalLightActor::DirectionalLightActor(PScene scene, Vector color, float intensity, Vector direction) : Actor(scene) {
|
||||
attachComponent<Component::DirectionalLight>(Vector4(color, intensity), Vector4(glm::normalize(direction), 0));
|
||||
attachComponent<Component::DirectionalLight>(Vector4(color, intensity));
|
||||
Vector lightDirection = Vector(direction);
|
||||
float dot = glm::dot(lightDirection, Math::Transform::FORWARD);
|
||||
Quaternion rotation = Quaternion(1, 0, 0, 0);
|
||||
// Handle the edge cases first
|
||||
if (glm::epsilonEqual(dot, 1.0f, 0.00001f)) {
|
||||
// Vectors are the same, no rotation
|
||||
} else if (glm::epsilonEqual(dot, -1.0f, 0.00001f)) {
|
||||
// Vectors are opposite need 180-degree rotation around any perpendicular axis
|
||||
rotation = glm::angleAxis(glm::pi<float>(), Vector(0, 1, 0));
|
||||
} else {
|
||||
// Normal case
|
||||
Vector axis = glm::normalize(glm::cross(lightDirection, Math::Transform::FORWARD));
|
||||
float angle = std::acos(dot); // angle between vectors
|
||||
rotation = glm::angleAxis(angle, axis);
|
||||
}
|
||||
attachComponent<Component::Transform>(Math::Transform(Vector(0, 0, 0), rotation));
|
||||
}
|
||||
|
||||
DirectionalLightActor::~DirectionalLightActor() {}
|
||||
@@ -16,4 +32,7 @@ Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent
|
||||
|
||||
const Component::DirectionalLight& DirectionalLightActor::getDirectionalLightComponent() const {
|
||||
return accessComponent<Component::DirectionalLight>();
|
||||
}
|
||||
}
|
||||
Component::Transform& DirectionalLightActor::getTransformComponent() { return accessComponent<Component::Transform>(); }
|
||||
|
||||
const Component::Transform& DirectionalLightActor::getTransformComponent() const { return accessComponent<Component::Transform>(); }
|
||||
@@ -10,6 +10,8 @@ class DirectionalLightActor : public Actor {
|
||||
virtual ~DirectionalLightActor();
|
||||
Component::DirectionalLight& getDirectionalLightComponent();
|
||||
const Component::DirectionalLight& getDirectionalLightComponent() const;
|
||||
Component::Transform& getTransformComponent();
|
||||
const Component::Transform& getTransformComponent() const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -5,11 +5,16 @@ using namespace Seele;
|
||||
PointLightActor::PointLightActor(PScene scene) : Actor(scene) { attachComponent<Component::PointLight>(); }
|
||||
|
||||
PointLightActor::PointLightActor(PScene scene, Vector position, float intensity, Vector color, float attenuation) : Actor(scene) {
|
||||
attachComponent<Component::PointLight>(Vector4(position, intensity), Vector4(color, attenuation));
|
||||
attachComponent<Component::PointLight>(color, intensity, attenuation);
|
||||
attachComponent<Component::Transform>(Math::Transform(position));
|
||||
}
|
||||
|
||||
PointLightActor::~PointLightActor() {}
|
||||
|
||||
Component::PointLight& PointLightActor::getPointLightComponent() { return accessComponent<Component::PointLight>(); }
|
||||
|
||||
const Component::PointLight& PointLightActor::getPointLightComponent() const { return accessComponent<Component::PointLight>(); }
|
||||
const Component::PointLight& PointLightActor::getPointLightComponent() const { return accessComponent<Component::PointLight>(); }
|
||||
|
||||
Component::Transform& PointLightActor::getTransformComponent() { return accessComponent<Component::Transform>(); }
|
||||
|
||||
const Component::Transform& PointLightActor::getTransformComponent() const { return accessComponent<Component::Transform>(); }
|
||||
@@ -10,6 +10,8 @@ class PointLightActor : public Actor {
|
||||
virtual ~PointLightActor();
|
||||
Component::PointLight& getPointLightComponent();
|
||||
const Component::PointLight& getPointLightComponent() const;
|
||||
Component::Transform& getTransformComponent();
|
||||
const Component::Transform& getTransformComponent() const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user