Merge branch 'escape001' of gitea.fishrungames.com:salmon-engine-projects/space-game001 into escape001
This commit is contained in:
commit
b633aa01f5
BIN
resources/e/Wheel_base002.png
(Stored with Git LFS)
Normal file
BIN
resources/e/Wheel_base002.png
(Stored with Git LFS)
Normal file
Binary file not shown.
25478
resources/e/car001.txt
Normal file
25478
resources/e/car001.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
resources/e/car002.png
(Stored with Git LFS)
Normal file
BIN
resources/e/car002.png
(Stored with Git LFS)
Normal file
Binary file not shown.
193
resources/e/car_wheel001.txt
Normal file
193
resources/e/car_wheel001.txt
Normal file
@ -0,0 +1,193 @@
|
||||
===Vertices (Split by UV/Normal): 98
|
||||
V 0: Pos(-0.165, 0.48, 0.0) Norm(-0.67888, 0.734249, 0.0) UV(1.0, 0.5)
|
||||
V 1: Pos(0.165, 0.48, -0.0) Norm(0.67888, 0.734249, -0.0) UV(1.0, 1.0)
|
||||
V 2: Pos(0.165, 0.463644, -0.124233) Norm(0.67888, 0.70923, -0.190038) UV(0.958333, 1.0)
|
||||
V 3: Pos(-0.165, 0.463644, -0.124233) Norm(-0.67888, 0.70923, -0.190038) UV(0.958333, 0.5)
|
||||
V 4: Pos(0.165, 0.415692, -0.24) Norm(0.67888, 0.635878, -0.367125) UV(0.916667, 1.0)
|
||||
V 5: Pos(-0.165, 0.415692, -0.24) Norm(-0.67888, 0.635878, -0.367125) UV(0.916667, 0.5)
|
||||
V 6: Pos(0.165, 0.339411, -0.339411) Norm(0.67888, 0.519193, -0.519193) UV(0.875, 1.0)
|
||||
V 7: Pos(-0.165, 0.339411, -0.339411) Norm(-0.67888, 0.519193, -0.519193) UV(0.875, 0.5)
|
||||
V 8: Pos(0.165, 0.24, -0.415692) Norm(0.67888, 0.367125, -0.635878) UV(0.833333, 1.0)
|
||||
V 9: Pos(-0.165, 0.24, -0.415692) Norm(-0.67888, 0.367125, -0.635878) UV(0.833333, 0.5)
|
||||
V 10: Pos(0.165, 0.124233, -0.463644) Norm(0.67888, 0.190038, -0.70923) UV(0.791667, 1.0)
|
||||
V 11: Pos(-0.165, 0.124233, -0.463644) Norm(-0.67888, 0.190038, -0.70923) UV(0.791667, 0.5)
|
||||
V 12: Pos(0.165, 0.0, -0.48) Norm(0.67888, 0.0, -0.734249) UV(0.75, 1.0)
|
||||
V 13: Pos(-0.165, 0.0, -0.48) Norm(-0.67888, 0.0, -0.734249) UV(0.75, 0.5)
|
||||
V 14: Pos(0.165, -0.124233, -0.463644) Norm(0.67888, -0.190038, -0.70923) UV(0.708333, 1.0)
|
||||
V 15: Pos(-0.165, -0.124233, -0.463644) Norm(-0.67888, -0.190038, -0.70923) UV(0.708333, 0.5)
|
||||
V 16: Pos(0.165, -0.24, -0.415692) Norm(0.67888, -0.367125, -0.635878) UV(0.666667, 1.0)
|
||||
V 17: Pos(-0.165, -0.24, -0.415692) Norm(-0.67888, -0.367125, -0.635878) UV(0.666667, 0.5)
|
||||
V 18: Pos(0.165, -0.339411, -0.339411) Norm(0.67888, -0.519193, -0.519193) UV(0.625, 1.0)
|
||||
V 19: Pos(-0.165, -0.339411, -0.339411) Norm(-0.67888, -0.519193, -0.519193) UV(0.625, 0.5)
|
||||
V 20: Pos(0.165, -0.415692, -0.24) Norm(0.67888, -0.635878, -0.367125) UV(0.583333, 1.0)
|
||||
V 21: Pos(-0.165, -0.415692, -0.24) Norm(-0.67888, -0.635878, -0.367125) UV(0.583333, 0.5)
|
||||
V 22: Pos(0.165, -0.463644, -0.124233) Norm(0.67888, -0.70923, -0.190038) UV(0.541666, 1.0)
|
||||
V 23: Pos(-0.165, -0.463644, -0.124233) Norm(-0.67888, -0.70923, -0.190038) UV(0.541666, 0.5)
|
||||
V 24: Pos(0.165, -0.48, -0.0) Norm(0.67888, -0.734249, -0.0) UV(0.5, 1.0)
|
||||
V 25: Pos(-0.165, -0.48, 0.0) Norm(-0.67888, -0.734249, 0.0) UV(0.5, 0.5)
|
||||
V 26: Pos(0.165, -0.463644, 0.124233) Norm(0.67888, -0.70923, 0.190038) UV(0.458333, 1.0)
|
||||
V 27: Pos(-0.165, -0.463644, 0.124233) Norm(-0.67888, -0.70923, 0.190038) UV(0.458333, 0.5)
|
||||
V 28: Pos(0.165, -0.415692, 0.24) Norm(0.67888, -0.635878, 0.367125) UV(0.416666, 1.0)
|
||||
V 29: Pos(-0.165, -0.415692, 0.24) Norm(-0.67888, -0.635878, 0.367125) UV(0.416666, 0.5)
|
||||
V 30: Pos(0.165, -0.339411, 0.339411) Norm(0.67888, -0.519193, 0.519193) UV(0.375, 1.0)
|
||||
V 31: Pos(-0.165, -0.339411, 0.339411) Norm(-0.67888, -0.519193, 0.519193) UV(0.375, 0.5)
|
||||
V 32: Pos(0.165, -0.24, 0.415692) Norm(0.67888, -0.367125, 0.635878) UV(0.333333, 1.0)
|
||||
V 33: Pos(-0.165, -0.24, 0.415692) Norm(-0.67888, -0.367125, 0.635878) UV(0.333333, 0.5)
|
||||
V 34: Pos(0.165, -0.124233, 0.463644) Norm(0.67888, -0.190038, 0.70923) UV(0.291667, 1.0)
|
||||
V 35: Pos(-0.165, -0.124233, 0.463644) Norm(-0.67888, -0.190038, 0.70923) UV(0.291667, 0.5)
|
||||
V 36: Pos(0.165, 0.0, 0.48) Norm(0.67888, 0.0, 0.734249) UV(0.25, 1.0)
|
||||
V 37: Pos(-0.165, 0.0, 0.48) Norm(-0.67888, 0.0, 0.734249) UV(0.25, 0.5)
|
||||
V 38: Pos(0.165, 0.124233, 0.463644) Norm(0.67888, 0.190038, 0.70923) UV(0.208333, 1.0)
|
||||
V 39: Pos(-0.165, 0.124233, 0.463644) Norm(-0.67888, 0.190038, 0.70923) UV(0.208333, 0.5)
|
||||
V 40: Pos(0.165, 0.24, 0.415692) Norm(0.67888, 0.367125, 0.635878) UV(0.166666, 1.0)
|
||||
V 41: Pos(-0.165, 0.24, 0.415692) Norm(-0.67888, 0.367125, 0.635878) UV(0.166666, 0.5)
|
||||
V 42: Pos(0.165, 0.339411, 0.339411) Norm(0.67888, 0.519193, 0.519193) UV(0.125, 1.0)
|
||||
V 43: Pos(-0.165, 0.339411, 0.339411) Norm(-0.67888, 0.519193, 0.519193) UV(0.125, 0.5)
|
||||
V 44: Pos(0.165, 0.415692, 0.24) Norm(0.67888, 0.635878, 0.367125) UV(0.083333, 1.0)
|
||||
V 45: Pos(-0.165, 0.415692, 0.24) Norm(-0.67888, 0.635878, 0.367125) UV(0.083333, 0.5)
|
||||
V 46: Pos(0.165, 0.463644, -0.124233) Norm(0.67888, 0.70923, -0.190038) UV(0.312117, 0.481822)
|
||||
V 47: Pos(0.165, 0.48, -0.0) Norm(0.67888, 0.734249, -0.0) UV(0.25, 0.49)
|
||||
V 48: Pos(0.165, 0.463644, 0.124233) Norm(0.67888, 0.70923, 0.190038) UV(0.187883, 0.481822)
|
||||
V 49: Pos(0.165, 0.415692, 0.24) Norm(0.67888, 0.635878, 0.367125) UV(0.13, 0.457846)
|
||||
V 50: Pos(0.165, 0.339411, 0.339411) Norm(0.67888, 0.519193, 0.519193) UV(0.080294, 0.419706)
|
||||
V 51: Pos(0.165, 0.24, 0.415692) Norm(0.67888, 0.367125, 0.635878) UV(0.042154, 0.37)
|
||||
V 52: Pos(0.165, 0.124233, 0.463644) Norm(0.67888, 0.190038, 0.70923) UV(0.018178, 0.312117)
|
||||
V 53: Pos(0.165, 0.0, 0.48) Norm(0.67888, 0.0, 0.734249) UV(0.01, 0.25)
|
||||
V 54: Pos(0.165, -0.124233, 0.463644) Norm(0.67888, -0.190038, 0.70923) UV(0.018178, 0.187883)
|
||||
V 55: Pos(0.165, -0.24, 0.415692) Norm(0.67888, -0.367125, 0.635878) UV(0.042154, 0.13)
|
||||
V 56: Pos(0.165, -0.339411, 0.339411) Norm(0.67888, -0.519193, 0.519193) UV(0.080294, 0.080294)
|
||||
V 57: Pos(0.165, -0.415692, 0.24) Norm(0.67888, -0.635878, 0.367125) UV(0.13, 0.042154)
|
||||
V 58: Pos(0.165, -0.463644, 0.124233) Norm(0.67888, -0.70923, 0.190038) UV(0.187883, 0.018178)
|
||||
V 59: Pos(0.165, -0.48, -0.0) Norm(0.67888, -0.734249, -0.0) UV(0.25, 0.01)
|
||||
V 60: Pos(0.165, -0.463644, -0.124233) Norm(0.67888, -0.70923, -0.190038) UV(0.312117, 0.018178)
|
||||
V 61: Pos(0.165, -0.415692, -0.24) Norm(0.67888, -0.635878, -0.367125) UV(0.37, 0.042154)
|
||||
V 62: Pos(0.165, -0.339411, -0.339411) Norm(0.67888, -0.519193, -0.519193) UV(0.419706, 0.080294)
|
||||
V 63: Pos(0.165, -0.24, -0.415692) Norm(0.67888, -0.367125, -0.635878) UV(0.457846, 0.13)
|
||||
V 64: Pos(0.165, -0.124233, -0.463644) Norm(0.67888, -0.190038, -0.70923) UV(0.481822, 0.187883)
|
||||
V 65: Pos(0.165, 0.0, -0.48) Norm(0.67888, 0.0, -0.734249) UV(0.49, 0.25)
|
||||
V 66: Pos(0.165, 0.124233, -0.463644) Norm(0.67888, 0.190038, -0.70923) UV(0.481822, 0.312117)
|
||||
V 67: Pos(0.165, 0.24, -0.415692) Norm(0.67888, 0.367125, -0.635878) UV(0.457846, 0.37)
|
||||
V 68: Pos(0.165, 0.339411, -0.339411) Norm(0.67888, 0.519193, -0.519193) UV(0.419706, 0.419706)
|
||||
V 69: Pos(0.165, 0.415692, -0.24) Norm(0.67888, 0.635878, -0.367125) UV(0.37, 0.457846)
|
||||
V 70: Pos(0.165, 0.463644, 0.124233) Norm(0.67888, 0.70923, 0.190038) UV(0.041666, 1.0)
|
||||
V 71: Pos(-0.165, 0.463644, 0.124233) Norm(-0.67888, 0.70923, 0.190038) UV(0.041666, 0.5)
|
||||
V 72: Pos(0.165, 0.48, -0.0) Norm(0.67888, 0.734249, -0.0) UV(-0.0, 1.0)
|
||||
V 73: Pos(-0.165, 0.48, 0.0) Norm(-0.67888, 0.734249, 0.0) UV(-0.0, 0.5)
|
||||
V 74: Pos(-0.165, 0.48, 0.0) Norm(-0.67888, 0.734249, 0.0) UV(0.75, 0.49)
|
||||
V 75: Pos(-0.165, 0.463644, -0.124233) Norm(-0.67888, 0.70923, -0.190038) UV(0.812117, 0.481822)
|
||||
V 76: Pos(-0.165, 0.415692, -0.24) Norm(-0.67888, 0.635878, -0.367125) UV(0.87, 0.457846)
|
||||
V 77: Pos(-0.165, 0.339411, -0.339411) Norm(-0.67888, 0.519193, -0.519193) UV(0.919706, 0.419706)
|
||||
V 78: Pos(-0.165, 0.24, -0.415692) Norm(-0.67888, 0.367125, -0.635878) UV(0.957846, 0.37)
|
||||
V 79: Pos(-0.165, 0.124233, -0.463644) Norm(-0.67888, 0.190038, -0.70923) UV(0.981822, 0.312117)
|
||||
V 80: Pos(-0.165, 0.0, -0.48) Norm(-0.67888, 0.0, -0.734249) UV(0.99, 0.25)
|
||||
V 81: Pos(-0.165, -0.124233, -0.463644) Norm(-0.67888, -0.190038, -0.70923) UV(0.981822, 0.187883)
|
||||
V 82: Pos(-0.165, -0.24, -0.415692) Norm(-0.67888, -0.367125, -0.635878) UV(0.957846, 0.13)
|
||||
V 83: Pos(-0.165, -0.339411, -0.339411) Norm(-0.67888, -0.519193, -0.519193) UV(0.919706, 0.080294)
|
||||
V 84: Pos(-0.165, -0.415692, -0.24) Norm(-0.67888, -0.635878, -0.367125) UV(0.87, 0.042154)
|
||||
V 85: Pos(-0.165, -0.463644, -0.124233) Norm(-0.67888, -0.70923, -0.190038) UV(0.812117, 0.018178)
|
||||
V 86: Pos(-0.165, -0.48, 0.0) Norm(-0.67888, -0.734249, 0.0) UV(0.75, 0.01)
|
||||
V 87: Pos(-0.165, -0.463644, 0.124233) Norm(-0.67888, -0.70923, 0.190038) UV(0.687883, 0.018178)
|
||||
V 88: Pos(-0.165, -0.415692, 0.24) Norm(-0.67888, -0.635878, 0.367125) UV(0.63, 0.042154)
|
||||
V 89: Pos(-0.165, -0.339411, 0.339411) Norm(-0.67888, -0.519193, 0.519193) UV(0.580294, 0.080294)
|
||||
V 90: Pos(-0.165, -0.24, 0.415692) Norm(-0.67888, -0.367125, 0.635878) UV(0.542154, 0.13)
|
||||
V 91: Pos(-0.165, -0.124233, 0.463644) Norm(-0.67888, -0.190038, 0.70923) UV(0.518178, 0.187883)
|
||||
V 92: Pos(-0.165, 0.0, 0.48) Norm(-0.67888, 0.0, 0.734249) UV(0.51, 0.25)
|
||||
V 93: Pos(-0.165, 0.124233, 0.463644) Norm(-0.67888, 0.190038, 0.70923) UV(0.518178, 0.312117)
|
||||
V 94: Pos(-0.165, 0.24, 0.415692) Norm(-0.67888, 0.367125, 0.635878) UV(0.542154, 0.37)
|
||||
V 95: Pos(-0.165, 0.339411, 0.339411) Norm(-0.67888, 0.519193, 0.519193) UV(0.580294, 0.419706)
|
||||
V 96: Pos(-0.165, 0.415692, 0.24) Norm(-0.67888, 0.635878, 0.367125) UV(0.63, 0.457846)
|
||||
V 97: Pos(-0.165, 0.463644, 0.124233) Norm(-0.67888, 0.70923, 0.190038) UV(0.687883, 0.481822)
|
||||
|
||||
===Triangles (Indices): 92
|
||||
Tri: 0 1 2
|
||||
Tri: 0 2 3
|
||||
Tri: 3 2 4
|
||||
Tri: 3 4 5
|
||||
Tri: 5 4 6
|
||||
Tri: 5 6 7
|
||||
Tri: 7 6 8
|
||||
Tri: 7 8 9
|
||||
Tri: 9 8 10
|
||||
Tri: 9 10 11
|
||||
Tri: 11 10 12
|
||||
Tri: 11 12 13
|
||||
Tri: 13 12 14
|
||||
Tri: 13 14 15
|
||||
Tri: 15 14 16
|
||||
Tri: 15 16 17
|
||||
Tri: 17 16 18
|
||||
Tri: 17 18 19
|
||||
Tri: 19 18 20
|
||||
Tri: 19 20 21
|
||||
Tri: 21 20 22
|
||||
Tri: 21 22 23
|
||||
Tri: 23 22 24
|
||||
Tri: 23 24 25
|
||||
Tri: 25 24 26
|
||||
Tri: 25 26 27
|
||||
Tri: 27 26 28
|
||||
Tri: 27 28 29
|
||||
Tri: 29 28 30
|
||||
Tri: 29 30 31
|
||||
Tri: 31 30 32
|
||||
Tri: 31 32 33
|
||||
Tri: 33 32 34
|
||||
Tri: 33 34 35
|
||||
Tri: 35 34 36
|
||||
Tri: 35 36 37
|
||||
Tri: 37 36 38
|
||||
Tri: 37 38 39
|
||||
Tri: 39 38 40
|
||||
Tri: 39 40 41
|
||||
Tri: 41 40 42
|
||||
Tri: 41 42 43
|
||||
Tri: 43 42 44
|
||||
Tri: 43 44 45
|
||||
Tri: 46 47 48
|
||||
Tri: 46 48 49
|
||||
Tri: 46 49 50
|
||||
Tri: 46 50 51
|
||||
Tri: 46 51 52
|
||||
Tri: 46 52 53
|
||||
Tri: 46 53 54
|
||||
Tri: 46 54 55
|
||||
Tri: 46 55 56
|
||||
Tri: 46 56 57
|
||||
Tri: 46 57 58
|
||||
Tri: 46 58 59
|
||||
Tri: 46 59 60
|
||||
Tri: 46 60 61
|
||||
Tri: 46 61 62
|
||||
Tri: 46 62 63
|
||||
Tri: 46 63 64
|
||||
Tri: 46 64 65
|
||||
Tri: 46 65 66
|
||||
Tri: 46 66 67
|
||||
Tri: 46 67 68
|
||||
Tri: 46 68 69
|
||||
Tri: 45 44 70
|
||||
Tri: 45 70 71
|
||||
Tri: 71 70 72
|
||||
Tri: 71 72 73
|
||||
Tri: 74 75 76
|
||||
Tri: 74 76 77
|
||||
Tri: 74 77 78
|
||||
Tri: 74 78 79
|
||||
Tri: 74 79 80
|
||||
Tri: 74 80 81
|
||||
Tri: 74 81 82
|
||||
Tri: 74 82 83
|
||||
Tri: 74 83 84
|
||||
Tri: 74 84 85
|
||||
Tri: 74 85 86
|
||||
Tri: 74 86 87
|
||||
Tri: 74 87 88
|
||||
Tri: 74 88 89
|
||||
Tri: 74 89 90
|
||||
Tri: 74 90 91
|
||||
Tri: 74 91 92
|
||||
Tri: 74 92 93
|
||||
Tri: 74 93 94
|
||||
Tri: 74 94 95
|
||||
Tri: 74 95 96
|
||||
Tri: 74 96 97
|
||||
29
src/Game.cpp
29
src/Game.cpp
@ -258,6 +258,7 @@ namespace ZL
|
||||
{
|
||||
if (currentLocation)
|
||||
{
|
||||
/*
|
||||
if (currentLocation->shadowMap) {
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
currentLocation->drawShadowDepthPass();
|
||||
@ -265,10 +266,10 @@ namespace ZL
|
||||
currentLocation->drawGameWithShadows();
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
}
|
||||
else {
|
||||
else {*/
|
||||
currentLocation->drawGame();
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
}
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -515,10 +516,24 @@ namespace ZL
|
||||
break;
|
||||
|
||||
case SDLK_p:
|
||||
x = x + 0.01;
|
||||
break;
|
||||
case SDLK_o:
|
||||
x = x - 0.01;
|
||||
break;
|
||||
|
||||
case SDLK_l:
|
||||
//currentLocation->carPosition += Eigen::Vector3f(0.f, 0.f, -1.f);
|
||||
currentLocation->inCar = !currentLocation->inCar;
|
||||
break;
|
||||
|
||||
case SDLK_w:
|
||||
case SDLK_s:
|
||||
case SDLK_a:
|
||||
case SDLK_d:
|
||||
if (currentLocation) currentLocation->handleKeyDown(event.key.keysym.sym);
|
||||
break;
|
||||
|
||||
case SDLK_RETURN:
|
||||
|
||||
default:
|
||||
@ -547,7 +562,15 @@ namespace ZL
|
||||
}
|
||||
|
||||
if (event.type == SDL_KEYUP) {
|
||||
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_w:
|
||||
case SDLK_s:
|
||||
case SDLK_a:
|
||||
case SDLK_d:
|
||||
if (currentLocation) currentLocation->handleKeyUp(event.key.keysym.sym);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
143
src/Location.cpp
143
src/Location.cpp
@ -16,6 +16,7 @@
|
||||
|
||||
namespace ZL
|
||||
{
|
||||
extern float x;
|
||||
extern const char* CONST_ZIP_FILE;
|
||||
|
||||
static constexpr float CAMERA_FOV_Y = 1.0f / 1.5f;
|
||||
@ -36,6 +37,12 @@ namespace ZL
|
||||
roomMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
roomMesh.RefreshVBO();
|
||||
|
||||
carTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/e/car002.png", CONST_ZIP_FILE));
|
||||
carMesh.data = LoadFromTextFile02("resources/e/car001.txt", CONST_ZIP_FILE);
|
||||
//carMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
carMesh.RefreshVBO();
|
||||
|
||||
|
||||
// Load static game objects
|
||||
gameObjects = GameObjectLoader::loadAndCreateGameObjects("resources/config2/gameobjects.json", renderer, CONST_ZIP_FILE);
|
||||
|
||||
@ -149,6 +156,16 @@ namespace ZL
|
||||
roomMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
roomMesh.RefreshVBO();
|
||||
|
||||
carTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/e/car002.png", CONST_ZIP_FILE));
|
||||
carMesh.data = LoadFromTextFile02("resources/e/car001.txt", CONST_ZIP_FILE);
|
||||
carMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
carMesh.RefreshVBO();
|
||||
|
||||
carWheelTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/e/Wheel_base002.png", CONST_ZIP_FILE));
|
||||
carWheelMesh.data = LoadFromTextFile02("resources/e/car_wheel001.txt", CONST_ZIP_FILE);
|
||||
carWheelMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
carWheelMesh.RefreshVBO();
|
||||
|
||||
gameObjects = GameObjectLoader::loadAndCreateGameObjects(gameObjectsPath, renderer, CONST_ZIP_FILE);
|
||||
|
||||
interactiveObjects = GameObjectLoader::loadAndCreateInteractiveObjects(interactiveObjectsPath, renderer, CONST_ZIP_FILE);
|
||||
@ -216,7 +233,8 @@ void Location::setup()
|
||||
debugNavMeshes.clear();
|
||||
|
||||
roomMesh.data = VertexDataStruct();
|
||||
roomMesh.RefreshVBO();
|
||||
//roomMesh.data = LoadFromTextFile02("resources/w/road001.txt", CONST_ZIP_FILE);
|
||||
//roomMesh.RefreshVBO();
|
||||
roomTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/w/room005.png", CONST_ZIP_FILE));
|
||||
|
||||
struct ModelAsset {
|
||||
@ -343,6 +361,17 @@ void Location::setup()
|
||||
dialogueSystem.init(renderer, CONST_ZIP_FILE);
|
||||
dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
|
||||
}
|
||||
|
||||
carTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/e/car002.png", CONST_ZIP_FILE));
|
||||
carMesh.data = LoadFromTextFile02("resources/e/car001.txt", CONST_ZIP_FILE);
|
||||
carMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
carMesh.RefreshVBO();
|
||||
|
||||
carWheelTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/e/Wheel_base002.png", CONST_ZIP_FILE));
|
||||
carWheelMesh.data = LoadFromTextFile02("resources/e/car_wheel001.txt", CONST_ZIP_FILE);
|
||||
carWheelMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
carWheelMesh.RefreshVBO();
|
||||
|
||||
}
|
||||
|
||||
void Location::setupNavigation()
|
||||
@ -519,11 +548,14 @@ void Location::setup()
|
||||
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(cameraInclination, Eigen::Vector3f::UnitX())).toRotationMatrix());
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(cameraAzimuth, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
const Eigen::Vector3f& camTarget = player ? player->position : Eigen::Vector3f::Zero();
|
||||
Eigen::Vector3f camTarget = inCar ? carPosition : (player ? player->position : Eigen::Vector3f::Zero());
|
||||
renderer.TranslateMatrix({ -camTarget.x(), -camTarget.y(), -camTarget.z() });
|
||||
|
||||
if (roomMesh.data.PositionData.size() > 0)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, roomTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(roomMesh);
|
||||
}
|
||||
|
||||
for (auto& [name, gameObj] : gameObjects) {
|
||||
if (name == roofObjectKey && !roofVisible) {
|
||||
@ -533,21 +565,46 @@ void Location::setup()
|
||||
renderer.DrawVertexRenderStruct(gameObj.mesh);
|
||||
}
|
||||
|
||||
/*
|
||||
glBindTexture(GL_TEXTURE_2D, fireboxTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(fireboxMesh);
|
||||
glBindTexture(GL_TEXTURE_2D, inaiTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(inaiMesh);
|
||||
glBindTexture(GL_TEXTURE_2D, benchTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(benchMesh);
|
||||
*/
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
if (intObj.isActive) {
|
||||
intObj.draw(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
if (player) player->draw(renderer);
|
||||
renderer.PushMatrix();
|
||||
//renderer.LoadIdentity();
|
||||
renderer.TranslateMatrix(carPosition);
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(carRotation, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
glBindTexture(GL_TEXTURE_2D, carTexture->getTexID());
|
||||
renderer.DrawVertexRenderStruct(carMesh);
|
||||
|
||||
if (carWheelTexture) {
|
||||
constexpr float track_width = 1.28f;
|
||||
constexpr float wheel_base = 2.25f;
|
||||
constexpr float shift = 0.6f;
|
||||
const Eigen::Vector3f wheelPositions[4] = {
|
||||
Eigen::Vector3f( track_width, 0.f - 0.21, -(wheel_base + shift)+1.25), // front right
|
||||
Eigen::Vector3f(-track_width, 0.f - 0.21, -(wheel_base + shift)+1.25), // front left
|
||||
Eigen::Vector3f( track_width, 0.f - 0.21, (wheel_base - shift)+1.1), // rear right
|
||||
Eigen::Vector3f(-track_width, 0.f - 0.21, (wheel_base - shift)+1.1) // rear left
|
||||
};
|
||||
const bool isFront[4] = { true, true, false, false };
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, carWheelTexture->getTexID());
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
renderer.PushMatrix();
|
||||
renderer.TranslateMatrix(wheelPositions[i]);
|
||||
if (isFront[i]) {
|
||||
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(carSteeringAngle, Eigen::Vector3f::UnitY())).toRotationMatrix());
|
||||
}
|
||||
renderer.DrawVertexRenderStruct(carWheelMesh);
|
||||
renderer.PopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
if (player && !inCar) player->draw(renderer);
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
//#ifdef SHOW_PATH
|
||||
@ -759,7 +816,45 @@ void Location::setup()
|
||||
}
|
||||
for (auto& npc : npcs) npc->update(delta);
|
||||
|
||||
if (inCar) {
|
||||
float dt = static_cast<float>(delta) / 1000.0f;
|
||||
|
||||
if (keyForward) {
|
||||
carVelocity += carAcceleration * dt;
|
||||
}
|
||||
if (keyBackward) {
|
||||
carVelocity -= carAcceleration * dt;
|
||||
}
|
||||
|
||||
if (!keyForward && !keyBackward) {
|
||||
float resistance = carFriction * dt;
|
||||
if (carVelocity > 0.f) {
|
||||
carVelocity = max(0.f, carVelocity - resistance);
|
||||
} else if (carVelocity < 0.f) {
|
||||
carVelocity = min(0.f, carVelocity + resistance);
|
||||
}
|
||||
}
|
||||
|
||||
carVelocity = max(-carMaxReverseSpeed, min(carMaxSpeed, carVelocity));
|
||||
|
||||
if (std::abs(carVelocity) > 0.01f) {
|
||||
float speedFactor = carVelocity / carMaxSpeed;
|
||||
if (keyLeft) carRotation += carTurnRate * dt * speedFactor;
|
||||
if (keyRight) carRotation -= carTurnRate * dt * speedFactor;
|
||||
}
|
||||
|
||||
float targetSteer = (keyLeft ? 1.f : 0.f) - (keyRight ? 1.f : 0.f);
|
||||
targetSteer *= carMaxSteerAngle;
|
||||
float steerLerp = min(1.f, dt * 8.f);
|
||||
carSteeringAngle += (targetSteer - carSteeringAngle) * steerLerp;
|
||||
|
||||
Eigen::Vector3f forward(-std::sin(carRotation), 0.f, -std::cos(carRotation));
|
||||
carPosition += forward * carVelocity * dt;
|
||||
|
||||
if (player) {
|
||||
player->position = carPosition;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if player reached target interactive object
|
||||
if (targetInteractiveObject && player) {
|
||||
@ -798,6 +893,10 @@ void Location::setup()
|
||||
return;
|
||||
}
|
||||
|
||||
if (inCar) {
|
||||
return;
|
||||
}
|
||||
|
||||
player->attackTarget = nullptr;
|
||||
|
||||
// Unproject click to ground plane (y=0) for Viola's walk target
|
||||
@ -909,6 +1008,28 @@ void Location::setup()
|
||||
}
|
||||
}
|
||||
|
||||
void Location::handleKeyDown(int sdlKey)
|
||||
{
|
||||
switch (sdlKey) {
|
||||
case SDLK_w: keyForward = true; break;
|
||||
case SDLK_s: keyBackward = true; break;
|
||||
case SDLK_a: keyLeft = true; break;
|
||||
case SDLK_d: keyRight = true; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void Location::handleKeyUp(int sdlKey)
|
||||
{
|
||||
switch (sdlKey) {
|
||||
case SDLK_w: keyForward = false; break;
|
||||
case SDLK_s: keyBackward = false; break;
|
||||
case SDLK_a: keyLeft = false; break;
|
||||
case SDLK_d: keyRight = false; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Location::requestDialogueStart(const std::string& dialogueId)
|
||||
{
|
||||
return dialogueSystem.startDialogue(dialogueId);
|
||||
|
||||
@ -39,6 +39,32 @@ namespace ZL
|
||||
Eigen::Matrix4f cameraViewMatrix = Eigen::Matrix4f::Identity();
|
||||
InteractiveObject* targetInteractiveObject = nullptr;
|
||||
|
||||
|
||||
std::shared_ptr<Texture> carTexture;
|
||||
VertexRenderStruct carMesh;
|
||||
std::shared_ptr<Texture> carWheelTexture;
|
||||
VertexRenderStruct carWheelMesh;
|
||||
Vector3f carPosition = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||
float carRotation = 0.f;
|
||||
|
||||
float carVelocity = 0.f;
|
||||
float carAcceleration = 20.0f;
|
||||
float carFriction = 6.0f;
|
||||
float carMaxSpeed = 20.0f;
|
||||
float carMaxReverseSpeed = 8.0f;
|
||||
float carTurnRate = 1.8f;
|
||||
|
||||
float carSteeringAngle = 0.f;
|
||||
float carMaxSteerAngle = 0.6f;
|
||||
|
||||
bool keyForward = false;
|
||||
bool keyBackward = false;
|
||||
bool keyLeft = false;
|
||||
bool keyRight = false;
|
||||
|
||||
bool inCar = false;
|
||||
|
||||
|
||||
ScriptEngine scriptEngine;
|
||||
Dialogue::DialogueSystem dialogueSystem;
|
||||
|
||||
@ -68,6 +94,8 @@ namespace ZL
|
||||
void handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
||||
void handleUp(int64_t fingerId, int mx, int my);
|
||||
void handleMotion(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
||||
void handleKeyDown(int sdlKey);
|
||||
void handleKeyUp(int sdlKey);
|
||||
|
||||
bool requestDialogueStart(const std::string& dialogueId);
|
||||
void setDialogueFlag(const std::string& flag, int value);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user