-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mesh.cpp
80 lines (62 loc) · 1.9 KB
/
Mesh.cpp
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
#include "Mesh.h"
#include <vector>
#include "Vector2.h"
#include "Vector3.h"
#include <memory>
#include "Material.h"
Mesh::Mesh(const std::vector<Vector3> &_vertex,const Material &_material)
:vertex(_vertex),material(_material){}
Mesh::Mesh(const std::vector<Vector3> &_vertex,const std::vector<Vector3> &_normal,const Material &_material)
:vertex(_vertex),normal(_normal),material(_material){}
Mesh::Mesh(const std::vector<Vector3> &_vertex,const std::vector<Vector2> &_texCoord,const Material &_material)
:vertex(_vertex),texCoord(_texCoord),material(_material){}
Mesh::Mesh(const std::vector<Vector3> &_vertex,const std::vector<Vector3> &_normal,const std::vector<Vector2> &_texCoord,const Material &_material)
:vertex(_vertex),normal(_normal),texCoord(_texCoord),material(_material){}
Mesh::Mesh(const Mesh &_orig)
:material(_orig.getMaterial()){
for(int i=0;i<_orig.getVertexNum();i++)
vertex.push_back(_orig.getVertex(i));
for(int i=0;i<_orig.getNormalNum();i++)
normal.push_back(_orig.getNormal(i));
for(int i=0;i<_orig.getTexCoordNum();i++)
texCoord.push_back(_orig.getTexCoord(i));
}
void Mesh::setVertex(int i,const Vector3 &_vertex){
vertex[i]=_vertex;
}
Vector3 Mesh::getVertex(int i)const{
return vertex[i];
}
int Mesh::getVertexNum()const{
return vertex.size();
}
void Mesh::setNormal(int i,const Vector3 &_normal){
normal[i]=_normal;
}
Vector3 Mesh::getNormal(int i)const{
return normal[i];
}
int Mesh::getNormalNum()const{
return normal.size();
}
void Mesh::setTexCoord(int i,const Vector2 &_texCoord){
texCoord[i]=_texCoord;
}
Vector2 Mesh::getTexCoord(int i)const{
return texCoord[i];
}
int Mesh::getTexCoordNum()const{
return texCoord.size();
}
void Mesh::setMaterial(const Material &_material){
material=_material;
}
Material Mesh::getMaterial()const{
return material;
}
bool Mesh::hasNormal()const{
return normal.size()>0;
}
bool Mesh::hasTexCoord()const{
return texCoord.size()>0;
}