add reading keypoints from file

This commit is contained in:
Matraf 2022-01-21 12:34:15 +01:00
parent a500d8febc
commit 312d30ec3e
5 changed files with 201 additions and 57 deletions

View File

@ -0,0 +1,104 @@
12.0,-130.0,33.0
12.0,-130.0,26.0
12.0,-130.0,19.0
12.0,-130.0,12.0
19.0,-130.0,5.0
26.0,-130.0,-2.0
33.0,-130.0,-2.0
40.0,-130.0,-9.0
33.0,-130.0,-16.0
26.0,-130.0,-23.0
19.0,-130.0,-30.0
19.0,-130.0,-37.0
19.0,-130.0,-44.0
26.0,-130.0,-51.0
33.0,-130.0,-58.0
33.0,-130.0,-65.0
26.0,-130.0,-72.0
19.0,-130.0,-79.0
12.0,-130.0,-86.0
5.0,-130.0,-86.0
-2.0,-130.0,-86.0
-9.0,-130.0,-79.0
-16.0,-130.0,-72.0
-23.0,-130.0,-65.0
-30.0,-130.0,-58.0
-37.0,-130.0,-51.0
-44.0,-130.0,-51.0
-51.0,-130.0,-51.0
-58.0,-130.0,-44.0
-58.0,-130.0,-37.0
-58.0,-130.0,-30.0
-65.0,-130.0,-23.0
-72.0,-130.0,-16.0
-79.0,-130.0,-16.0
-86.0,-130.0,-9.0
-86.0,-130.0,-2.0
-86.0,-130.0,5.0
-86.0,-130.0,12.0
-86.0,-130.0,19.0
-79.0,-130.0,26.0
-72.0,-130.0,33.0
-65.0,-130.0,40.0
-58.0,-130.0,47.0
-51.0,-130.0,54.0
-44.0,-130.0,61.0
-37.0,-130.0,68.0
-30.0,-130.0,75.0
-37.0,-130.0,82.0
-44.0,-130.0,89.0
-51.0,-130.0,96.0
-51.0,-130.0,103.0
-51.0,-130.0,110.0
-51.0,-130.0,117.0
-44.0,-130.0,124.0
-37.0,-130.0,131.0
-30.0,-130.0,138.0
-23.0,-130.0,145.0
-16.0,-130.0,152.0
-9.0,-130.0,159.0
-2.0,-130.0,152.0
5.0,-130.0,145.0
12.0,-130.0,138.0
19.0,-130.0,131.0
26.0,-130.0,131.0
33.0,-130.0,131.0
40.0,-130.0,131.0
47.0,-130.0,131.0
54.0,-130.0,131.0
61.0,-130.0,131.0
61.0,-130.0,138.0
68.0,-130.0,145.0
75.0,-130.0,152.0
82.0,-130.0,159.0
89.0,-130.0,166.0
96.0,-130.0,166.0
103.0,-130.0,166.0
110.0,-130.0,159.0
117.0,-130.0,152.0
124.0,-130.0,145.0
131.0,-130.0,138.0
124.0,-130.0,131.0
117.0,-130.0,124.0
110.0,-130.0,117.0
103.0,-130.0,110.0
110.0,-130.0,103.0
117.0,-130.0,96.0
117.0,-130.0,89.0
110.0,-130.0,82.0
103.0,-130.0,82.0
96.0,-130.0,82.0
89.0,-130.0,82.0
82.0,-130.0,75.0
82.0,-130.0,68.0
75.0,-130.0,61.0
68.0,-130.0,54.0
61.0,-130.0,54.0
54.0,-130.0,54.0
47.0,-130.0,47.0
47.0,-130.0,40.0
40.0,-130.0,40.0
33.0,-130.0,40.0
26.0,-130.0,33.0
19.0,-130.0,33.0
12.0,-130.0,33.0
1 12.0 -130.0 33.0
2 12.0 -130.0 26.0
3 12.0 -130.0 19.0
4 12.0 -130.0 12.0
5 19.0 -130.0 5.0
6 26.0 -130.0 -2.0
7 33.0 -130.0 -2.0
8 40.0 -130.0 -9.0
9 33.0 -130.0 -16.0
10 26.0 -130.0 -23.0
11 19.0 -130.0 -30.0
12 19.0 -130.0 -37.0
13 19.0 -130.0 -44.0
14 26.0 -130.0 -51.0
15 33.0 -130.0 -58.0
16 33.0 -130.0 -65.0
17 26.0 -130.0 -72.0
18 19.0 -130.0 -79.0
19 12.0 -130.0 -86.0
20 5.0 -130.0 -86.0
21 -2.0 -130.0 -86.0
22 -9.0 -130.0 -79.0
23 -16.0 -130.0 -72.0
24 -23.0 -130.0 -65.0
25 -30.0 -130.0 -58.0
26 -37.0 -130.0 -51.0
27 -44.0 -130.0 -51.0
28 -51.0 -130.0 -51.0
29 -58.0 -130.0 -44.0
30 -58.0 -130.0 -37.0
31 -58.0 -130.0 -30.0
32 -65.0 -130.0 -23.0
33 -72.0 -130.0 -16.0
34 -79.0 -130.0 -16.0
35 -86.0 -130.0 -9.0
36 -86.0 -130.0 -2.0
37 -86.0 -130.0 5.0
38 -86.0 -130.0 12.0
39 -86.0 -130.0 19.0
40 -79.0 -130.0 26.0
41 -72.0 -130.0 33.0
42 -65.0 -130.0 40.0
43 -58.0 -130.0 47.0
44 -51.0 -130.0 54.0
45 -44.0 -130.0 61.0
46 -37.0 -130.0 68.0
47 -30.0 -130.0 75.0
48 -37.0 -130.0 82.0
49 -44.0 -130.0 89.0
50 -51.0 -130.0 96.0
51 -51.0 -130.0 103.0
52 -51.0 -130.0 110.0
53 -51.0 -130.0 117.0
54 -44.0 -130.0 124.0
55 -37.0 -130.0 131.0
56 -30.0 -130.0 138.0
57 -23.0 -130.0 145.0
58 -16.0 -130.0 152.0
59 -9.0 -130.0 159.0
60 -2.0 -130.0 152.0
61 5.0 -130.0 145.0
62 12.0 -130.0 138.0
63 19.0 -130.0 131.0
64 26.0 -130.0 131.0
65 33.0 -130.0 131.0
66 40.0 -130.0 131.0
67 47.0 -130.0 131.0
68 54.0 -130.0 131.0
69 61.0 -130.0 131.0
70 61.0 -130.0 138.0
71 68.0 -130.0 145.0
72 75.0 -130.0 152.0
73 82.0 -130.0 159.0
74 89.0 -130.0 166.0
75 96.0 -130.0 166.0
76 103.0 -130.0 166.0
77 110.0 -130.0 159.0
78 117.0 -130.0 152.0
79 124.0 -130.0 145.0
80 131.0 -130.0 138.0
81 124.0 -130.0 131.0
82 117.0 -130.0 124.0
83 110.0 -130.0 117.0
84 103.0 -130.0 110.0
85 110.0 -130.0 103.0
86 117.0 -130.0 96.0
87 117.0 -130.0 89.0
88 110.0 -130.0 82.0
89 103.0 -130.0 82.0
90 96.0 -130.0 82.0
91 89.0 -130.0 82.0
92 82.0 -130.0 75.0
93 82.0 -130.0 68.0
94 75.0 -130.0 61.0
95 68.0 -130.0 54.0
96 61.0 -130.0 54.0
97 54.0 -130.0 54.0
98 47.0 -130.0 47.0
99 47.0 -130.0 40.0
100 40.0 -130.0 40.0
101 33.0 -130.0 40.0
102 26.0 -130.0 33.0
103 19.0 -130.0 33.0
104 12.0 -130.0 33.0

