Files
GDevelop/Extensions/Light/Directional_light.cpp
T
Florian 7d35fc59fa Exchanged all french messages with their English counterparts.
git-svn-id: svn://localhost@844 8062f311-0dae-4547-b526-b8ab9ac864a5
2012-09-20 19:55:40 +00:00

54 lines
1.3 KiB
C++

#include "Directional_light.h"
#include <cmath>
#include <iostream>
#include <SFML/Graphics.hpp>
Directional_light::Directional_light() : Light()
{
m_angle = 0;
m_opening_angle = 0;
}
Directional_light::Directional_light(sf::Vector2f position, float intensity, float radius, float angle, float opening_angle, sf::Color colo)
: Light(position, intensity, radius, 0, colo), m_angle(angle), m_opening_angle(opening_angle)
{
}
Directional_light::~Directional_light()
{
//dtor
}
void Directional_light::Generate(std::vector<Wall*> &m_wall)
{
m_shape.clear();
float angle = m_angle * M_PI / 180;
float o_angle = m_opening_angle * M_PI / 180;
AddTriangle(sf::Vector2f((m_radius*cos(angle + o_angle * 0.5))
,(m_radius*sin(angle + o_angle * 0.5))) ,
sf::Vector2f((m_radius*cos(angle - o_angle * 0.5))
,(m_radius*sin(angle - o_angle * 0.5))),0,m_wall);
}
void Directional_light::SetAngle(float angle)
{
m_angle = angle;
}
void Directional_light::SetOpeningAngle(float angle)
{
m_opening_angle = angle;
}
void Directional_light::SetOtherParameter(unsigned n, float v)
{
if(n == ANGLE)
SetAngle(v);
else if(n == OPENING_ANGLE)
SetOpeningAngle(v);
}