-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScene.cpp
More file actions
45 lines (35 loc) · 1.08 KB
/
Scene.cpp
File metadata and controls
45 lines (35 loc) · 1.08 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
#include "Scene.h"
Scene::Scene()
{}
void Scene::AddObject(std::string object_name, Matrix *C, bool wireframe)
{
Object* object = scene_objects_.at(object_name);
int offset = scene_vertices_.x.size();
// Copy vertices into scene vertices and transform them via matrix C
for (int i = 0; i < object->Vertices().x.size(); i++) {
double x = object->Vertices().x[i];
double y = object->Vertices().y[i];
double z = object->Vertices().z[i];
double w = object->Vertices().w[i];
TransformVector(&x, &y, &z, &w, C);
scene_vertices_.x.push_back(x);
scene_vertices_.y.push_back(y);
scene_vertices_.z.push_back(z);
scene_vertices_.w.push_back(w);
}
// Copy objects polygons into the scenes polygon list and
// update the polygons data and flags
for (int poly = 0; poly < object->PolyCount(); poly++) {
polygon new_polygon;
if (wireframe) {
new_polygon.wire = true;
}
else {
new_polygon.wire = false;
}
new_polygon.object_offset = offset;
new_polygon.vertices = object->Polygons()[poly].vertices;
new_polygon.cull = false;
scene_polys_.push_back(new_polygon);
}
}