VenomEngine
Cross-Platform Modern Graphics Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages Concepts
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:
24 MaterialImpl();
25 virtual ~MaterialImpl();
26
27 void SetComponent(const MaterialComponentType type, const MaterialComponent & comp);
28 void SetComponent(const MaterialComponentType type, const vcm::Vec3& value);
29 void SetComponent(const MaterialComponentType type, const vcm::Vec4& value);
30 void SetComponent(const MaterialComponentType type, const float value);
31 void SetComponent(const MaterialComponentType type, const Texture & texture);
32 void RemoveComponentValue(const MaterialComponentType type);
33 void RemoveComponentTexture(const MaterialComponentType type);
34 void SetComponentChannels(const MaterialComponentType type, const MaterialComponentValueChannels channels);
35 void SetComponentChannelsFromIndex(const MaterialComponentType type, const int index);
36 const MaterialComponent & GetComponent(const MaterialComponentType type) const;
37 const vc::String & GetName() const;
38 void SetName(const vc::String & name);
39 const vcm::Vec2 & GetTextureRepeatFactor() const;
40 void SetTextureRepeatFactor(const vcm::Vec2 & factor);
41
45 struct VENOM_COMMON_API MaterialComponentResourceTable {
46 MaterialComponentResourceTable();
47 vcm::Vec4 value; // 16 bytes
48 int valueType; // 4 bytes
49 int channels; // 4 bytes
50 char padding[8]; // 8 bytes
51 };
52 struct VENOM_COMMON_API MaterialResourceTable {
53 MaterialComponentResourceTable components[MaterialComponentType::MAX_COMPONENT];
54 vcm::Vec2 textureRepeatingFactor;
55 };
56protected:
57 const MaterialResourceTable & _GetResourceTable(bool & wasDirty);
58
59private:
60 MaterialComponent __components[MaterialComponentType::MAX_COMPONENT];
61 vcm::Vec2 __textureRepeatingFactor;
62 MaterialResourceTable __resourceTable;
63 bool __resourceTableDirty;
64 vc::String __name;
65};
66
67class VENOM_COMMON_API Material : public PluginObjectImplWrapper
68{
69public:
70 Material();
71 ~Material();
72public:
73 inline void SetComponent(const MaterialComponentType type, const MaterialComponent & comp) {
74 _impl->As<MaterialImpl>()->SetComponent(type, comp);
75 }
76 inline void SetComponent(const MaterialComponentType type, const vcm::Vec3& value) {
77 _impl->As<MaterialImpl>()->SetComponent(type, value);
78 }
79 inline void SetComponent(const MaterialComponentType type, const vcm::Vec4& value) {
80 _impl->As<MaterialImpl>()->SetComponent(type, value);
81 }
82 inline void SetComponent(const MaterialComponentType type, const float value) {
83 _impl->As<MaterialImpl>()->SetComponent(type, value);
84 }
85 inline void SetComponent(const MaterialComponentType type, const Texture & texture) {
86 _impl->As<MaterialImpl>()->SetComponent(type, texture);
87 }
88 inline void SetComponentChannels(const MaterialComponentType type, const MaterialComponentValueChannels channels) {
89 _impl->As<MaterialImpl>()->SetComponentChannels(type, channels);
90 }
91 inline void SetComponentChannelsFromIndex(const MaterialComponentType type, const int index) {
92 _impl->As<MaterialImpl>()->SetComponentChannelsFromIndex(type, index);
93 }
94 inline void RemoveComponentTexture(const MaterialComponentType type) {
95 _impl->As<MaterialImpl>()->RemoveComponentTexture(type);
96 }
97 inline void RemoveComponentValue(const MaterialComponentType type) {
98 _impl->As<MaterialImpl>()->RemoveComponentValue(type);
99 }
100 inline const MaterialComponent & GetComponent(const MaterialComponentType type) const {
101 return _impl->As<MaterialImpl>()->GetComponent(type);
102 }
103 inline const vc::String & GetName() const {
104 return _impl->As<MaterialImpl>()->GetName();
105 }
106 inline void SetName(const vc::String & name) {
107 _impl->As<MaterialImpl>()->SetName(name);
108 }
109 inline const vcm::Vec2 & GetTextureRepeatFactor() const {
110 return _impl->As<MaterialImpl>()->GetTextureRepeatFactor();
111 }
112 inline void SetTextureRepeatFactor(const vcm::Vec2 & factor) {
113 _impl->As<MaterialImpl>()->SetTextureRepeatFactor(factor);
114 }
115};
116
117}
118}
MaterialComponent Contains all the data of a material component.
Definition MaterialComponent.h:82
Definition Material.h:22
Contains all the mesh's data and is the main high-level interface for the user.
Definition Model.h:55
Definition Texture.h:179
High-Level Frontend of the VenomEngine project. It also contains all the code shared between every AP...
Definition Callback.h:15
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 Callback.h:13