VenomEngine
Cross-Platform Modern Graphics Engine
Loading...
Searching...
No Matches
Material.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <venom/common/plugin/graphics/MaterialComponent.h>
12
14
15namespace venom
16{
17namespace common
18{
19class Model;
20
21class VENOM_COMMON_API MaterialImpl : public PluginObjectImpl, public GraphicsPluginObject
22{
23public:
25 virtual ~MaterialImpl();
26
27 void SetComponent(const MaterialComponentType type, const vcm::Vec3& value);
28 void SetComponent(const MaterialComponentType type, const vcm::Vec4& value);
29 void SetComponent(const MaterialComponentType type, const float value);
30 void SetComponent(const MaterialComponentType type, const Texture & texture);
31 const MaterialComponent & GetComponent(const MaterialComponentType type) const;
32 const std::string & GetName() const;
33 void SetName(const std::string & name);
34
38 struct VENOM_COMMON_API MaterialComponentResourceTable {
40 vcm::Vec4 value; // 16 bytes
41 int valueType; // 4 bytes
42 char padding[12]; // 12 bytes
43 };
44 struct VENOM_COMMON_API MaterialResourceTable {
45 MaterialComponentResourceTable components[MaterialComponentType::MAX_COMPONENT];
46 };
47protected:
48 const MaterialResourceTable & _GetResourceTable(bool & wasDirty);
49
50private:
51 MaterialComponent __components[MaterialComponentType::MAX_COMPONENT];
52 MaterialResourceTable __resourceTable;
53 bool __resourceTableDirty;
54 std::string __name;
55};
56
57class VENOM_COMMON_API Material : public PluginObjectImplWrapper
58{
59public:
60 Material();
61 ~Material();
62public:
63 inline void SetComponent(const MaterialComponentType type, const vcm::Vec3& value) {
64 _impl->As<MaterialImpl>()->SetComponent(type, value);
65 }
66 inline void SetComponent(const MaterialComponentType type, const vcm::Vec4& value) {
67 _impl->As<MaterialImpl>()->SetComponent(type, value);
68 }
69 inline void SetComponent(const MaterialComponentType type, const float value) {
70 _impl->As<MaterialImpl>()->SetComponent(type, value);
71 }
72 inline void SetComponent(const MaterialComponentType type, const Texture & texture) {
73 _impl->As<MaterialImpl>()->SetComponent(type, texture);
74 }
75 inline const MaterialComponent & GetComponent(const MaterialComponentType type) const {
76 return _impl->As<MaterialImpl>()->GetComponent(type);
77 }
78 inline const std::string & GetName() const {
79 return _impl->As<MaterialImpl>()->GetName();
80 }
81 inline void SetName(const std::string & name) {
82 _impl->As<MaterialImpl>()->SetName(name);
83 }
84};
85
86}
87}
Base class for graphics plugin objects.
Definition GraphicsPluginObject.h:80
MaterialComponent Contains all the data of a material component.
Definition MaterialComponent.h:69
Definition Material.h:58
Definition Material.h:22
Interface for the PluginObject different implementations.
Definition PluginObject.h:56
Wrapper for the PluginObjectImpl, inherited by classes like Model or Mesh to make them usable as comp...
Definition PluginObject.h:76
Definition Texture.h:80
MaterialComponentType
MaterialComponentType Contains all the possible components of a material that VenomEngine can handle.
Definition MaterialComponent.h:24
Contains the entirety of the code of the VenomEngine project.
Definition Config.h:13