View File

@ -0,0 +1,12 @@
0.0, 0.0, 15.0
-20.0, 10.0, 10.0
-35.0, 15.0, 5.0
-55.0, 0.0, 5.0
-70.0, 0.0, 0.0
-70.0, 0.0, -10.0
-70.0, 0.0, -25.0
-85.0, 0.0, -35.0
-115.0, 0.0, -45.0
-135.0, 0.0, -25.0
-155.0, 0.0, -5.0
-175.0, 0.0, 0.0
1 0.0 0.0 15.0
2 -20.0 10.0 10.0
3 -35.0 15.0 5.0
4 -55.0 0.0 5.0
5 -70.0 0.0 0.0
6 -70.0 0.0 -10.0
7 -70.0 0.0 -25.0
8 -85.0 0.0 -35.0
9 -115.0 0.0 -45.0
10 -135.0 0.0 -25.0
11 -155.0 0.0 -5.0
12 -175.0 0.0 0.0

View File

@ -0,0 +1,26 @@
0.0, -130.0, 0.0
50.0, -130.0, 25.0
75.0, -130.0, 75.0
40.0, -130.0, 100.0
-25.0, -130.0, 85.0
-60.0, -130.0, 75.0
-75.0, -130.0, 70.0
-100.0, -130.0, 35.0
-90.0, -130.0, 0.0
-105.0, -130.0, -50.0
-95.0, -130.0, -75.0
-115.0, -130.0, -100.0
-75.0, -130.0, -120.0
-70.0, -130.0, -135.0
-35.0, -130.0, -120.0
10.0, -130.0, -150.0
25.0, -130.0, -135.0
50.0, -130.0, -140.0
60.0, -130.0, -110.0
50.0, -130.0, -75.0
30.0, -130.0, -85.0
10.0, -130.0, -50.0
-40.0, -130.0, -65.0
-25.0, -130.0, -25.0
-15.0, -130.0, -10.0
0.0, -130.0, 0.0
1 0.0 -130.0 0.0
2 50.0 -130.0 25.0
3 75.0 -130.0 75.0
4 40.0 -130.0 100.0
5 -25.0 -130.0 85.0
6 -60.0 -130.0 75.0
7 -75.0 -130.0 70.0
8 -100.0 -130.0 35.0
9 -90.0 -130.0 0.0
10 -105.0 -130.0 -50.0
11 -95.0 -130.0 -75.0
12 -115.0 -130.0 -100.0
13 -75.0 -130.0 -120.0
14 -70.0 -130.0 -135.0
15 -35.0 -130.0 -120.0
16 10.0 -130.0 -150.0
17 25.0 -130.0 -135.0
18 50.0 -130.0 -140.0
19 60.0 -130.0 -110.0
20 50.0 -130.0 -75.0
21 30.0 -130.0 -85.0
22 10.0 -130.0 -50.0
23 -40.0 -130.0 -65.0
24 -25.0 -130.0 -25.0
25 -15.0 -130.0 -10.0
26 0.0 -130.0 0.0

View File

@ -0,0 +1,9 @@
-400.0, 100.0, -400.0
-300.0, 100.0, -300.0
-200.0, 100.0, -200.0
-100.0, 100.0, -100.0
0.0, 100.0, 0.0
100.0, 100.0, 100.0
200.0, 100.0, 200.0
300.0, 100.0, 300.0
400.0, 100.0, 400.0
1 -400.0 100.0 -400.0
2 -300.0 100.0 -300.0
3 -200.0 100.0 -200.0
4 -100.0 100.0 -100.0
5 0.0 100.0 0.0
6 100.0 100.0 100.0
7 200.0 100.0 200.0
8 300.0 100.0 300.0
9 400.0 100.0 400.0

View File

@ -4,6 +4,8 @@
#include "glm.hpp"
#include "ext.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
#include <vector>
#include <random>
@ -54,63 +56,13 @@ Core::RenderContext fangtoothContext;
Core::RenderContext sharkContext;
Core::RenderContext bubbleContext;
std::vector<glm::vec3> fishKeyPointsFirst({
glm::vec3(0.0f, -130.0f, 0.0f),
glm::vec3(50.0f, -130.0f, 25.0f),
glm::vec3(75.0f, -130.0f, 75.0f),
glm::vec3(40.0f, -130.0f, 100.0f),
glm::vec3(-25.0f, -130.0f, 85.0f),
glm::vec3(-60.0f, -130.0f, 75.0f),
glm::vec3(-75.0f, -130.0f, 70.0f),
glm::vec3(-100.0f, -130.0f, 35.0f),
glm::vec3(-90.0f, -130.0f, 0.0f),
glm::vec3(-105.0f, -130.0f, -50.0f),
glm::vec3(-95.0f, -130.0f, -75.0f),
glm::vec3(-115.0f, -130.0f, -100.0f),
glm::vec3(-75.0f, -130.0f, -120.0f),
glm::vec3(-70.0f, -130.0f, -135.0f),
glm::vec3(-35.0f, -130.0f, -120.0f),
glm::vec3(10.0f, -130.0f, -150.0f),
glm::vec3(25.0f, -130.0f, -135.0f),
glm::vec3(50.0f, -130.0f, -140.0f),
glm::vec3(60.0f, -130.0f, -110.0f),
glm::vec3(50.0f, -130.0f, -75.0f),
glm::vec3(30.0f, -130.0f, -85.0f),
glm::vec3(10.0f, -130.0f, -50.0f),
glm::vec3(-40.0f, -130.0f, -65.0f),
glm::vec3(-25.0f, -130.0f, -25.0f),
glm::vec3(-15.0f, -130.0f, -10.0f),
glm::vec3(0.0f, -130.0f, 0.0f),
});
std::vector<glm::vec3> fishKeyPointsFirst;
std::vector<glm::quat> fishKeyRotationFirst;
std::vector<glm::vec3> fishKeyPointsSecond({
glm::vec3(0.0f, 0.0f, 15.0f),
glm::vec3(-20.0f, 10.0f, 10.0f),
glm::vec3(-35.0f, 15.0f, 5.0f),
glm::vec3(-55.0f, 0.0f, 5.0f),
glm::vec3(-70.0f, 0.0f, 0.0f),
glm::vec3(-70.0f, 0.0f, -10.0f),
glm::vec3(-70.0f, 0.0f, -25.0f),
glm::vec3(-85.0f, 0.0f, -35.0f),
glm::vec3(-115.0f, 0.0f, -45.0f),
glm::vec3(-135.0f, 0.0f, -25.0f),
glm::vec3(-155.0f, 0.0f, -5.0f),
glm::vec3(-175.0f, 0.0f, 0.0f)
});
std::vector<glm::vec3> fishKeyPointsSecond;
std::vector<glm::quat> fishKeyRotationSecond;
std::vector<glm::vec3> sharkKeyPoints({
glm::vec3(-400.0f, 100.0f, -400.0f),
glm::vec3(-300.0f, 100.0f, -300.0f),
glm::vec3(-200.0f, 100.0f, -200.0f),
glm::vec3(-100.0f, 100.0f, -100.0f),
glm::vec3(0.0f, 100.0f, 0.0f),
glm::vec3(100.0f, 100.0f, 100.0f),
glm::vec3(200.0f, 100.0f, 200.0f),
glm::vec3(300.0f, 100.0f, 300.0f),
glm::vec3(400.0f, 100.0f, 400.0f),
});
std::vector<glm::vec3> sharkKeyPoints;
std::vector<glm::quat> sharkKeyRotation;
@ -463,10 +415,10 @@ void renderScene()
for (int i = 0; i < 5; i++) {
if (time > -10) {
drawObjectTexture(fishContext, animationMatrix(time + 15, change1, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change2, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 1.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change1, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 5.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change2, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 5.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change3, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 5.f), textureFish, programTexture);
drawObjectTexture(fishContext, animationMatrix(time + 15, change4, fishKeyPointsFirst, fishKeyRotationFirst, glm::vec3(0.8f), 5.f), textureFish, programTexture);
drawObjectTexture(fangtoothContext, animationMatrix(time + 15, change1, fishKeyPointsSecond, fishKeyRotationSecond, glm::vec3(0.25f), 1.f), textureFangtooth, programTexture);
time -= 5;
}
@ -543,6 +495,41 @@ unsigned int loadCubemap()
return textureID;
}
std::vector<glm::vec3>parse(std::string filename)
{
std::ifstream data(filename);
std::string line;
std::vector<glm::vec3> result;
while (std::getline(data, line))
{
std::stringstream lineStream(line);
std::string cell;
glm::vec3 row;
int i = 0;
while (std::getline(lineStream, cell, ','))
{
switch (i%3) {
case 0:
row.x = std::stof(cell);
break;
case 1:
row.y = std::stof(cell);
break;
case 2:
row.z = std::stof(cell);
break;
default:
break;
}
i += 1;
}
result.push_back(row);
}
return result;
}
void initSkybox()
{
glGenVertexArrays(1, &skyboxVAO);
@ -625,10 +612,16 @@ void init()
generateFishArray();
generateBubbleArray();
fishKeyPointsFirst = parse("keypoints/fishKeyPointsFirst.csv");
fishKeyPointsSecond = parse("keypoints/fishKeyPointsSecond.csv");
sharkKeyPoints = parse("keypoints/sharkKeyPoints.csv");
initKeyRotation(fishKeyPointsFirst, fishKeyRotationFirst);
initKeyRotation(fishKeyPointsSecond, fishKeyRotationSecond);
initKeyRotation(sharkKeyPoints, sharkKeyRotation);
initCube();
initSkybox();