bc8646f939bdedec3958448a0d787830fd080289
[occt.git] / src / Graphic3d / Graphic3d_CLight.hxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Graphic3d_CLight_HeaderFile
15 #define _Graphic3d_CLight_HeaderFile
16
17 #include <InterfaceGraphic_Graphic3d.hxx>
18 #include <InterfaceGraphic_Visual3d.hxx>
19 #include <Graphic3d_Vec.hxx>
20
21 //! Light definition
22 struct Graphic3d_CLight
23 {
24
25 public:
26
27   Graphic3d_Vec4     Color;       //!< light color
28   Graphic3d_Vec4     Position;    //!< light position
29   Graphic3d_Vec4     Direction;   //!< direction of directional/spot light
30   Graphic3d_Vec4     Params;      //!< packed light parameters
31   Standard_Integer   Type;        //!< Visual3d_TypeOfLightSource enumeration
32   Standard_Boolean   IsHeadlight; //!< flag to mark head light
33   Standard_ShortReal Smoothness;  //!< radius (cone angle) for point (directional) light
34   Standard_ShortReal Intensity;   //!< intensity multiplier for light
35
36   //! Const attenuation factor of positional light source
37   Standard_ShortReal  ConstAttenuation()  const { return Params.x();  }
38
39   //! Linear attenuation factor of positional light source
40   Standard_ShortReal  LinearAttenuation() const { return Params.y();  }
41
42   //! Const, Linear attenuation factors of positional light source
43   Graphic3d_Vec2      Attenuation()       const { return Params.xy(); }
44
45   //! Angle in radians of the cone created by the spot
46   Standard_ShortReal  Angle()             const { return Params.z();  }
47
48   //! Intensity distribution of the spot light, with 0..1 range.
49   Standard_ShortReal  Concentration()     const { return Params.w();  }
50
51   Standard_ShortReal& ChangeConstAttenuation()  { return Params.x();  }
52   Standard_ShortReal& ChangeLinearAttenuation() { return Params.y();  }
53   Graphic3d_Vec2&     ChangeAttenuation()       { return Params.xy(); }
54   Standard_ShortReal& ChangeAngle()             { return Params.z();  }
55   Standard_ShortReal& ChangeConcentration()     { return Params.w();  }
56
57 public:
58
59   //! Empty constructor
60   Graphic3d_CLight()
61   : Color         (1.0f, 1.0f, 1.0f, 1.0f),
62     Position      (0.0f, 0.0f, 0.0f, 1.0f),
63     Direction     (0.0f, 0.0f, 0.0f, 0.0f),
64     Params        (0.0f, 0.0f, 0.0f, 0.0f),
65     Type          (0),
66     IsHeadlight   (Standard_False),
67     Smoothness    (0.0f),
68     Intensity     (1.0f)
69   {
70     //
71   }
72
73 public:
74
75   DEFINE_STANDARD_ALLOC
76
77 };
78
79 #endif // Graphic3d_CLight_HeaderFile