-
Notifications
You must be signed in to change notification settings - Fork 0
/
Object.h
102 lines (89 loc) · 2.89 KB
/
Object.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#include <string>
#include <vector>
#include <map>
#include "SOIL.h"
#include "vec.hpp"
struct Group
{
public:
Group(const std::string& name);
public:
std::string m_name;
std::vector<kmuvcl::math::vec3f> m_vertices;
std::vector<kmuvcl::math::vec3f> m_normals;
std::vector<kmuvcl::math::vec2f> m_texcoords;
std::string m_mtl_name;
};
struct Material
{
public:
Material();
Material(const std::string& name,
kmuvcl::math::vec4f& ambient,
kmuvcl::math::vec4f& diffuse,
kmuvcl::math::vec4f& specular,
float& shininess);
public:
std::string m_name;
kmuvcl::math::vec4f m_ambient;
kmuvcl::math::vec4f m_diffuse;
kmuvcl::math::vec4f m_specular;
float m_shininess;
};
class Object
{
public:
Object() {}
Material mtl;
GLuint textureid;
GLuint norm_textureid;
void draw(int loc_a_vertex, int loc_a_normal,
int loc_u_material_ambient, int loc_u_material_diffuse,
int loc_u_material_specular, int loc_u_material_shininess);
void draw(int loc_a_vertex, int loc_a_normal, int loc_a_texcoord,
int loc_u_material_ambient, int loc_u_material_diffuse,
int loc_u_material_specular, int loc_u_material_shininess);
void set_value(const kmuvcl::math::vec3f& t, const GLfloat s, const GLfloat yr){
translation = t;
scale = s;
rotate = yr;
};
void set_color(int r, int g, int b){
mtl.m_ambient = (r, g, b, 1.0);
mtl.m_diffuse = (r, g, b, 1.0);
mtl.m_specular = (r, g, b, 1.0);
};
void print();
void naming(const std::string name){this->name = name;}
void texturename(const std::string texturename_){this->texturename_ = texturename_;}
bool load_simple_obj(const std::string& filename);
bool load_simple_mtl(const std::string& filename);
void load_texture(const std::string& filename);
void load_normtexture(const std::string& filename);
void move_left();
void move_right();
void move_forward();
void move_backward();
void rotate_left();
void rotate_right();
void smaller();
void taller();
void mark(){translation(1) += 2.0f;}
const kmuvcl::math::vec3f Trans() const{return translation;}
const GLfloat Tx() const{return translation(0);}
const GLfloat Ty() const{return translation(1);}
const GLfloat Tz() const{return translation(2);}
const GLfloat S() const{return scale;}
const GLfloat R() const{return rotate;}
const std::string N() const{return name;}
const std::string texture() const{return texturename_;}
private:
kmuvcl::math::vec3f translation;
GLfloat scale, rotate;
std::string name;
std::string texturename_;
std::string PATH;
std::vector<Group> m_groups; // Group 형식의 벡터
std::map<std::string, Material> m_materials; // string, Material 형식의 map
};