Cafu Engine
CompLightPoint.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_GAMESYS_COMPONENT_POINT_LIGHT_HPP_INCLUDED
8 #define CAFU_GAMESYS_COMPONENT_POINT_LIGHT_HPP_INCLUDED
9 
10 #include "CompLight.hpp"
11 
12 
13 namespace cf
14 {
15  namespace GameSys
16  {
17  /// This component adds a dynamic point light source to its entity.
19  {
20  public:
21 
22  /// A variable of type int, specifically for the type of shadow that a light source casts.
23  class VarShadowTypeT : public TypeSys::VarT<int>
24  {
25  public:
26 
27  enum { NONE = 0, STENCIL };
28 
29  VarShadowTypeT(const char* Name, const int& Value, const char* Flags[]=NULL);
30 
31  // Base class overrides.
32  void GetChoices(ArrayT<std::string>& Strings, ArrayT<int>& Values) const;
33  };
34 
35 
36  /// The constructor.
38 
39  /// The copy constructor.
40  /// @param Comp The component to create a copy of.
42 
43  bool IsOn() const { return m_On.Get(); }
44  Vector3fT GetColor() const { return m_Color.Get(); }
45  float GetRadius() const { return m_Radius.Get(); }
46  bool CastsShadows() const { return m_ShadowType.Get() != VarShadowTypeT::NONE; }
47 
48 
49  // Base class overrides.
50  ComponentPointLightT* Clone() const override;
51  const char* GetName() const override { return "PointLight"; }
52  BoundingBox3fT GetCullingBB() const override;
53 
54 
55  // The TypeSys related declarations for this class.
56  const cf::TypeSys::TypeInfoT* GetType() const override { return &TypeInfo; }
57  static void* CreateInstance(const cf::TypeSys::CreateParamsT& Params);
58  static const cf::TypeSys::TypeInfoT TypeInfo;
59 
60 
61  protected:
62 
63  // The Lua API methods of this class.
64  static int toString(lua_State* LuaState);
65 
66  static const luaL_Reg MethodsList[]; ///< The list of Lua methods for this class.
67  static const char* DocClass;
68  static const cf::TypeSys::MethsDocT DocMethods[];
69  static const cf::TypeSys::VarsDocT DocVars[];
70 
71 
72  private:
73 
76  TypeSys::VarT<float> m_Radius;
77  VarShadowTypeT m_ShadowType;
78  };
79  }
80 }
81 
82 #endif
ComponentPointLightT()
The constructor.
Definition: CompLightPoint.cpp:61
ComponentPointLightT * Clone() const override
The virtual copy constructor.
Definition: CompLightPoint.cpp:89
The common base class for light source components.
Definition: CompLight.hpp:18
const char * GetName() const override
Returns the name of this component.
Definition: CompLightPoint.hpp:51
This is a "wrapper" around a normal C++ variable.
Definition: SetCompVar.hpp:15
A variable of type int, specifically for the type of shadow that a light source casts.
Definition: CompLightPoint.hpp:23
void GetChoices(ArrayT< std::string > &Strings, ArrayT< int > &Values) const
This method returns a list of acceptable input values for this variable, along with a string represen...
Definition: CompLightPoint.cpp:30
static const luaL_Reg MethodsList[]
The list of Lua methods for this class.
Definition: CompLightPoint.hpp:66
This component adds a dynamic point light source to its entity.
Definition: CompLightPoint.hpp:18
BoundingBox3fT GetCullingBB() const override
This method returns a bounding-box that encloses the visual representation of this component...
Definition: CompLightPoint.cpp:95
Definition: TypeSys.hpp:52
Definition: TypeSys.hpp:57
This class keeps type information (about an entity class that occurs in the game).
Definition: TypeSys.hpp:79
const T & Get() const
Returns the value of this variable.
Definition: Variables.hpp:182
Definition: TypeSys.hpp:68