source: trunk/src/light.cpp @ 2370

Last change on this file since 2370 was 2289, checked in by sam, 7 years ago

easymesh: interface the shiny shader with new Light objects.

File size: 1.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstring>
16#include <cstdlib>
17
18#include "core.h"
19
20namespace lol
21{
22
23Light::Light()
24  : m_color(1.f),
25    m_directional(true)
26{
27    m_gamegroup = GAMEGROUP_BEFORE;
28    m_drawgroup = DRAWGROUP_CAMERA;
29
30    SetPosition(vec4(0.f));
31}
32
33Light::~Light()
34{
35}
36
37void Light::SetPosition(vec4 const &pos)
38{
39    m_directional = (pos.w > 0.f);
40    m_position = pos.xyz;
41}
42
43vec4 Light::GetPosition()
44{
45    return vec4(m_position, m_directional ? 1.f : 0.f);
46}
47
48void Light::SetColor(vec4 const &color)
49{
50    m_color = color;
51}
52
53vec4 Light::GetColor()
54{
55    return m_color;
56}
57
58void Light::TickGame(float seconds)
59{
60    WorldEntity::TickGame(seconds);
61}
62
63void Light::TickDraw(float seconds)
64{
65    WorldEntity::TickDraw(seconds);
66
67    Scene::GetDefault()->AddLight(this);
68}
69
70} /* namespace lol */
71
Note: See TracBrowser for help on using the repository browser.