SleakEngine 0.1.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::MaterialComponent Class Reference

#include <MaterialComponent.hpp>

Inheritance diagram for Sleak::MaterialComponent:

Public Member Functions

 MaterialComponent (GameObject *object, const RefPtr< Material > &material)
 MaterialComponent (GameObject *object, const std::string &diffuseTexture)
 MaterialComponent (GameObject *object, Material *material)
 MaterialComponent (GameObject *object, Math::Color diffuseColor=Math::Color::White)
 ~MaterialComponent () override=default
const RefPtr< Material > & GetMaterial () const
Material * GetMaterialRaw () const
bool Initialize () override
 Initializes the owned material's GPU resources.
void OnDisable () override
void OnEnable () override
void SetDiffuseColor (Math::Color color)
void SetDiffuseTexture (const std::string &path)
void SetMaterial (const RefPtr< Material > &material)
 Replaces the material, re-initializing it if the component is already initialized.
void SetMaterial (Material *material)
 Takes ownership of a raw material pointer, re-initializing it if already initialized.
void SetMetallic (float metallic)
void SetNormalTexture (const std::string &path)
void SetRoughness (float roughness)
void SetShininess (float shininess)
void Update (float DeltaTime) override
 Submits the material bind unless a sibling mesh does it.
Public Member Functions inherited from Sleak::Component
 Component (GameObject *object)
virtual ~Component ()=default
virtual void FixedUpdate (float fixedDeltaTime)
GameObject * GetOwner ()
bool IsInitialized () const
 True once Initialize() has run and succeeded.
virtual void LateUpdate (float deltaTime)
virtual void OnDestroy ()
 Called when the component is detached or the owner is destroyed.
Public Member Functions inherited from Sleak::Object
 Object (const std::string &name="Object")
virtual ~Object ()=default
std::string GetDebugName () const
 Name plus unique ID, for logs where names can repeat.
const std::string & GetName () const
uint64_t GetUniqueID () const
void SetName (const std::string &value)

Friends

class MeshComponent

Additional Inherited Members

Protected Attributes inherited from Sleak::Component
bool bIsInitialized
GameObject * owner

Detailed Description

Owns and binds a Material for rendering; submits it into the draw command queue each Update while enabled.

Definition at line 13 of file MaterialComponent.hpp.

Constructor & Destructor Documentation

◆ MaterialComponent() [1/4]

Sleak::MaterialComponent::MaterialComponent ( GameObject * object,
const RefPtr< Material > & material )

Definition at line 8 of file MaterialComponent.cpp.

◆ MaterialComponent() [2/4]

Sleak::MaterialComponent::MaterialComponent ( GameObject * object,
Material * material )

Definition at line 12 of file MaterialComponent.cpp.

◆ MaterialComponent() [3/4]

Sleak::MaterialComponent::MaterialComponent ( GameObject * object,
Math::Color diffuseColor = Math::Color::White )

Definition at line 21 of file MaterialComponent.cpp.

◆ MaterialComponent() [4/4]

Sleak::MaterialComponent::MaterialComponent ( GameObject * object,
const std::string & diffuseTexture )

Definition at line 29 of file MaterialComponent.cpp.

◆ ~MaterialComponent()

Sleak::MaterialComponent::~MaterialComponent ( )
overridedefault

Member Function Documentation

◆ GetMaterial()

const RefPtr< Material > & Sleak::MaterialComponent::GetMaterial ( ) const

Definition at line 83 of file MaterialComponent.cpp.

◆ GetMaterialRaw()

Material * Sleak::MaterialComponent::GetMaterialRaw ( ) const

Definition at line 87 of file MaterialComponent.cpp.

◆ Initialize()

bool Sleak::MaterialComponent::Initialize ( )
overridevirtual

Initializes the owned material's GPU resources.

Implements Sleak::Component.

Definition at line 37 of file MaterialComponent.cpp.

◆ OnDisable()

void Sleak::MaterialComponent::OnDisable ( )
overridevirtual

Reimplemented from Sleak::Component.

Definition at line 62 of file MaterialComponent.cpp.

◆ OnEnable()

void Sleak::MaterialComponent::OnEnable ( )
overridevirtual

Reimplemented from Sleak::Component.

Definition at line 60 of file MaterialComponent.cpp.

◆ SetDiffuseColor()

void Sleak::MaterialComponent::SetDiffuseColor ( Math::Color color)

Definition at line 91 of file MaterialComponent.cpp.

◆ SetDiffuseTexture()

void Sleak::MaterialComponent::SetDiffuseTexture ( const std::string & path)

Definition at line 96 of file MaterialComponent.cpp.

◆ SetMaterial() [1/2]

void Sleak::MaterialComponent::SetMaterial ( const RefPtr< Material > & material)

Replaces the material, re-initializing it if the component is already initialized.

Definition at line 64 of file MaterialComponent.cpp.

◆ SetMaterial() [2/2]

void Sleak::MaterialComponent::SetMaterial ( Material * material)

Takes ownership of a raw material pointer, re-initializing it if already initialized.

Definition at line 72 of file MaterialComponent.cpp.

◆ SetMetallic()

void Sleak::MaterialComponent::SetMetallic ( float metallic)

Definition at line 113 of file MaterialComponent.cpp.

◆ SetNormalTexture()

void Sleak::MaterialComponent::SetNormalTexture ( const std::string & path)

Definition at line 102 of file MaterialComponent.cpp.

◆ SetRoughness()

void Sleak::MaterialComponent::SetRoughness ( float roughness)

Definition at line 118 of file MaterialComponent.cpp.

◆ SetShininess()

void Sleak::MaterialComponent::SetShininess ( float shininess)

Definition at line 108 of file MaterialComponent.cpp.

◆ Update()

void Sleak::MaterialComponent::Update ( float DeltaTime)
overridevirtual

Submits the material bind unless a sibling mesh does it.

Implements Sleak::Component.

Definition at line 45 of file MaterialComponent.cpp.

◆ MeshComponent

friend class MeshComponent
friend

Definition at line 57 of file MaterialComponent.hpp.