107 void setColor(glm::vec4 color=glm::vec4(1));
115 void setColor(
float r=1,
float g=1,
float b=1,
float a=1);
148 virtual void setShader(std::string vertexShader, std::string fragmentShader);
155 static const Material emerald,
jade,
obsidian,
pearl,
ruby,
turquoise,
brass,
bronze,
chrome,
copper,
gold,
silver,
160 Material(
float ar,
float ag,
float ab,
float dr,
float dg,
float db,
float sr,
float sg,
float sb,
float sn);
195 bool dynamic =
false;
210 Entity(
const glm::vec3 &pos=glm::vec3(0));
222 void translate(
const glm::vec3 &d=glm::vec3(0));
229 void translate(
float dx=0,
float dy=0,
float dz=0);
235 void rotate(
float rad=0, glm::vec3 axis=glm::vec3(0));
240 void scale(
const glm::vec3 &s=glm::vec3(1));
249 void scale(
float sx=1,
float sy=std::nanf(
""),
float sz=std::nanf(
""));
254 void transform(
const glm::mat4 &m);
261 void applyTransform();
270 virtual void mergeData();
274 virtual void createBuffers();
305 float spotExponent = 0,
307 constantAttenuation = 1,
308 linearAttenuation = 0,
309 quadraticAttenuation = 0;
320 Light(
const glm::vec3 &pos=glm::vec3(-2, 3, 2),
const glm::vec4 &color=glm::vec4(1));
329 Light(
const glm::vec3 &pos=glm::vec3(-2, 3, 2),
float r=1,
float g=1,
float b=1,
float a=1);
334 void setColor(glm::vec4 color=glm::vec4(1));
338 void setColor(
float r=1,
float g=1,
float b=1,
float a=1);
345 return parent ==
nullptr ? position : parent->getMatM() * position;
373 Light l(dir, r, g, b, a);
401 virtual void mergeData();
409 virtual void createBuffers();
glm::vec3 position
Position of the entity, the entity is centered here.
Definition: entity.h:201
The base for all Entity and Light.
Definition: entity.h:166
glm::vec4 emission
Emission, self color of the material.
Definition: entity.h:54
glm::vec4 specular
Specular, reflects from surface.
Definition: entity.h:300
static const Material copper
Definition: entity.h:155
void createTexture(const char *path=nullptr)
Creates a texture.
Definition: entity.cpp:191
static const Material white_plastic
Definition: entity.h:155
float shininess
Shininess, amount of light reflected by the material.
Definition: entity.h:59
static const Material emerald
Definition: entity.h:155
GLuint dID
diffuse color ID
Definition: entity.h:68
Material & operator*=(const Material &other)
Same as operator* but modifies the current material.
Definition: entity.cpp:167
glm::mat4 model
The model matrix for the entity. This is the M part of the MVP matrix. This is responsible for all th...
Definition: entity.h:202
static const Material green_rubber
Definition: entity.h:155
static const Material cyan_rubber
Definition: entity.h:155
GLuint eID
emission color ID
Definition: entity.h:68
static const Material cyan_plastic
Definition: entity.h:155
GLuint nID
normal matrix ID
Definition: entity.h:68
Material operator+(const Material &other) const
Mix two material.
Definition: entity.cpp:138
The Entity; basically all visible objects in AGL.
Definition: entity.h:188
glm::vec4 ambient
Ambient, color due to ambient light.
Definition: entity.h:54
static const Material gold
Definition: entity.h:155
glm::vec4 ratios
Definition: entity.h:54
GLuint mvpID
MVP matrix ID.
Definition: entity.h:68
Definition: create_shader.cpp:4
static const Material white_rubber
Definition: entity.h:155
Material operator*(const Material &other) const
Mix two material.
Definition: entity.cpp:157
static const Material chrome
Definition: entity.h:155
GLuint gID
shininess color ID
Definition: entity.h:68
A SharedEntity shares its data off another Entity.
Definition: entity.h:388
void setColor(glm::vec4 color=glm::vec4(1))
Set color for all the components.
Definition: entity.cpp:176
GLuint vID
camera position ID
Definition: entity.h:68
std::vector< GLfloat > vertices
Vertices.
Definition: entity.h:196
int tex_channel
Number of channels in texture, if used.
Definition: entity.h:65
static const Material yellow_rubber
Definition: entity.h:155
static const Material red_plastic
Definition: entity.h:155
virtual void setShader(std::string vertexShader, std::string fragmentShader)
Compile and set the shader for the material.
Definition: entity.cpp:211
GLuint mID
model matrix ID
Definition: entity.h:68
std::vector< BaseEntity * > children
Children of this entity.
Definition: entity.h:204
static const Material yellow_plastic
Definition: entity.h:155
glm::vec3 spotDirection
Direction of spotlight.
Definition: entity.h:304
~Material()
Definition: entity.cpp:134
int tex_height
Height of texture, if used.
Definition: entity.h:64
GLubyte * texture
Pointer to texture data, if present.
Definition: entity.h:66
static const Material silver
Definition: entity.h:155
Light, adds reality to the scene.
Definition: entity.h:297
GLuint aID
ambient color ID
Definition: entity.h:68
static const Material black_plastic
Definition: entity.h:155
static const Material brass
Definition: entity.h:155
Material material
Material for shading this entity.
Definition: entity.h:203
static const Material obsidian
Definition: entity.h:155
bool lightsEnabled
If true, no lighting calculations are done.
Definition: entity.h:60
static const Material jade
Definition: entity.h:155
static const Material black_rubber
Definition: entity.h:155
static const Material green_plastic
Definition: entity.h:155
static const Material turquoise
Definition: entity.h:155
int tex_width
Width of texture,if used.
Definition: entity.h:63
#define AGL_SHADING_PHONG
Each point (fragment) will be shaded.
Definition: util.h:71
Material()
Creates a material.
Definition: entity.cpp:131
GLuint sID
specular color ID
Definition: entity.h:68
Material & operator+=(const Material &other)
Same as operator+ but modifies the current material.
Definition: entity.cpp:148
glm::vec4 specular
Specular, color due to the reflection of light.
Definition: entity.h:54
glm::vec4 position
Position (direction) of the light.
Definition: entity.h:300
GLuint tID
texture ID
Definition: entity.h:68
glm::vec4 getPos()
Get the position of the light.
Definition: entity.h:343
Material class for entities.
Definition: entity.h:51
static const Material pearl
Definition: entity.h:155
Light DirectionalLight(const glm::vec3 &dir=glm::vec3(0), const glm::vec4 &color=glm::vec4(1))
Create a directional Light.
Definition: entity.h:356
static const Material ruby
Definition: entity.h:155
glm::vec4 diffuse
Diffuse, color when light hits a surface.
Definition: entity.h:54
GLuint progID
program ID
Definition: entity.h:67
static const Material red_rubber
Definition: entity.h:155
bool customShader
If true, Scene::prepare do not create shaders.
Definition: entity.h:61
int shadingType
Type of shading, currently unused.
Definition: entity.h:62
static const Material bronze
Definition: entity.h:155
std::vector< GLuint > indices
Indices.
Definition: entity.h:200