2 Copyright 2004 John Tsiombikas <nuclear@siggraph.org>
4 This file is part of the 3dengfx, realtime visualization system.
6 3dengfx is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 3dengfx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with 3dengfx; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "n3dmath2/n3dmath2.hpp"
25 #include "gfx/animation.hpp"
26 #include "gfx/color.hpp"
28 #define LIGHTCOL_AMBIENT 1
29 #define LIGHTCOL_DIFFUSE 2
30 #define LIGHTCOL_SPECULAR 4
32 // abstract base class Light
33 class Light : public XFormNode {
35 Color ambient_color, diffuse_color, specular_color;
37 scalar_t attenuation[3];
44 virtual void set_color(const Color &c, unsigned short color_flags = 0);
45 virtual void set_color(const Color &amb, const Color &diff, const Color &spec);
46 virtual Color get_color(unsigned short which) const;
48 virtual void set_intensity(scalar_t intensity);
49 virtual scalar_t get_intensity() const;
51 virtual void set_attenuation(scalar_t att0, scalar_t att1, scalar_t att2);
52 virtual scalar_t get_attenuation(int which) const;
53 virtual Vector3 get_attenuation_vector() const;
55 virtual void set_shadow_casting(bool shd);
56 virtual bool casts_shadows() const;
58 virtual void set_gl_light(int n, unsigned long time = XFORM_LOCAL_PRS) const = 0;
62 class PointLight : public Light {
64 PointLight(const Vector3 &pos=Vector3(0,0,0), const Color &col=Color(1.0f, 1.0f, 1.0f));
65 virtual ~PointLight();
67 virtual void set_gl_light(int n, unsigned long time = XFORM_LOCAL_PRS) const;
70 class DirLight : public Light {
72 Vector3 dir; // actually get rid of this and work with the PRS directly?
75 DirLight(const Vector3 &dir=Vector3(0, 0, 1), const Color &col=Color(1.0f, 1.0f, 1.0f));
78 Vector3 get_direction();
80 virtual void set_gl_light(int n, unsigned long time = XFORM_LOCAL_PRS) const;