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