CSEngine
Loading...
Searching...
No Matches
CSE::RenderComponent Class Reference
Inheritance diagram for CSE::RenderComponent:
CSE::SComponent CSE::SIRender CSE::SObject CSE::SISComponent CSE::VariableBinder CSE::ReflectionObject

Public Member Functions

 COMPONENT_DEFINE_CONSTRUCTOR (RenderComponent)
 
void Exterminate () override
 
void Init () override
 
void Tick (float elapsedTime) override
 
SComponentClone (SGameObject *object) override
 
void SetMatrix (const CameraMatrixStruct &cameraMatrixStruct, const GLProgramHandle *handle) override
 
void Render (const GLProgramHandle *handle) const override
 
void SetIsEnable (bool is_enable) override
 
SMaterialGetMaterial () const override
 
void SetMaterial (SMaterial *material)
 
void SetValue (std::string name_str, Arguments value) override
 
std::string PrintValue () const override
 
- Public Member Functions inherited from CSE::SComponent
 SComponent (std::string classType, SGameObject *gameObject)
 
 SComponent (SGameObject *gameObject)
 
 SComponent (const SComponent &src)
 
void Start () override
 
virtual void CopyReference (SComponent *src, std::map< SGameObject *, SGameObject * > lists_obj, std::map< SComponent *, SComponent * > lists_comp)
 
virtual auto GetComponent () -> SObject *
 
void SetValue (std::string name_str, Arguments value) override
 
std::string PrintValue () const override
 
void SetGameObject (SGameObject *object)
 
virtual SGameObjectGetGameObject () const
 
virtual bool GetIsEnable () const
 
- Public Member Functions inherited from CSE::SObject
 SObject (bool isRegister)
 
virtual void SetUndestroyable (bool enable)
 
virtual void Destroy ()
 
std::string GetHash () const
 
virtual void SetHash (std::string &hash)
 
- Public Member Functions inherited from CSE::SISComponent
 SISComponent (const SISComponent &src)=default
 
- Public Member Functions inherited from CSE::VariableBinder
- Public Member Functions inherited from CSE::ReflectionObject
 ReflectionObject (std::string type)
 
void SetClassType (std::string type)
 
const char * GetClassType () const
 
bool IsSameClass (const char *classType) const
 
- Public Member Functions inherited from CSE::SIRender
SMaterialGetMaterialReference () const
 

Additional Inherited Members

- Static Public Member Functions inherited from CSE::ReflectionObject
static ReflectionObjectNewObject (const std::string &name)
 
- Public Attributes inherited from CSE::SIRender
bool isRenderActive = false
 
- Protected Types inherited from CSE::VariableBinder
typedef std::vector< std::string > Arguments
 
- Protected Member Functions inherited from CSE::VariableBinder
- Protected Attributes inherited from CSE::SComponent
SGameObjectgameObject = nullptr
 
bool isEnable = true
 
- Protected Attributes inherited from CSE::SObject
std::string m_hash
 
- Protected Attributes inherited from CSE::ReflectionObject
std::string m_class
 
- Protected Attributes inherited from CSE::SIRender
SMaterialmaterial = nullptr
 

Detailed Description

Definition at line 15 of file RenderComponent.h.

Member Function Documentation

◆ Clone()

SComponent * RenderComponent::Clone ( SGameObject * object)
overridevirtual

Reimplemented from CSE::SComponent.

Definition at line 85 of file RenderComponent.cpp.

85 {
86 INIT_COMPONENT_CLONE(RenderComponent, clone);
87
88 clone->isRenderActive = isRenderActive;
89 clone->SetMaterial(material);
90
91 return clone;
92}

◆ Exterminate()

void RenderComponent::Exterminate ( )
overridevirtual

Implements CSE::SObject.

Definition at line 20 of file RenderComponent.cpp.

20 {
21 if (material != nullptr) {
22 const auto& mode = material->GetMode();
23 if (m_renderMgr != nullptr) {
24 m_renderMgr->Remove(this, (RenderContainer::RenderGroupMode) mode);
25 m_renderMgr->Remove(this, RenderContainer::DEPTH_ONLY);
26 }
27 }
28 SAFE_DELETE(m_material_clone);
29 material = nullptr;
30}

◆ GetMaterial()

SMaterial * RenderComponent::GetMaterial ( ) const
overridevirtual

Implements CSE::SIRender.

Definition at line 100 of file RenderComponent.cpp.

100 {
101 return m_material_clone;
102}

◆ Init()

void RenderComponent::Init ( )
overridevirtual

Implements CSE::SISComponent.

Definition at line 32 of file RenderComponent.cpp.

