-
Notifications
You must be signed in to change notification settings - Fork 0
/
Object.cpp
53 lines (42 loc) · 1.43 KB
/
Object.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
#include "Object.h"
Object::Object(std::vector<Point*> vertex, std::vector<Face*> faces, std::vector<Vector*> normals){
this->vertex = vertex;
this->faces = faces;
this->normals = normals;
}
void Object::calculateNormals(){
int size = this->faces.size();
for (int i = 0; i < size; i++){
this->faces[i]->calculateNormal();
}
}
void Object::vertices(){
for (int i = 0; i < this->vertex.size(); i++){
printf("%d", this->vertex[i]->index);
}
}
void Object::calculateVertexNormals(){
int size = this->faces.size();
int qlqer = 1;
for (int i = 0; i < size; i++){
if (this->faces.at(i)->v1->index == 0){
printf("%f %f %f bla1\n", this->faces.at(i)->fn->x, this->faces.at(i)->fn->y, this->faces.at(i)->fn->z);
}
this->normals[this->faces.at(i)->v1->index]->add(this->faces.at(i)->fn);
if (this->faces.at(i)->v2->index == 0){
printf("%f %f %f bla2\n", this->faces.at(i)->fn->x, this->faces.at(i)->fn->y, this->faces.at(i)->fn->z);
}
this->normals[this->faces.at(i)->v2->index]->add(this->faces.at(i)->fn);
if (this->faces.at(i)->v3->index == 0){
printf("%f %f %f bla3\n", this->faces.at(i)->fn->x, this->faces.at(i)->fn->y, this->faces.at(i)->fn->z);
}
this->normals[this->faces.at(i)->v3->index]->add(this->faces.at(i)->fn);
}
size = this->normals.size();
for (int i = 0; i < size; i++){
this->normals[i]->normalize();
if (i == 0){
printf("%f %f %f he \n", normals[i]->x, normals[i]->y, normals[i]->z);
}
}
}