3D City v-1.0
Computer Graphics Project
drawable.h
Go to the documentation of this file.
1#pragma once
2
3#include "core.h"
4#include "material.h"
5#include "transformations.h"
6#include <vector>
7
11template <class T>
12struct drawable {
13
14 std::vector<T> m_vertices;
15 std::vector<uint32_t> m_indices;
18 std::string name;
19 bool draw = true;
20
22
23 drawable() = default;
24
25 drawable(const std::vector<T> &vertices, std::vector<unsigned> indices, const std::string &n) : name(n), m_vertices(vertices), m_indices(indices) {
26 }
27
28 void delpos(const vec3 &delta) {
29 translation = trans::translate(delta) * this->translation;
31 }
32
33 void setpos(const vec3 &delta) {
34 translation = trans::translate(delta);
36 }
37
39
40 void setScale(const vec3 &scale) {
41 scaling = trans::scaling3d(scale);
43 }
44
45 void setRotation(float angle, const vec3 &axis) {
46 rotation = trans::rotation(radian * angle, axis);
48 }
49
52 return &matModel;
53 }
54
55 virtual void userSpecificFunction() {}
56
57 protected:
61};
62
drawable< Vertex > Mesh
Definition: drawable.h:63
mat< float, 4, 4 > mat4f
Definition: maths.h:750
constexpr float radian
Definition: maths.h:10
class to store information about material read from .mtl file along with obj
Definition: material.h:20
this class represents all drawable entities that has a material and vertices
Definition: drawable.h:12
void setScale(const vec3 &scale)
Definition: drawable.h:40
virtual void userSpecificFunction()
Definition: drawable.h:55
std::string name
Definition: drawable.h:18
mat4f getTranslation()
Definition: drawable.h:38
void delpos(const vec3 &delta)
Definition: drawable.h:28
std::vector< uint32_t > m_indices
Definition: drawable.h:15
mat4f scaling
Definition: drawable.h:58
bool doLightCalculations
Definition: drawable.h:17
Material material
Definition: drawable.h:16
mat4f * refreshModel()
Definition: drawable.h:50
bool draw
Definition: drawable.h:19
drawable()=default
mat4f matModel
Definition: drawable.h:21
mat4f translation
Definition: drawable.h:59
void setpos(const vec3 &delta)
Definition: drawable.h:33
void setRotation(float angle, const vec3 &axis)
Definition: drawable.h:45
std::vector< T > m_vertices
Definition: drawable.h:14
mat4f rotation
Definition: drawable.h:60
drawable(const std::vector< T > &vertices, std::vector< unsigned > indices, const std::string &n)
Definition: drawable.h:25