32 {
33
34 if (!m_disableShadow) {
35 m_renderMgr->Register(this, RenderContainer::DEPTH_ONLY);
36 }
37
38 m_mesh = gameObject->GetComponent<DrawableStaticMeshComponent>();
39 //TODO: 반드시 리플렉션 시스템에서 상속 문제도 해결할 수 있도록! 2222
40 if (m_mesh == nullptr) m_mesh = gameObject->GetComponent<DrawableSkinnedMeshComponent>();
41 if (m_mesh != nullptr) {
42 m_skinningMesh = dynamic_cast<DrawableSkinnedMeshComponent*>(m_mesh);
43 }
44
45 if (material == nullptr) {
46 isEnable = isRenderActive = false;
47 }
48
49 isRenderActive = isEnable;
50}

◆ PrintValue()

std::string RenderComponent::PrintValue ( ) const
overridevirtual

Implements CSE::VariableBinder.

Definition at line 127 of file RenderComponent.cpp.

127 {
128 PRINT_START("component");
129
130 PRINT_RES(material);
131
132 PRINT_END("component");
133}

◆ Render()

void RenderComponent::Render ( const GLProgramHandle * handle) const
overridevirtual

Implements CSE::SIRender.

Definition at line 71 of file RenderComponent.cpp.

71 {
72
73 if (m_mesh == nullptr || m_material_clone == nullptr || gameObject->isPrefab()) return;
74
75 SetJointMatrix(handle);
76 ShaderUtil::BindAttributeToShader(*handle, m_mesh->GetMeshID());
77}
static void BindAttributeToShader(const GLProgramHandle &handle, const GLMeshID &meshId)
Binds the attributes to the shader.

◆ SetIsEnable()

void RenderComponent::SetIsEnable ( bool is_enable)
overridevirtual

Reimplemented from CSE::SComponent.

Definition at line 79 of file RenderComponent.cpp.

79 {
80 SComponent::SetIsEnable(is_enable);
81
82 isRenderActive = isEnable;
83}

◆ SetMaterial()

void RenderComponent::SetMaterial ( SMaterial * material)

Definition at line 104 of file RenderComponent.cpp.

104 {
105 auto renderMgr = CORE->GetCore(RenderMgr);
106 if (this->material == nullptr)
107 this->material = SResource::Create<SMaterial>(Settings::GetDefaultDeferredMaterialId());
108 else {
109 const auto& mode = this->material->GetMode();
110 renderMgr->Remove(this, (RenderContainer::RenderGroupMode) mode);
111 this->material = material;
112 }
113
114 const auto& mode = this->material->GetMode();
115 renderMgr->Register(this, (RenderContainer::RenderGroupMode) mode);
116
117 SAFE_DELETE(m_material_clone)
118 m_material_clone = new SMaterial(this->material);
119}
Class for managing rendering operations.
Definition RenderMgr.h:24

◆ SetMatrix()

void RenderComponent::SetMatrix ( const CameraMatrixStruct & cameraMatrixStruct,
const GLProgramHandle * handle )
overridevirtual

Implements CSE::SIRender.

Definition at line 65 of file RenderComponent.cpp.

65 {
66 ShaderUtil::BindCameraToShader(*handle, cameraMatrixStruct.camera, cameraMatrixStruct.cameraPosition,
67 cameraMatrixStruct.projection,
68 static_cast<const TransformComponent*>(gameObject->GetTransform())->GetMatrix());
69}
static void BindCameraToShader(const GLProgramHandle &handle, const mat4 &camera, const vec3 &cameraPosition, const mat4 &projection, const mat4 &transform)
Binds the camera data to the shader.

◆ SetValue()

void RenderComponent::SetValue ( std::string name_str,
Arguments value )
overridevirtual

Used to get serialized values. All classes that inherit from VariableBinder will unconditionally call this function first during initialization.

Parameters
name_strName of values
valueSerialized values

Implements CSE::VariableBinder.

Definition at line 121 of file RenderComponent.cpp.

121 {
122 if (name_str == "material") {
123 SetMaterial(SResource::Create<SMaterial>(value[0]));
124 }
125}

◆ Tick()

void RenderComponent::Tick ( float elapsedTime)
overridevirtual

Implements CSE::SISComponent.

Definition at line 52 of file RenderComponent.cpp.

52 {
53
54 if (m_mesh == nullptr) {
55 m_mesh = gameObject->GetComponent<DrawableStaticMeshComponent>();
56 //TODO: 반드시 리플렉션 시스템에서 상속 문제도 해결할 수 있도록!
57 if (m_mesh == nullptr) m_mesh = gameObject->GetComponent<DrawableSkinnedMeshComponent>();
58 if (m_mesh != nullptr) {
59 m_skinningMesh = dynamic_cast<DrawableSkinnedMeshComponent*>(m_mesh);
60 }
61 }
62}

The documentation for this class was generated from the following files: