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