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