HatchitGame
ht_light_component.h
1 
15 #pragma once
16 
17 #include <ht_shadervariablechunk.h>
18 #include <ht_meshrenderer.h>
19 #include <ht_component.h>
20 #include <ht_model.h>
21 
22 
23 namespace Hatchit {
24 
25  namespace Game {
26 
27  enum LightType
28  {
29  POINT_LIGHT,
30  SPOT_LIGHT,
31  DIRECTIONAL_LIGHT
32  };
33 
34  class LightComponent : public Component
35  {
36  public:
38 
39  virtual Core::JSON VSerialize(void) override;
40  virtual bool VDeserialize(const Core::JSON& jsonObject) override;
41 
42  void SetType(LightType lightType);
43 
44  void VOnInit() override;
45 
46  void VOnUpdate() override;
47 
48  Component* VClone() const override;
49 
50  virtual Core::Guid VGetComponentId(void) const override;
51  protected:
52 
53  void VOnEnabled() override;
54 
55  void VOnDisabled() override;
56 
57  void VOnDestroy() override;
58 
59  private:
60 
61  bool SetMeshAndMaterial(std::string meshFile, std::string materialFile);
62 
63  LightType m_lightType;
64  Graphics::MeshRenderer* m_meshRenderer;
65  Graphics::MeshHandle m_mesh;
66  Graphics::MaterialHandle m_material;
67 
68  /* Point Light Data */
69  float m_radius;
70  Math::Vector3 m_attenuation;
71 
72  /* Directional & Spot Light Data*/
73  Math::Vector3 m_direction;
74 
75  /* All Light Data */
76  Graphics::ShaderVariableChunk* m_data;
77  Math::Vector4 m_color;
78  };
79  }
80 }
Component * VClone() const override
Creates a copy of this Component.
Definition: ht_light_component.cpp:189
void VOnEnabled() override
Called when the Component is enabled.
Definition: ht_light_component.cpp:209
void SetType(LightType lightType)
Sets the light to the specified type with proper data.
Definition: ht_light_component.cpp:105
void VOnDestroy() override
Called when the GameObject is destroyed/deleted.
Definition: ht_light_component.cpp:229
Definition: ht_component.h:42
Definition: ht_light_component.h:34
void VOnUpdate() override
Called once per frame while the GameObject is enabled.
Definition: ht_light_component.cpp:177
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_glfwkeyboard.h:21
virtual Core::JSON VSerialize(void) override
Saves light as JSON.
Definition: ht_light_component.cpp:45
virtual bool VDeserialize(const Core::JSON &jsonObject) override
Constructs light from JSON.
Definition: ht_light_component.cpp:53
void VOnInit() override
Called when the GameObject is created to initialize all values.
Definition: ht_light_component.cpp:130
virtual Core::Guid VGetComponentId(void) const override
Retrieves the id associated with this class of Component.
Definition: ht_light_component.cpp:200
void VOnDisabled() override
Called when the Component is disabled.
Definition: ht_light_component.cpp:219