Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[inkscape.git] / src / display / nr-light.h
1 #ifndef __NR_LIGHT_H__
2 #define __NR_LIGHT_H__
3 /** \file
4  * These classes provide tools to compute interesting objects relative to light
5  * sources. Each class provides a constructor converting information contained
6  * in a sp light object into information useful in the current setting, a
7  * method to get the light vector (at a given point) and a method to get the 
8  * light color components (at a given point).
9  */
11 #include <gdk/gdktypes.h>
12 #include "display/nr-3dutils.h"
13 #include "display/nr-light-types.h"
14 #include <2geom/forward.h>
16 struct SPFeDistantLight;
17 struct SPFePointLight;
18 struct SPFeSpotLight;
20 namespace Inkscape {
21 namespace Filters {
23 enum LightComponent {
24     LIGHT_RED = 0,
25     LIGHT_GREEN,
26     LIGHT_BLUE
27 };
29 class DistantLight {
30     public:
31         /**
32          * Constructor
33          *
34          * \param light the sp light object
35          * \param lighting_color the lighting_color used
36          */
37         DistantLight(SPFeDistantLight *light, guint32 lighting_color);
38         virtual ~DistantLight();
39         
40         /**
41          * Computes the light vector of the distant light
42          *
43          * \param v a Fvector referece where we store the result
44          */
45         void light_vector(NR::Fvector &v);
46         
47         /**
48          * Computes the light components of the distant light
49          *
50          * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B
51          */
52         void light_components(NR::Fvector &lc);
54     private:
55         guint32 color;
56         gdouble azimuth; //azimuth in rad
57         gdouble elevation; //elevation in rad
58 };
60 class PointLight {
61     public:
62         /**
63          * Constructor
64          *
65          * \param light the sp light object
66          * \param lighting_color the lighting_color used
67          * \param trans the transformation between absolute coordinate (those
68          * employed in the sp light object) and current coordinate (those
69          * employed in the rendering)
70          */
71         PointLight(SPFePointLight *light, guint32 lighting_color, const Geom::Matrix &trans);
72         virtual ~PointLight();
73         /**
74          * Computes the light vector of the distant light at point (x,y,z).
75          * x, y and z are given in the arena_item coordinate, they are used as
76          * is
77          *
78          * \param v a Fvector referece where we store the result
79          * \param x x coordinate of the current point
80          * \param y y coordinate of the current point
81          * \param z z coordinate of the current point
82          */
83         void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z);
84         
85         /**
86          * Computes the light components of the distant light
87          *
88          * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B
89          */
90         void light_components(NR::Fvector &lc);
92     private:
93         guint32 color;
94         //light position coordinates in render setting
95         gdouble l_x;
96         gdouble l_y;
97         gdouble l_z;
98 };
100 class SpotLight {
101     public:
102         /**
103          * Constructor
104          *
105          * \param light the sp light object
106          * \param lighting_color the lighting_color used
107          * \param trans the transformation between absolute coordinate (those
108          * employed in the sp light object) and current coordinate (those
109          * employed in the rendering)
110          */
111         SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::Matrix &trans);
112         virtual ~SpotLight();
114         /**
115          * Computes the light vector of the distant light at point (x,y,z).
116          * x, y and z are given in the arena_item coordinate, they are used as
117          * is
118          *
119          * \param v a Fvector referece where we store the result
120          * \param x x coordinate of the current point
121          * \param y y coordinate of the current point
122          * \param z z coordinate of the current point
123          */
124         void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z);
126         /**
127          * Computes the light components of the distant light at the current
128          * point. We only need the light vector to compute theses
129          *
130          * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B
131          * \param L the light vector of the current point
132          */
133         void light_components(NR::Fvector &lc, const NR::Fvector &L);
135     private:
136         guint32 color;
137         //light position coordinates in render setting
138         gdouble l_x;
139         gdouble l_y;
140         gdouble l_z;
141         gdouble cos_lca; //cos of the limiting cone angle
142         gdouble speExp; //specular exponent;
143         NR::Fvector S; //unit vector from light position in the direction
144                    //the spot point at
145 };
148 } /* namespace Filters */
149 } /* namespace Inkscape */
151 #endif // __NR_LIGHT_H__
152 /*
153   Local Variables:
154   mode:c++
155   c-file-style:"stroustrup"
156   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
157   indent-tabs-mode:nil
158   fill-column:99
159   End:
160 */
161 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :