-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadDataFunctions.hpp
More file actions
127 lines (114 loc) · 4.08 KB
/
loadDataFunctions.hpp
File metadata and controls
127 lines (114 loc) · 4.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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// loadDataFunctions.hpp
// CompSci78
//
// Created by Michael Schuff on 1/11/21.
// Copyright © 2021 Michael Schuff. All rights reserved.
//
#ifndef loadDataFunctions_hpp
#define loadDataFunctions_hpp
#include <vector>
#include <fstream>
#include "line.hpp"
#include "color.hpp"
#include "vector3.hpp"
#include "triangle.hpp"
#include "mesh.hpp"
#include "whale.hpp"
#include "fish.hpp"
using namespace std;
//static string file_path = "/Users/michael/Downloads/";
static string file_path = "Resources/";
vector<vector3> getPoints() {
return {
};
}
vector<line> getLines() {
return {
line(vector3(0, 0, 0), vector3(1.5, 0, 0), color(255, 0, 0)),
line(vector3(0, 0, 0), vector3(0, 1.5, 0), color(0, 255, 0)),
line(vector3(0, 0, 0), vector3(0, 0, 1.5), color(0, 0, 255)),
line(vector3(0, 0, 0), vector3(100, 0, 0), color(0.5, 0.5, 0.5)),
line(vector3(100, 0, 0), vector3(100, 0, 100), color(0.5, 0.5, 0.5)),
line(vector3(100, 0, 100), vector3(0, 0, 100), color(0.5, 0.5, 0.5)),
line(vector3(0, 0, 100), vector3(0, 0, 0), color(0.5, 0.5, 0.5)),
line(vector3(0, 0, 0), vector3(0, 100, 0), color(0.5, 0.5, 0.5)),
line(vector3(100, 0, 0), vector3(100, 100, 0), color(0.5, 0.5, 0.5)),
line(vector3(0, 0, 100), vector3(0, 100, 100), color(0.5, 0.5, 0.5)),
line(vector3(100, 0, 100), vector3(100, 100, 100), color(0.5, 0.5, 0.5)),
line(vector3(0, 100, 0), vector3(100, 100, 0), color(0.5, 0.5, 0.5)),
line(vector3(100, 100, 0), vector3(100, 100, 100), color(0.5, 0.5, 0.5)),
line(vector3(100, 100, 100), vector3(0, 100, 100), color(0.5, 0.5, 0.5)),
line(vector3(0, 100, 100), vector3(0, 100, 0), color(0.5, 0.5, 0.5)),
};
}
vector<mesh> getBodies(const vector<fish>& fishList,
const vector<whale>& whaleList,
const mesh& fish_mesh,
const mesh& whale_mesh) {
vector<mesh> bodies;
for (int i = 0; i < fishList.size(); i++) {
quaternion q = get_quaternion(vector3(1, 0, 0), fishList[i].velocity);
bodies.push_back((fishList[i].position + fish_mesh));//.rotated(q));
}
for (int i = 0; i < whaleList.size(); i++) {
quaternion q = get_quaternion(vector3(1, 0, 0), whaleList[i].velocity);
bodies.push_back((whaleList[i].position + whale_mesh));//.rotated(q));
}
return bodies;
}
mesh getWhaleMesh() {
mesh m;
vector<vector3> whale_obj_points;
string check;
ifstream whale_file(file_path + "whalemodel.obj");
while (!whale_file.eof()) {
float x, y, z;
whale_file>>check;
if (check == 'v') {
whale_file>>x;
whale_file>>y;
whale_file>>z;
whale_obj_points.push_back(vector3(x,y,z));
} else if (check == 'f'){
whale_file>>x;
whale_file>>y;
whale_file>>z;
m.push_back(triangle(whale_obj_points[x-1], whale_obj_points[y-1], whale_obj_points[z-1],
color((float) rand()/RAND_MAX, (float) rand()/RAND_MAX, (float) rand()/RAND_MAX)));
} else {
string s;
getline(whale_file, s);
}
}
whale_file.close();
return m;
}
mesh getFishMesh() {
mesh m;
vector<vector3> fish_obj_points;
string check;
ifstream fish_file(file_path + "fishmodel.obj");
while (!fish_file.eof()) {
float x, y, z;
fish_file>>check;
if (check == 'v') {
fish_file>>x;
fish_file>>y;
fish_file>>z;
fish_obj_points.push_back(vector3(x,y,z));
} else if (check == 'f'){
fish_file>>x;
fish_file>>y;
fish_file>>z;
m.push_back(triangle(fish_obj_points[x-1], fish_obj_points[y-1], fish_obj_points[z-1],
color((float) rand()/RAND_MAX, (float) rand()/RAND_MAX, (float) rand()/RAND_MAX)));
} else {
string s;
getline(fish_file, s);
}
}
fish_file.close();
return m;
}
#endif /* loadDataFunctions_hpp */