SLight.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __S_LIGHT_H_INCLUDED__
  5. #define __S_LIGHT_H_INCLUDED__
  6. #include "SColor.h"
  7. namespace irr
  8. {
  9. namespace video
  10. {
  11. //! Enumeration for different types of lights
  12. enum E_LIGHT_TYPE
  13. {
  14. //! point light, it has a position in space and radiates light in all directions
  15. ELT_POINT,
  16. //! spot light, it has a position in space, a direction, and a limited cone of influence
  17. ELT_SPOT,
  18. //! directional light, coming from a direction from an infinite distance
  19. ELT_DIRECTIONAL,
  20. //! Only used for counting the elements of this enum
  21. ELT_COUNT
  22. };
  23. //! Names for light types
  24. const c8* const LightTypeNames[] =
  25. {
  26. "Point",
  27. "Spot",
  28. "Directional",
  29. 0
  30. };
  31. //! structure for holding data describing a dynamic point light.
  32. /** Irrlicht supports point lights, spot lights, and directional lights.
  33. */
  34. struct SLight
  35. {
  36. SLight() : AmbientColor(0.f,0.f,0.f), DiffuseColor(1.f,1.f,1.f),
  37. SpecularColor(1.f,1.f,1.f), Attenuation(1.f,0.f,0.f),
  38. OuterCone(45.f), InnerCone(0.f), Falloff(2.f),
  39. Position(0.f,0.f,0.f), Direction(0.f,0.f,1.f),
  40. Radius(100.f), Type(ELT_POINT), CastShadows(true)
  41. {}
  42. //! Ambient color emitted by the light
  43. SColorf AmbientColor;
  44. //! Diffuse color emitted by the light.
  45. /** This is the primary color you want to set. */
  46. SColorf DiffuseColor;
  47. //! Specular color emitted by the light.
  48. /** For details how to use specular highlights, see SMaterial::Shininess */
  49. SColorf SpecularColor;
  50. //! Attenuation factors (constant, linear, quadratic)
  51. /** Changes the light strength fading over distance.
  52. Can also be altered by setting the radius, Attenuation will change to
  53. (0,1.f/radius,0). Can be overridden after radius was set. */
  54. core::vector3df Attenuation;
  55. //! The angle of the spot's outer cone. Ignored for other lights.
  56. f32 OuterCone;
  57. //! The angle of the spot's inner cone. Ignored for other lights.
  58. f32 InnerCone;
  59. //! The light strength's decrease between Outer and Inner cone. Only for spot lights
  60. f32 Falloff;
  61. //! Read-ONLY! Position of the light.
  62. /** If Type is ELT_DIRECTIONAL, it is ignored. Changed via light scene node's position. */
  63. core::vector3df Position;
  64. //! Read-ONLY! Direction of the light.
  65. /** If Type is ELT_POINT, it is ignored. Changed via light scene node's rotation. */
  66. core::vector3df Direction;
  67. //! Read-ONLY! Radius of light. Everything within this radius will be lighted.
  68. /** On OpenGL light doesn't stop at radius. To get same light as in OpenGL in other drivers
  69. do set the radius to a large value like sqrt(FLT_MAX) and then set the Attenuation afterwards.
  70. */
  71. f32 Radius;
  72. //! Read-ONLY! Type of the light. Default: ELT_POINT
  73. E_LIGHT_TYPE Type;
  74. //! Read-ONLY! Does the light cast shadows?
  75. bool CastShadows:1;
  76. };
  77. } // end namespace video
  78. } // end namespace irr
  79. #endif