#include "SpotLight.hpp"
#include "Scene.hpp"
#include <wren/spot_light.h>
namespace wren {
SpotLight::SpotLight() :
mIsDirectionDirty(true),
mDirectionRelative(gVec3UnitZ),
mCutOffInner(glm::quarter_pi<float>()),
mCutOffOuter(glm::quarter_pi<float>()) {
Scene::instance()->addLight(this);
}
SpotLight::~SpotLight() {
Scene::instance()->removeLight(this);
if (on() && castShadows())
--LightNode::cActiveLightsCastingShadows[TYPE_SPOT];
}
}
WrSpotLight *wr_spot_light_new() {
return reinterpret_cast<WrSpotLight *>(wren::SpotLight::createSpotLight());
}
void wr_spot_light_set_color(WrSpotLight *light, const float *color) {
reinterpret_cast<wren::SpotLight *>(light)->setColor(glm::make_vec3(color));
}
void wr_spot_light_set_intensity(WrSpotLight *light, float intensity) {
reinterpret_cast<wren::LightNode *>(light)->setIntensity(intensity);
}
void wr_spot_light_set_ambient_intensity(WrSpotLight *light, float ambient_intensity) {
reinterpret_cast<wren::LightNode *>(light)->setAmbientIntensity(ambient_intensity);
}
void wr_spot_light_set_on(WrSpotLight *light, bool on) {
reinterpret_cast<wren::LightNode *>(light)->setOn(on);
}
void wr_spot_light_set_cast_shadows(WrSpotLight *light, bool cast_shadows) {
reinterpret_cast<wren::LightNode *>(light)->setCastShadows(cast_shadows);
}
void wr_spot_light_set_attenuation(WrSpotLight *light, float attenuation_constant, float attenuation_linear,
float attenuation_quadratic) {
reinterpret_cast<wren::PositionalLight *>(light)->setAttenuation(attenuation_constant, attenuation_linear,
attenuation_quadratic);
}
void wr_spot_light_set_position_relative(WrSpotLight *light, const float *position) {
reinterpret_cast<wren::SpotLight *>(light)->setPosition(glm::make_vec3(position));
}
void wr_spot_light_set_radius(WrSpotLight *light, float radius) {
reinterpret_cast<wren::SpotLight *>(light)->setRadius(radius);
}
void wr_spot_light_set_direction(WrSpotLight *light, const float *direction) {
reinterpret_cast<wren::SpotLight *>(light)->setDirection(glm::make_vec3(direction));
}
void wr_spot_light_set_beam_width(WrSpotLight *light, float beam_width) {
reinterpret_cast<wren::SpotLight *>(light)->setBeamWidth(beam_width);
}
void wr_spot_light_set_cutoff_angle(WrSpotLight *light, float cutoff_angle) {
reinterpret_cast<wren::SpotLight *>(light)->setCutOffAngle(cutoff_angle);
}