light.h 7.7 KB

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