Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Material.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <ThirdParty/assimp/include/assimp/scene.h>
7 #include <ThirdParty/EASTL-master/include/EASTL/string.h>
8 #include <ThirdParty/EASTL-master/include/EASTL/shared_ptr.h>
9 
10 #ifdef USING_OPENGL
12 #endif
13 #ifdef USING_VULKAN
15 #endif
16 
17 namespace Engine {
18 
19  class Material
20  {
21  public:
22  Material() = default;
23 
32  Material(const aiScene* scene, uint32_t materialIndex, eastl::string modelName);
33  virtual ~Material();
34 
40  virtual void SetDiffuseTexture(eastl::string diffuseTextureName);
41 
46  virtual void SetDiffuseTexture(eastl::shared_ptr<Texture> diffuseTexture);
47 
53  eastl::weak_ptr<Texture> GetDiffuseTexture();
54 
60  eastl::weak_ptr<Texture> GetDefaultDiffuseTexture();
61 
66  bool IsDiffuseLoaded() const;
67 
73  virtual void SetBumpMapTexture(eastl::string bumpMapTextureName);
74 
79  virtual void SetBumpMapTexture(eastl::shared_ptr<Texture> bumpMapTexture);
80 
86  eastl::weak_ptr<Texture> GetBumpMapTexture() const;
87 
93  eastl::weak_ptr<Texture> GetDefaultBumpMapTexture() const;
94 
99  bool IsBumpMapLoaded() const;
100 
105  virtual void SetSpecularTexture(eastl::shared_ptr<Texture> specularTexture);
106 
112  eastl::weak_ptr<Texture> GetSpecularTexture() const;
113 
119  eastl::weak_ptr<Texture> GetDefaultSpecularTexture() const;
120 
125  bool IsSpecularLoaded() const;
126 
131  virtual void SetDiffuseColor(glm::vec3 diffuseColor);
132 
137  glm::vec3 GetDiffuseColor() const;
138 
143  glm::vec3 GetDefaultDiffuseColor() const;
144 
145 
150  virtual void SetSpecularColor(glm::vec3 specularColor);
151 
156  glm::vec3 GetSpecularColor() const;
157 
162  glm::vec3 GetDefaultSpecularColor() const;
163 
168  void SetSpecularScale(float scale);
169 
174  float GetSpecularScale() const;
175 
181  float GetDefaultSpecularScale() const;
182 
187  void SetSpecularExponent(float exponent);
188 
193  float GetSpecularExponent() const;
194 
200  float GetDefaultSpecularExponent() const;
201 
207  bool operator==(const Material& other) const;
208 
209  protected:
210  typedef struct MaterialData
211  {
213  glm::vec4 diffuseColor;
215  glm::vec4 specularColor;
216  int32_t bumpMapLoaded;
219  } MaterialData_t;
220 
221  virtual void UpdateMaterialData();
222 
225 
226  eastl::string modelName;
227 
228  eastl::weak_ptr<Texture> diffuseTexture;
229  eastl::weak_ptr<Texture> defaultDiffuseTexture;
230  eastl::weak_ptr<Texture> bumpMapTexture;
231  eastl::weak_ptr<Texture> defaultBumpMapTexture;
232  eastl::weak_ptr<Texture> specularTexture;
233  eastl::weak_ptr<Texture> defaultSpecularTexture;
234 
235  eastl::weak_ptr<Texture> missingTexture;
236 
237  eastl::weak_ptr<Texture> LoadTexture(const aiScene* scene, aiMaterial* material, aiTextureType textureType);
238  };
239 
240 } // namespace Engine
MaterialData_t materialData_
Definition: Material.hpp:223
void SetSpecularExponent(float exponent)
Sets the specular exponent of the material (shinyness).
Definition: Material.cpp:263
virtual void SetDiffuseTexture(eastl::string diffuseTextureName)
Changes the diffuse texture of the material. NOTE: Texture will be loaded in, if it doesn&#39;t excist ye...
Definition: Material.cpp:83
MaterialData_t defaultMaterialData_
Definition: Material.hpp:224
virtual void SetSpecularColor(glm::vec3 specularColor)
Sets the material&#39;s specular color.
Definition: Material.cpp:231
eastl::weak_ptr< Texture > missingTexture
Definition: Material.hpp:235
float GetDefaultSpecularScale() const
Returns the scale of the specular highlights (strength) that was defined by the model this material w...
Definition: Material.cpp:258
float GetDefaultSpecularExponent() const
Returns the specular exponent of the material that was defined by the model this material was created...
Definition: Material.cpp:274
eastl::weak_ptr< Texture > GetDefaultBumpMapTexture() const
Returns the bump map texture that was defined by the model this material was created from...
Definition: Material.cpp:172
virtual void SetSpecularTexture(eastl::shared_ptr< Texture > specularTexture)
Changes the specular texture of the material. Pass a nullptr to clear the current texture...
Definition: Material.cpp:185
glm::vec3 GetDiffuseColor() const
Returns the material&#39;s diffuse color.
Definition: Material.cpp:221
Material()=default
eastl::string modelName
Definition: Material.hpp:226
eastl::weak_ptr< Texture > defaultBumpMapTexture
Definition: Material.hpp:231
eastl::weak_ptr< Texture > LoadTexture(const aiScene *scene, aiMaterial *material, aiTextureType textureType)
Definition: Material.cpp:297
glm::vec3 GetDefaultSpecularColor() const
Returns the specular color that was defined by the model this material was created from...
Definition: Material.cpp:242
struct Engine::Material::MaterialData MaterialData_t
eastl::weak_ptr< Texture > GetDefaultDiffuseTexture()
Returns the diffuse texture that was defined by the model this material was created from...
Definition: Material.cpp:121
glm::vec3 GetDefaultDiffuseColor() const
Returns the diffuse color that was defined by the model this material was created from...
Definition: Material.cpp:226
float GetSpecularScale() const
Returns the scale of the specular highlights (strength).
Definition: Material.cpp:253
void SetSpecularScale(float scale)
Sets the scale of the specular highlights (strength) of the material.
Definition: Material.cpp:247
glm::vec3 GetSpecularColor() const
Returns the material&#39;s specular color.
Definition: Material.cpp:237
eastl::weak_ptr< Texture > diffuseTexture
Definition: Material.hpp:228
eastl::weak_ptr< Texture > defaultSpecularTexture
Definition: Material.hpp:233
eastl::weak_ptr< Texture > GetDefaultSpecularTexture() const
Returns the specular texture that was defined by the model this material was created from...
Definition: Material.cpp:205
eastl::weak_ptr< Texture > bumpMapTexture
Definition: Material.hpp:230
bool IsBumpMapLoaded() const
Indicates if the material has a bump map texture loaded or not.
Definition: Material.cpp:180
virtual ~Material()
Definition: Material.cpp:79
bool IsSpecularLoaded() const
Indicates if the material has a specular texture loaded or not.
Definition: Material.cpp:210
bool operator==(const Material &other) const
Returns whether or not two materials are the same.
Definition: Material.cpp:279
float GetSpecularExponent() const
Returns the specular exponent of the material.
Definition: Material.cpp:269
eastl::weak_ptr< Texture > GetDiffuseTexture()
Returns the diffuse texture of the material. Returns nullptr if the current material doesn&#39;t have a d...
Definition: Material.cpp:113
eastl::weak_ptr< Texture > defaultDiffuseTexture
Definition: Material.hpp:229
eastl::weak_ptr< Texture > GetSpecularTexture() const
Returns the specular texture of the material. Returns nullptr if the current material doesn&#39;t have a ...
Definition: Material.cpp:200
bool IsDiffuseLoaded() const
Indicates if the material has a diffuse texture loaded or not.
Definition: Material.cpp:129
virtual void SetDiffuseColor(glm::vec3 diffuseColor)
Sets the material&#39;s diffuse color.
Definition: Material.cpp:215
virtual void UpdateMaterialData()
Definition: Material.cpp:293
eastl::weak_ptr< Texture > GetBumpMapTexture() const
Returns the bump map texture of the material. Returns nullptr if the current material doesn&#39;t have a ...
Definition: Material.cpp:164
virtual void SetBumpMapTexture(eastl::string bumpMapTextureName)
Changes the bump map texture of the material. NOTE: Texture will be loaded in, if it doesn&#39;t excist y...
Definition: Material.cpp:134
eastl::weak_ptr< Texture > specularTexture
Definition: Material.hpp:232