-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.h
More file actions
56 lines (43 loc) · 2.1 KB
/
object.h
File metadata and controls
56 lines (43 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
////////////////////////////////////////////////////////////////////////
// A lightweight class representing an instance of an object that can
// be drawn onscreen. An Object consists of a shape (batch of
// triangles), and various transformation, color and texture
// parameters. It also contains a list of child objects to be drawn
// in a hierarchical fashion under the control of parent's
// transformations.
//
// Methods consist of a constructor, and a Draw procedure, and an
// append for building hierarchies of objects.
#ifndef _OBJECT
#define _OBJECT
#include "shapes.h"
#include "texture.h"
#include <utility> // for pair<Object*,glm::mat4>
class Shader;
class Object;
typedef std::pair<Object*,glm::mat4> INSTANCE;
// Object:: A shape, and its transformations, colors, and textures and sub-objects.
class Object
{
public:
Shape* shape; // Polygons
Texture* texture;
Texture* normalTexture;
glm::mat4 animTr; // This model's animation transformation
int objectId; // Object id to be sent to the shader
bool drawMe; // Toggle specifies if this object (and children) are drawn.
bool reflective; // Is the object reflective?
glm::vec3 diffuseColor; // Diffuse color of object
glm::vec3 specularColor; // Specular color of object
float shininess; // Surface roughness value
std::vector<INSTANCE> instances; // Pairs of sub-objects and transformations
Object(Shape* _shape, const int objectId,
const glm::vec3 _d=glm::vec3(), const glm::vec3 _s=glm::vec3(), const float _n=1, bool reflective=false, Texture* _texture = NULL, Texture* _normalTexture = NULL);
// If this object is to be drawn with a texture, this is a good
// place to store the texture id (a small positive integer). The
// texture id should be set in Scene::InitializeScene and used in
// Object::Draw.
void Draw(ShaderProgram* program, glm::mat4& objectTr);
void add(Object* m, glm::mat4 tr=glm::mat4(1.0)) { instances.push_back(std::make_pair(m,tr)); }
};
#endif