1 | /* |
2 | --------------------------------------------------------------------------- |
3 | Open Asset Import Library (assimp) |
4 | --------------------------------------------------------------------------- |
5 | |
6 | Copyright (c) 2006-2017, assimp team |
7 | |
8 | |
9 | All rights reserved. |
10 | |
11 | Redistribution and use of this software in source and binary forms, |
12 | with or without modification, are permitted provided that the following |
13 | conditions are met: |
14 | |
15 | * Redistributions of source code must retain the above |
16 | copyright notice, this list of conditions and the |
17 | following disclaimer. |
18 | |
19 | * Redistributions in binary form must reproduce the above |
20 | copyright notice, this list of conditions and the |
21 | following disclaimer in the documentation and/or other |
22 | materials provided with the distribution. |
23 | |
24 | * Neither the name of the assimp team, nor the names of its |
25 | contributors may be used to endorse or promote products |
26 | derived from this software without specific prior |
27 | written permission of the assimp team. |
28 | |
29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
30 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
31 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
32 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
33 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
34 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
35 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
36 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
37 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
38 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
39 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
40 | --------------------------------------------------------------------------- |
41 | */ |
42 | |
43 | /** @file light.h |
44 | * @brief Defines the aiLight data structure |
45 | */ |
46 | |
47 | #pragma once |
48 | #ifndef AI_LIGHT_H_INC |
49 | #define AI_LIGHT_H_INC |
50 | |
51 | #include "types.h" |
52 | |
53 | #ifdef __cplusplus |
54 | extern "C" { |
55 | #endif |
56 | |
57 | // --------------------------------------------------------------------------- |
58 | /** Enumerates all supported types of light sources. |
59 | */ |
60 | enum aiLightSourceType |
61 | { |
62 | aiLightSource_UNDEFINED = 0x0, |
63 | |
64 | //! A directional light source has a well-defined direction |
65 | //! but is infinitely far away. That's quite a good |
66 | //! approximation for sun light. |
67 | aiLightSource_DIRECTIONAL = 0x1, |
68 | |
69 | //! A point light source has a well-defined position |
70 | //! in space but no direction - it emits light in all |
71 | //! directions. A normal bulb is a point light. |
72 | aiLightSource_POINT = 0x2, |
73 | |
74 | //! A spot light source emits light in a specific |
75 | //! angle. It has a position and a direction it is pointing to. |
76 | //! A good example for a spot light is a light spot in |
77 | //! sport arenas. |
78 | aiLightSource_SPOT = 0x3, |
79 | |
80 | //! The generic light level of the world, including the bounces |
81 | //! of all other light sources. |
82 | //! Typically, there's at most one ambient light in a scene. |
83 | //! This light type doesn't have a valid position, direction, or |
84 | //! other properties, just a color. |
85 | aiLightSource_AMBIENT = 0x4, |
86 | |
87 | //! An area light is a rectangle with predefined size that uniformly |
88 | //! emits light from one of its sides. The position is center of the |
89 | //! rectangle and direction is its normal vector. |
90 | aiLightSource_AREA = 0x5, |
91 | |
92 | /** This value is not used. It is just there to force the |
93 | * compiler to map this enum to a 32 Bit integer. |
94 | */ |
95 | #ifndef SWIG |
96 | _aiLightSource_Force32Bit = INT_MAX |
97 | #endif |
98 | }; |
99 | |
100 | // --------------------------------------------------------------------------- |
101 | /** Helper structure to describe a light source. |
102 | * |
103 | * Assimp supports multiple sorts of light sources, including |
104 | * directional, point and spot lights. All of them are defined with just |
105 | * a single structure and distinguished by their parameters. |
106 | * Note - some file formats (such as 3DS, ASE) export a "target point" - |
107 | * the point a spot light is looking at (it can even be animated). Assimp |
108 | * writes the target point as a subnode of a spotlights's main node, |
109 | * called "<spotName>.Target". However, this is just additional information |
110 | * then, the transformation tracks of the main node make the |
111 | * spot light already point in the right direction. |
112 | */ |
113 | struct aiLight |
114 | { |
115 | /** The name of the light source. |
116 | * |
117 | * There must be a node in the scenegraph with the same name. |
118 | * This node specifies the position of the light in the scene |
119 | * hierarchy and can be animated. |
120 | */ |
121 | C_STRUCT aiString mName; |
122 | |
123 | /** The type of the light source. |
124 | * |
125 | * aiLightSource_UNDEFINED is not a valid value for this member. |
126 | */ |
127 | C_ENUM aiLightSourceType mType; |
128 | |
129 | /** Position of the light source in space. Relative to the |
130 | * transformation of the node corresponding to the light. |
131 | * |
132 | * The position is undefined for directional lights. |
133 | */ |
134 | C_STRUCT aiVector3D mPosition; |
135 | |
136 | /** Direction of the light source in space. Relative to the |
137 | * transformation of the node corresponding to the light. |
138 | * |
139 | * The direction is undefined for point lights. The vector |
140 | * may be normalized, but it needn't. |
141 | */ |
142 | C_STRUCT aiVector3D mDirection; |
143 | |
144 | /** Up direction of the light source in space. Relative to the |
145 | * transformation of the node corresponding to the light. |
146 | * |
147 | * The direction is undefined for point lights. The vector |
148 | * may be normalized, but it needn't. |
149 | */ |
150 | C_STRUCT aiVector3D mUp; |
151 | |
152 | /** Constant light attenuation factor. |
153 | * |
154 | * The intensity of the light source at a given distance 'd' from |
155 | * the light's position is |
156 | * @code |
157 | * Atten = 1/( att0 + att1 * d + att2 * d*d) |
158 | * @endcode |
159 | * This member corresponds to the att0 variable in the equation. |
160 | * Naturally undefined for directional lights. |
161 | */ |
162 | float mAttenuationConstant; |
163 | |
164 | /** Linear light attenuation factor. |
165 | * |
166 | * The intensity of the light source at a given distance 'd' from |
167 | * the light's position is |
168 | * @code |
169 | * Atten = 1/( att0 + att1 * d + att2 * d*d) |
170 | * @endcode |
171 | * This member corresponds to the att1 variable in the equation. |
172 | * Naturally undefined for directional lights. |
173 | */ |
174 | float mAttenuationLinear; |
175 | |
176 | /** Quadratic light attenuation factor. |
177 | * |
178 | * The intensity of the light source at a given distance 'd' from |
179 | * the light's position is |
180 | * @code |
181 | * Atten = 1/( att0 + att1 * d + att2 * d*d) |
182 | * @endcode |
183 | * This member corresponds to the att2 variable in the equation. |
184 | * Naturally undefined for directional lights. |
185 | */ |
186 | float mAttenuationQuadratic; |
187 | |
188 | /** Diffuse color of the light source |
189 | * |
190 | * The diffuse light color is multiplied with the diffuse |
191 | * material color to obtain the final color that contributes |
192 | * to the diffuse shading term. |
193 | */ |
194 | C_STRUCT aiColor3D mColorDiffuse; |
195 | |
196 | /** Specular color of the light source |
197 | * |
198 | * The specular light color is multiplied with the specular |
199 | * material color to obtain the final color that contributes |
200 | * to the specular shading term. |
201 | */ |
202 | C_STRUCT aiColor3D mColorSpecular; |
203 | |
204 | /** Ambient color of the light source |
205 | * |
206 | * The ambient light color is multiplied with the ambient |
207 | * material color to obtain the final color that contributes |
208 | * to the ambient shading term. Most renderers will ignore |
209 | * this value it, is just a remaining of the fixed-function pipeline |
210 | * that is still supported by quite many file formats. |
211 | */ |
212 | C_STRUCT aiColor3D mColorAmbient; |
213 | |
214 | /** Inner angle of a spot light's light cone. |
215 | * |
216 | * The spot light has maximum influence on objects inside this |
217 | * angle. The angle is given in radians. It is 2PI for point |
218 | * lights and undefined for directional lights. |
219 | */ |
220 | float mAngleInnerCone; |
221 | |
222 | /** Outer angle of a spot light's light cone. |
223 | * |
224 | * The spot light does not affect objects outside this angle. |
225 | * The angle is given in radians. It is 2PI for point lights and |
226 | * undefined for directional lights. The outer angle must be |
227 | * greater than or equal to the inner angle. |
228 | * It is assumed that the application uses a smooth |
229 | * interpolation between the inner and the outer cone of the |
230 | * spot light. |
231 | */ |
232 | float mAngleOuterCone; |
233 | |
234 | /** Size of area light source. */ |
235 | C_STRUCT aiVector2D mSize; |
236 | |
237 | #ifdef __cplusplus |
238 | |
239 | aiLight() |
240 | : mType (aiLightSource_UNDEFINED) |
241 | , mAttenuationConstant (0.f) |
242 | , mAttenuationLinear (1.f) |
243 | , mAttenuationQuadratic (0.f) |
244 | , mAngleInnerCone ((float)AI_MATH_TWO_PI) |
245 | , mAngleOuterCone ((float)AI_MATH_TWO_PI) |
246 | , mSize (0.f, 0.f) |
247 | { |
248 | } |
249 | |
250 | #endif |
251 | }; |
252 | |
253 | #ifdef __cplusplus |
254 | } |
255 | #endif |
256 | |
257 | |
258 | #endif // !! AI_LIGHT_H_INC |
259 | |