Kemena3D
Loading...
Searching...
No Matches
kmaterial.h
Go to the documentation of this file.
1
5
6#ifndef KMATERIAL_H
7#define KMATERIAL_H
8
9#include "kexport.h"
10
11#include "kdatatype.h"
12#include "kshader.h"
13#include "ktexture2d.h"
14#include "ktexturecube.h"
15
16namespace kemena
17{
27 {
28 public:
33
40 virtual ~kMaterial();
41
46 void setShader(kShader *newShader);
47
53
58 void addTexture(kTexture *texture);
59
64 std::vector<kTexture *> getTextures();
65
71 kTexture *getTexture(int index);
72
78
84
89 void setUvTiling(kVec2 newTiling);
90
96
102
108
114
119 void setShininess(float value);
120
125 void setMetallic(float value);
126
131 void setRoughness(float value);
132
138
144
150
156
161 float getMetallic();
162
168
174 void setSingleSided(bool newSingleSided, bool newCullBack = true);
175
181
187
188 protected:
189 private:
190 kShader *shader = nullptr;
191 kTransparentType transparent = TRANSP_TYPE_NONE;
192 std::vector<kTexture *> textures;
193
194 kVec2 uvTiling = kVec2(1, 1);
195
196 kVec3 ambientColor = kVec3(1.0f, 1.0f, 1.0f);
197 kVec3 diffuseColor = kVec3(1.0f, 1.0f, 1.0f);
198 kVec3 specularColor = kVec3(1.0f, 1.0f, 1.0f);
199 float shininess = 32.0f;
200 float metallic = 0.0f;
201 float roughness = 0.5f;
202
203 bool isSingleSided = true;
204 bool isCullBack = true;
205 };
206}
207
208#endif // KMATERIAL_H
kVec2 getUvTiling()
Returns the UV tiling factor.
void setSingleSided(bool newSingleSided, bool newCullBack=true)
Configures face culling for this material.
void setRoughness(float value)
Sets the PBR roughness factor.
void addTexture(kTexture *texture)
Appends a texture to the material's texture list.
kVec3 getAmbientColor()
Returns the ambient colour.
kTransparentType getTransparent()
Returns the transparency blending mode.
void setAmbientColor(kVec3 color)
Sets the ambient colour.
bool getCullBack()
Returns which face is culled when single-sided rendering is on.
kShader * getShader()
Returns the assigned shader.
void setMetallic(float value)
Sets the PBR metallic factor.
bool getSingleSided()
Returns whether face culling is enabled.
float getShininess()
Returns the Phong shininess exponent.
std::vector< kTexture * > getTextures()
Returns all textures attached to this material.
void setShininess(float value)
Sets the Phong shininess exponent.
kVec3 getDiffuseColor()
Returns the diffuse colour.
void setShader(kShader *newShader)
Assigns a compiled shader to this material.
void setSpecularColor(kVec3 color)
Sets the specular colour.
float getRoughness()
Returns the PBR roughness factor.
void setTransparent(kTransparentType type)
Sets the transparency blending mode.
void setDiffuseColor(kVec3 color)
Sets the diffuse colour.
virtual ~kMaterial()
Destroys the material.
kVec3 getSpecularColor()
Returns the specular colour.
void setUvTiling(kVec2 newTiling)
Sets the UV tiling factor applied to all texture coordinates.
float getMetallic()
Returns the PBR metallic factor.
kTexture * getTexture(int index)
Returns a texture by index.
kMaterial()
Constructs a material with default surface parameters and no shader.
Wraps a compiled GLSL shader program.
Definition kshader.h:55
Base GPU texture abstraction shared by kTexture2D and kTextureCube.
Definition ktexture.h:37
Core type aliases, enumerations, structs, and utility functions used throughout the engine.
Symbol visibility / linkage macro for the Kemena3D library.
GLSL shader program wrapper.
2D texture with pixel data access.
Cube-map texture used for skyboxes and environment maps.
Top-level Kemena3D engine namespace.
Definition kanimation.h:23
glm::vec2 kVec2
2-component float vector.
Definition kdatatype.h:32
glm::vec3 kVec3
3-component float vector.
Definition kdatatype.h:33
kTransparentType
Transparency/blending mode for a material.
Definition kdatatype.h:106
@ TRANSP_TYPE_NONE
Opaque — no blending.
Definition kdatatype.h:107