Working on taxi car

This commit is contained in:
Vladislav Khorev 2026-07-14 14:07:53 +03:00
parent 38e45d67b8
commit 35a2a91178
21 changed files with 26446 additions and 45 deletions

View File

@ -60,6 +60,8 @@ add_executable(witcher001
../src/LocationState.cpp ../src/LocationState.cpp
../src/LocationEditor.h ../src/LocationEditor.h
../src/LocationEditor.cpp ../src/LocationEditor.cpp
../src/NpcCar.h
../src/NpcCar.cpp
../src/GameConstants.h ../src/GameConstants.h
../src/GameConstants.cpp ../src/GameConstants.cpp
../src/GameState.h ../src/GameState.h

View File

@ -26,14 +26,13 @@
}, },
{ {
"name": "car001", "name": "car001",
"texturePath": "resources/w/exterior/car_body001_002.png", "texturePath": "resources/e/car4096blue_v002.png",
"textureDarkandsPath": "resources/w/exterior/car_body001_002.png", "meshPath": "resources/e/car004.txt",
"meshPath": "resources/w/exterior/car001.txt.bin",
"rotationX": 0.0, "rotationX": 0.0,
"rotationY": 90.0, "rotationY": 90.0,
"rotationZ": 0.0, "rotationZ": 0.0,
"positionX": -10.5, "positionX": -10.5,
"positionY": 0.0, "positionY": 0.55,
"positionZ": -14.4195, "positionZ": -14.4195,
"approachRadius": 0.5, "approachRadius": 0.5,
"boundsMaxX": 0.8858480453491211, "boundsMaxX": 0.8858480453491211,
@ -51,8 +50,7 @@
}, },
{ {
"name": "car001wheels", "name": "car001wheels",
"texturePath": "resources/w/exterior/Wheel_base002.png", "texturePath": "resources/w/exterior/Wheel_base003.png",
"textureDarkandsPath": "resources/w/exterior/Wheel_base002.png",
"meshPath": "resources/w/exterior/wheels002.txt.bin", "meshPath": "resources/w/exterior/wheels002.txt.bin",
"rotationX": 0.0, "rotationX": 0.0,
"rotationY": 90.0, "rotationY": 90.0,

View File

@ -277,8 +277,8 @@
}, },
{ {
"name": "car001", "name": "car001",
"texturePath": "resources/w/exterior/car_body001_002.png", "texturePath": "resources/e/car4096blue_v002.png",
"meshPath": "resources/w/exterior/car001.txt.bin", "meshPath": "resources/e/car004.txt",
"rotationX": 0.0, "rotationX": 0.0,
"rotationY": 90.0, "rotationY": 90.0,
"rotationZ": 0.0, "rotationZ": 0.0,
@ -300,7 +300,7 @@
}, },
{ {
"name": "car001wheels", "name": "car001wheels",
"texturePath": "resources/w/exterior/Wheel_base002.png", "texturePath": "resources/w/exterior/Wheel_base003.png",
"meshPath": "resources/w/exterior/wheels002.txt.bin", "meshPath": "resources/w/exterior/wheels002.txt.bin",
"rotationX": 0.0, "rotationX": 0.0,
"rotationY": 90.0, "rotationY": 90.0,

View File

@ -484,6 +484,53 @@
"targetInteractNpcIndex": -1, "targetInteractNpcIndex": -1,
"targetInteractiveObjectIndex": -1, "targetInteractiveObjectIndex": -1,
"targetTeleportZoneIndex": -1, "targetTeleportZoneIndex": -1,
"taxi": {
"taxiArrivedCallbackCalled": false,
"taxiCar": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -20.850000381469727,
"positionY": 0.0,
"positionZ": 64.0,
"rotation": 0.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 5.0,
"waypoints": []
},
"taxiCarInitialState": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -20.850000381469727,
"positionY": 0.0,
"positionZ": 64.0,
"rotation": 0.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 5.0,
"waypoints": []
},
"taxiCarTriggerPositionX": -19.0,
"taxiCarTriggerPositionY": 0.0,
"taxiCarTriggerPositionZ": 0.0,
"taxiDefaultWaypoints": [
{
"x": -20.850000381469727,
"y": 0.0,
"z": 30.0
},
{
"x": -19.350000381469727,
"y": 0.0,
"z": 24.0
},
{
"x": -19.350000381469727,
"y": 0.0,
"z": 14.0
}
]
},
"tutorialInteractiveObjectsLocked": true "tutorialInteractiveObjectsLocked": true
}, },
"npcStates": [ "npcStates": [
@ -522,6 +569,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
-6.296899795532227, -6.296899795532227,
0.0, 0.0,
@ -564,6 +612,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
6.8031005859375, 6.8031005859375,
0.0, 0.0,
@ -616,7 +665,7 @@
"isActive": true, "isActive": true,
"isAnimating": false, "isAnimating": false,
"positionX": -10.496715545654297, "positionX": -10.496715545654297,
"positionY": 0.8919645547866821, "positionY": 0.901249885559082,
"positionZ": -13.977367401123047, "positionZ": -13.977367401123047,
"rotationY": 0.0, "rotationY": 0.0,
"scale": 1.0 "scale": 1.0
@ -642,6 +691,53 @@
"targetInteractNpcIndex": -1, "targetInteractNpcIndex": -1,
"targetInteractiveObjectIndex": -1, "targetInteractiveObjectIndex": -1,
"targetTeleportZoneIndex": -1, "targetTeleportZoneIndex": -1,
"taxi": {
"taxiArrivedCallbackCalled": false,
"taxiCar": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -17.600000381469727,
"positionY": 0.05000000074505806,
"positionZ": -100.0,
"rotation": 180.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 5.0,
"waypoints": []
},
"taxiCarInitialState": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -17.600000381469727,
"positionY": 0.05000000074505806,
"positionZ": -100.0,
"rotation": 180.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 5.0,
"waypoints": []
},
"taxiCarTriggerPositionX": -17.600000381469727,
"taxiCarTriggerPositionY": 0.05000000074505806,
"taxiCarTriggerPositionZ": -45.0,
"taxiDefaultWaypoints": [
{
"x": -17.600000381469727,
"y": 0.05000000074505806,
"z": -90.0
},
{
"x": -17.600000381469727,
"y": 0.05000000074505806,
"z": -75.0
},
{
"x": -17.600000381469727,
"y": 0.05000000074505806,
"z": -55.0
}
]
},
"tutorialInteractiveObjectsLocked": false "tutorialInteractiveObjectsLocked": false
}, },
"npcStates": [], "npcStates": [],
@ -674,6 +770,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
5.0, 5.0,
0.0, 0.0,
@ -778,7 +875,7 @@
"isActive": true, "isActive": true,
"isAnimating": false, "isAnimating": false,
"positionX": -4.959765434265137, "positionX": -4.959765434265137,
"positionY": 0.919700026512146, "positionY": 0.935509979724884,
"positionZ": 2.3698995113372803, "positionZ": 2.3698995113372803,
"rotationY": 0.0, "rotationY": 0.0,
"scale": 1.0 "scale": 1.0
@ -828,7 +925,7 @@
"isActive": true, "isActive": true,
"isAnimating": false, "isAnimating": false,
"positionX": -10.496715545654297, "positionX": -10.496715545654297,
"positionY": -4.108035564422607, "positionY": -4.648750305175781,
"positionZ": -13.977367401123047, "positionZ": -13.977367401123047,
"rotationY": 0.0, "rotationY": 0.0,
"scale": 1.0 "scale": 1.0
@ -999,6 +1096,37 @@
"targetInteractNpcIndex": -1, "targetInteractNpcIndex": -1,
"targetInteractiveObjectIndex": -1, "targetInteractiveObjectIndex": -1,
"targetTeleportZoneIndex": -1, "targetTeleportZoneIndex": -1,
"taxi": {
"taxiArrivedCallbackCalled": false,
"taxiCar": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -100.0,
"positionY": -100.0,
"positionZ": -100.0,
"rotation": 0.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 3.0,
"waypoints": []
},
"taxiCarInitialState": {
"currentWaypoint": 0,
"mode": 1,
"positionX": -100.0,
"positionY": -100.0,
"positionZ": -100.0,
"rotation": 0.0,
"steeringAngle": 0.0,
"velocity": 0.0,
"waypointReachRadius": 3.0,
"waypoints": []
},
"taxiCarTriggerPositionX": -1.7014118346046923e+38,
"taxiCarTriggerPositionY": -1.7014118346046923e+38,
"taxiCarTriggerPositionZ": -1.7014118346046923e+38,
"taxiDefaultWaypoints": []
},
"tutorialInteractiveObjectsLocked": false "tutorialInteractiveObjectsLocked": false
}, },
"npcStates": [ "npcStates": [
@ -1037,6 +1165,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
-0.31001949310302734, -0.31001949310302734,
0.0, 0.0,
@ -1078,6 +1207,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
0.7899808883666992, 0.7899808883666992,
0.0, 0.0,
@ -1095,32 +1225,33 @@
"facingAngle": 0.0, "facingAngle": 0.0,
"homeDriftCheckTimer": 5.0, "homeDriftCheckTimer": 5.0,
"homePosition": [ "homePosition": [
-0.2859399914741516, 0.0,
0.0, 0.0,
13.964099884033203 13.964099884033203
], ],
"hp": 35.0, "hp": 35.0,
"pathWaypoints": [ "pathWaypoints": [
[ [
-0.31001949310302734, -0.010019302368164063,
0.0, 0.0,
13.974998474121094 13.974998474121094
] ]
], ],
"position": [ "position": [
-0.2859399914741516, 0.0,
0.0, 0.0,
13.964099884033203 13.964099884033203
], ],
"requestedWalkTarget": [ "requestedWalkTarget": [
-0.2859399914741516, 0.0,
0.0, 0.0,
13.964099884033203 13.964099884033203
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 5.5,
"walkTarget": [ "walkTarget": [
-0.31001949310302734, -0.010019302368164063,
0.0, 0.0,
13.974998474121094 13.974998474121094
] ]
@ -1160,6 +1291,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.5,
"walkTarget": [ "walkTarget": [
-0.010019302368164063, -0.010019302368164063,
0.0, 0.0,
@ -1201,6 +1333,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
-5.010019302368164, -5.010019302368164,
0.0, 0.0,
@ -1242,6 +1375,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 4.800000190734863,
"walkTarget": [ "walkTarget": [
4.889980316162109, 4.889980316162109,
0.0, 0.0,
@ -1283,6 +1417,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
3.989980697631836, 3.989980697631836,
0.0, 0.0,
@ -1325,6 +1460,7 @@
], ],
"showWeapon": true, "showWeapon": true,
"targetFacingAngle": 0.0, "targetFacingAngle": 0.0,
"visibleRange": 6.0,
"walkTarget": [ "walkTarget": [
0.9899806976318359, 0.9899806976318359,
0.0, 0.0,
@ -1341,7 +1477,7 @@
"morning_did_open_door_index": 0, "morning_did_open_door_index": 0,
"player_hold_book": false, "player_hold_book": false,
"player_hold_knife": false, "player_hold_knife": false,
"teacher_arrived": false, "teacher_arrived_to_library": false,
"teacher_door_opened": false, "teacher_door_opened": false,
"teacher_told_about_book": false, "teacher_told_about_book": false,
"was_day_when_player_left": 0, "was_day_when_player_left": 0,
@ -1516,7 +1652,8 @@
} }
] ]
}, },
"savedAt": "2026-07-08 15:45", "savedAt": "2026-07-14 14:00",
"taxiIsCalled": false,
"tutorialJournalPickedUp": false, "tutorialJournalPickedUp": false,
"tutorialJournalScreenOpened": false, "tutorialJournalScreenOpened": false,
"tutorialNeedOpenTaxiScreen": false, "tutorialNeedOpenTaxiScreen": false,

25497
resources/e/car004.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
resources/e/car4096_v002.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
resources/e/car4096blue_v002.png (Stored with Git LFS) Normal file

Binary file not shown.

View 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

BIN
resources/w/exterior/Wheel_base002.png (Stored with Git LFS)

Binary file not shown.

BIN
resources/w/exterior/Wheel_base003.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -230,8 +230,20 @@ namespace ZL
// so it stays a single synchronous function rather than being split into // so it stays a single synchronous function rather than being split into
// per-location queue steps; it's queued here as one coarse step. // per-location queue steps; it's queued here as one coarse step.
loadSteps.push([this]() { loadSteps.push([this]() {
createLocations(); createLocationsStep1();
}); });
loadSteps.push([this]() {
createLocationsStep2();
});
loadSteps.push([this]() {
createLocationsStep3();
});
loadSteps.push([this]() {
createLocationsStep4();
});
loadSteps.push([this]() {
createLocationsStep5();
});
loadSteps.push([this]() { loadSteps.push([this]() {
// Wire inventory callbacks: tutorial tracking + toast notifications. // Wire inventory callbacks: tutorial tracking + toast notifications.
@ -392,7 +404,11 @@ namespace ZL
} }
gameState.inventory.clear(); gameState.inventory.clear();
gameState.questJournal.loadFromFile(localizedConfigPath("resources/config/quests.json", g_currentLanguage), CONST_ZIP_FILE); gameState.questJournal.loadFromFile(localizedConfigPath("resources/config/quests.json", g_currentLanguage), CONST_ZIP_FILE);
createLocations(); createLocationsStep1();
createLocationsStep2();
createLocationsStep3();
createLocationsStep4();
createLocationsStep5();
// Developer workflow: uncomment to (re)generate resources/config/start_state.json // Developer workflow: uncomment to (re)generate resources/config/start_state.json
// from this freshly-rebuilt state after changing gameplay/content JSON or Lua. // from this freshly-rebuilt state after changing gameplay/content JSON or Lua.
@ -432,25 +448,30 @@ namespace ZL
void Game::saveInitialState() { void Game::saveInitialState() {
nlohmann::json root; nlohmann::json root;
gameState.save(root); gameState.save(root);
const std::string path = "resources/config/start_state.json"; const std::string path = "start_state.json";
/* std::cout << "[reset] saveInitialState called, to " << path << std::endl;
std::ofstream file(path); std::ofstream file(path);
if (file.is_open()) { if (file.is_open()) {
file << root.dump(2); file << root.dump(2);
std::cout << "[reset] Saved initial state snapshot to " << path << std::endl; std::cout << "[reset] Saved initial state snapshot to " << path << std::endl;
} else { } else {
std::cerr << "[reset] Could not open " << path << " for writing" << std::endl; std::cerr << "[reset] Could not open " << path << " for writing" << std::endl;
}*/ }
saveJsonToFile(root, path); saveJsonToFile(root, path);
} }
void Game::createLocations() void Game::createLocationsStep1()
{ {
gameState.locations.clear(); gameState.locations.clear();
gameState.globalFloats["player_hp"] = 200; gameState.globalFloats["player_hp"] = 200;
}
void Game::createLocationsStep2()
{
LocationSetup uniInteriorParams; LocationSetup uniInteriorParams;
uniInteriorParams.gameObjectsJsonPath = "resources/config/gameobjects_uni_interior_x.json"; uniInteriorParams.gameObjectsJsonPath = "resources/config/gameobjects_uni_interior_x.json";
uniInteriorParams.npcsJsonPath = "resources/config/npcs_uni_interior.json"; uniInteriorParams.npcsJsonPath = "resources/config/npcs_uni_interior.json";
@ -553,16 +574,32 @@ namespace ZL
gameState.locations["uni_interior"]->requestDarklandsPlayNormalMusic = [this]() { gameState.locations["uni_interior"]->requestDarklandsPlayNormalMusic = [this]() {
audioPlayer->crossFadeMusicFromPositionAsync("audio/bishkek fight calm.ogg"); audioPlayer->crossFadeMusicFromPositionAsync("audio/bishkek fight calm.ogg");
}; };
}
void Game::createLocationsStep3()
{
LocationSetup uniInteriorParams;
LocationSetup uniExteriorParams = uniInteriorParams; LocationSetup uniExteriorParams = uniInteriorParams;
uniExteriorParams.gameObjectsJsonPath = "resources/config/gameobjects_uni_exterior_x.json"; uniExteriorParams.gameObjectsJsonPath = "resources/config/gameobjects_uni_exterior_x.json";
uniExteriorParams.interactiveObjectsJsonPath = "resources/config/interactive_objects_uni_exterior_x.json"; uniExteriorParams.interactiveObjectsJsonPath = "resources/config/interactive_objects_uni_exterior_x.json";
//uniExteriorParams.navigationJsonPaths = {"resources/navigation/uni_exterior3_all.json"};
/* /*
uniExteriorParams.navigationJsonPaths = { uniExteriorParams.navigationJsonPaths = {
"resources/navigation/uni_exterior3_trees_car.json", "resources/navigation/uni_exterior0.json",
"resources/navigation/uni_exterior3_trees.json", "resources/navigation/uni_exterior0.json"
};*/ };*/
//uni_exterior0
/*uniExteriorParams.navigationJsonPaths = {
"resources/navigation/uni_exterior3_all.json",
"resources/navigation/uni_exterior3_all.json"
};*/
/*
uniExteriorParams.navigationJsonPaths = {
"resources/navigation/uni_exterior3_trees_car.json",
"resources/navigation/uni_exterior3_trees.json",
};*/
uniExteriorParams.navigationJsonPaths = { uniExteriorParams.navigationJsonPaths = {
"resources/navigation/uni_exterior3_trees_car.txt", "resources/navigation/uni_exterior3_trees_car.txt",
@ -585,7 +622,7 @@ namespace ZL
gameState.locations["uni_exterior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) { gameState.locations["uni_exterior"]->requestNightDayTransition = [this](bool isNight, bool isDawn) {
gameState.isNight = isNight; gameState.isNight = isNight;
gameState.isDawn = isDawn; gameState.isDawn = isDawn;
}; };
gameState.locations["uni_exterior"]->requestDarklandsTransition = [this]() { return startDarklandsTransition(); }; gameState.locations["uni_exterior"]->requestDarklandsTransition = [this]() { return startDarklandsTransition(); };
gameState.locations["uni_exterior"]->requestClosePhone = [this]() { menuManager.closePhoneEntirely(); }; gameState.locations["uni_exterior"]->requestClosePhone = [this]() { menuManager.closePhoneEntirely(); };
gameState.locations["uni_exterior"]->requestReturnToMainMenu = [this]() { menuManager.showMainMenu(); }; gameState.locations["uni_exterior"]->requestReturnToMainMenu = [this]() { menuManager.showMainMenu(); };
@ -595,6 +632,34 @@ namespace ZL
if (gameState.locations["uni_exterior"]->player) if (gameState.locations["uni_exterior"]->player)
gameState.locations["uni_exterior"]->player->state.onDeathAnimComplete = [this]() { startDarklandsTransition(); }; gameState.locations["uni_exterior"]->player->state.onDeathAnimComplete = [this]() { startDarklandsTransition(); };
//Exterior set up taxi:
gameState.locations["uni_exterior"]->state.taxiCarTriggerPosition = Eigen::Vector3f(-17.6, 0.05, -45);
gameState.locations["uni_exterior"]->state.taxiCarWaypoints = {
Vector3f(-17.6, 0.05, -90.0),
Vector3f(-17.6, 0.05, -75.0),
Vector3f(-17.6, 0.05, -55.0)
};
gameState.locations["uni_exterior"]->state.taxiCarInitialState.position = /*Vector3f(-17.6, 0.05, -40);*/ Vector3f(-17.6, 0.05, -100);
gameState.locations["uni_exterior"]->state.taxiCarInitialState.rotation = 180.f;
gameState.locations["uni_exterior"]->state.taxiCarInitialState.mode = NpcCar::Mode::NONE;
gameState.locations["uni_exterior"]->state.taxiCarInitialState.velocity = 0.f;
gameState.locations["uni_exterior"]->state.taxiCarInitialState.steeringAngle = 0.f;
gameState.locations["uni_exterior"]->state.taxiCarInitialState.waypointReachRadius = 5.f;
gameState.locations["uni_exterior"]->state.taxiCar = gameState.locations["uni_exterior"]->state.taxiCarInitialState;
//Exterior set up taxi end
}
void Game::createLocationsStep4()
{
LocationSetup params_dorm; LocationSetup params_dorm;
//params_dorm.gameObjectsJsonPath = "resources/config/gameobjects_dorm.json"; //params_dorm.gameObjectsJsonPath = "resources/config/gameobjects_dorm.json";
//params_dorm.gameObjectsJsonPath = "resources/config/gameobjects_dorm_trees001.json"; //params_dorm.gameObjectsJsonPath = "resources/config/gameobjects_dorm_trees001.json";
@ -654,6 +719,35 @@ namespace ZL
gameState.locations["location_dorm"]->state.tutorialInteractiveObjectsLocked = true; gameState.locations["location_dorm"]->state.tutorialInteractiveObjectsLocked = true;
//Dorm set up taxi:
gameState.locations["location_dorm"]->state.taxiCarTriggerPosition = Eigen::Vector3f(-19.0, 0, 0);
gameState.locations["location_dorm"]->state.taxiCarWaypoints = {
Vector3f(-20.85, 0, 30.0),
Vector3f(-19.35, 0, 24.0),
Vector3f(-19.35, 0, 14.0)
};
gameState.locations["location_dorm"]->state.taxiCarInitialState.position = Vector3f(-20.85, 0, 64);
gameState.locations["location_dorm"]->state.taxiCarInitialState.rotation = 0.f;
gameState.locations["location_dorm"]->state.taxiCarInitialState.mode = NpcCar::Mode::NONE;
gameState.locations["location_dorm"]->state.taxiCarInitialState.velocity = 0.f;
gameState.locations["location_dorm"]->state.taxiCarInitialState.steeringAngle = 0.f;
gameState.locations["location_dorm"]->state.taxiCarInitialState.waypointReachRadius = 5.f;
gameState.locations["location_dorm"]->state.taxiCar = gameState.locations["location_dorm"]->state.taxiCarInitialState;
//Dorm set up taxi end
}
void Game::createLocationsStep5()
{
rearmDormOneShotCallbacks(); rearmDormOneShotCallbacks();
menuManager.callTaxiFunc = [this]() menuManager.callTaxiFunc = [this]()
@ -665,7 +759,7 @@ namespace ZL
if (currentLocation()) if (currentLocation())
{ {
currentLocation()->scriptEngine.callCallTaxiCallback(); currentLocation()->onTaxiCalled();
} }
}; };
@ -697,6 +791,11 @@ namespace ZL
loc->state.isDawn = gameState.isDawn; loc->state.isDawn = gameState.isDawn;
loc->scriptEngine.callLocationEnterCallback(); loc->scriptEngine.callLocationEnterCallback();
//Reset taxi
loc->state.taxiCar = loc->state.taxiCarInitialState;
loc->state.taxiArrivedCallbackCalled = false;
gameState.taxiIsCalled = false;
menuManager.onLocationChanged(destName); menuManager.onLocationChanged(destName);
}; };
@ -1251,7 +1350,7 @@ namespace ZL
break; break;
case SDLK_o: case SDLK_o:
x = x + 1; x = x + 0.05;
std::cout << "current x: " << x << std::endl; std::cout << "current x: " << x << std::endl;
//y = y + 0.002; //y = y + 0.002;
//currentLocation->player->hp = 200; //currentLocation->player->hp = 200;
@ -1260,7 +1359,7 @@ namespace ZL
break; break;
case SDLK_k: case SDLK_k:
x = x - 1; x = x - 0.05;
std::cout << "current x: " << x << std::endl; std::cout << "current x: " << x << std::endl;
std::cout << "Player pos: " << currentLocation()->player->state.position.transpose() << std::endl; std::cout << "Player pos: " << currentLocation()->player->state.position.transpose() << std::endl;
std::cout << "Player rotation: " << currentLocation()->player->state.facingAngle*180.0/M_PI << std::endl; std::cout << "Player rotation: " << currentLocation()->player->state.facingAngle*180.0/M_PI << std::endl;

View File

@ -118,7 +118,11 @@ namespace ZL {
void saveGame(int slot); void saveGame(int slot);
void loadGame(int slot); void loadGame(int slot);
SaveSlotInfo readSlotInfo(int slot) const; SaveSlotInfo readSlotInfo(int slot) const;
void createLocations(); void createLocationsStep1();
void createLocationsStep2();
void createLocationsStep3();
void createLocationsStep4();
void createLocationsStep5();
void createShadowMapAndProparateToLocations(); void createShadowMapAndProparateToLocations();
void destroyShadowMapAndProparateToLocations(); void destroyShadowMapAndProparateToLocations();

View File

@ -77,6 +77,8 @@ void GameState::save(nlohmann::json& out) const
} }
} }
out["locations"] = std::move(locsJson); out["locations"] = std::move(locsJson);
out["taxiIsCalled"] = taxiIsCalled;
} }
void GameState::load(const nlohmann::json& in) void GameState::load(const nlohmann::json& in)
@ -149,6 +151,9 @@ void GameState::load(const nlohmann::json& in)
} }
} }
} }
// --- Taxi ---
taxiIsCalled = in.value("taxiIsCalled", taxiIsCalled);
} }
} // namespace ZL } // namespace ZL

View File

@ -69,6 +69,8 @@ struct GameState : public ISaveable {
std::string chatPreviewMsg[3]; std::string chatPreviewMsg[3];
std::vector<StoredChatMessage> chatHistory[3]; std::vector<StoredChatMessage> chatHistory[3];
bool taxiIsCalled = false;
void save(nlohmann::json& out) const override; void save(nlohmann::json& out) const override;
void load(const nlohmann::json& in) override; void load(const nlohmann::json& in) override;
}; };

View File

@ -20,6 +20,9 @@ namespace ZL
{ {
extern const char* CONST_ZIP_FILE; extern const char* CONST_ZIP_FILE;
extern float x;
constexpr float CONST_TAXI_CAR_SCALE = 0.6f;
static constexpr float CAMERA_FOV_Y = 1.0f / 1.5f; static constexpr float CAMERA_FOV_Y = 1.0f / 1.5f;
@ -212,6 +215,18 @@ namespace ZL
} }
}); });
carTexture = renderer.textureManager.LoadFromPng("resources/e/car4096_v002.png", CONST_ZIP_FILE);
carMesh.data = LoadFromTextFile02("resources/e/car004.txt", CONST_ZIP_FILE);
carMesh.data.Scale(CONST_TAXI_CAR_SCALE);
carMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
carMesh.RefreshVBO();
carWheelTexture = renderer.textureManager.LoadFromPng("resources/w/exterior/Wheel_base003.png", CONST_ZIP_FILE);
carWheelMesh.data = LoadFromTextFile02("resources/e/car_wheel001.txt", CONST_ZIP_FILE);
carWheelMesh.data.Scale(CONST_TAXI_CAR_SCALE);
carWheelMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
carWheelMesh.RefreshVBO();
} }
void Location::loadTeleportZones(const std::string& jsonPath, const char* zipFile) void Location::loadTeleportZones(const std::string& jsonPath, const char* zipFile)
@ -273,6 +288,7 @@ namespace ZL
} }
std::cout << "[TELEPORT] Loaded " << teleportZones.size() << " teleport(s) from " << jsonPath << std::endl; std::cout << "[TELEPORT] Loaded " << teleportZones.size() << " teleport(s) from " << jsonPath << std::endl;
} }
void Location::loadTriggerZones(const std::string& jsonPath, const char* zipFile) void Location::loadTriggerZones(const std::string& jsonPath, const char* zipFile)
@ -693,6 +709,8 @@ namespace ZL
if (player) player->draw(renderer); if (player) player->draw(renderer);
for (auto& npc : npcs) npc->draw(renderer); for (auto& npc : npcs) npc->draw(renderer);
drawNpcCar();
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height); for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
if (editorMode == EditorMode::Navigation) { if (editorMode == EditorMode::Navigation) {
@ -784,6 +802,8 @@ namespace ZL
if (player) player->drawShadowDepth(renderer); if (player) player->drawShadowDepth(renderer);
for (auto& npc : npcs) npc->drawShadowDepth(renderer); for (auto& npc : npcs) npc->drawShadowDepth(renderer);
drawNpcCar();
renderer.PopMatrix(); // light view renderer.PopMatrix(); // light view
renderer.PopProjectionMatrix(); renderer.PopProjectionMatrix();
renderer.shaderManager.PopShader(); renderer.shaderManager.PopShader();
@ -883,6 +903,7 @@ namespace ZL
} }
if (player) player->draw(renderer); if (player) player->draw(renderer);
for (auto& npc : npcs) npc->draw(renderer); for (auto& npc : npcs) npc->draw(renderer);
drawNpcCar();
#else #else
// Characters use their own shadow-aware shaders // Characters use their own shadow-aware shaders
CheckGlError(__FILE__, __LINE__); CheckGlError(__FILE__, __LINE__);
@ -896,6 +917,8 @@ namespace ZL
for (auto& npc : npcs) npc->drawWithShadow(renderer, lightFromCamera, shadowMap->getDepthTexture(), lightDirCamera); for (auto& npc : npcs) npc->drawWithShadow(renderer, lightFromCamera, shadowMap->getDepthTexture(), lightDirCamera);
drawNpcCar();
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height); for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
#endif #endif
@ -972,6 +995,8 @@ namespace ZL
if (player) player->draw(renderer); if (player) player->draw(renderer);
for (auto& npc : npcs) npc->draw(renderer); for (auto& npc : npcs) npc->draw(renderer);
//drawNpcCar();
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height); for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
if (editorMode == EditorMode::Navigation) { if (editorMode == EditorMode::Navigation) {
@ -1029,6 +1054,8 @@ namespace ZL
if (player) player->drawShadowDepth(renderer); if (player) player->drawShadowDepth(renderer);
for (auto& npc : npcs) npc->drawShadowDepth(renderer); for (auto& npc : npcs) npc->drawShadowDepth(renderer);
drawNpcCar();
renderer.PopMatrix(); // light view renderer.PopMatrix(); // light view
renderer.PopProjectionMatrix(); renderer.PopProjectionMatrix();
renderer.shaderManager.PopShader(); renderer.shaderManager.PopShader();
@ -1037,6 +1064,44 @@ namespace ZL
shadowMap->unbind(); shadowMap->unbind();
} }
void Location::drawNpcCar()
{
renderer.PushMatrix();
renderer.TranslateMatrix(state.taxiCar.position);
renderer.TranslateMatrix({ 0, 0.7f - 0.25f +x, 0 });
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(state.taxiCar.rotation, Eigen::Vector3f::UnitY())).toRotationMatrix());
glBindTexture(GL_TEXTURE_2D, carTexture->getTexID());
renderer.DrawVertexRenderStruct(carMesh);
if (carWheelTexture) {
constexpr float track_width = 1.28f * CONST_TAXI_CAR_SCALE;
constexpr float wheel_base = 2.25f * CONST_TAXI_CAR_SCALE;
constexpr float shift = 0.6f * CONST_TAXI_CAR_SCALE;
const Eigen::Vector3f wheelPositions[4] = {
Eigen::Vector3f(track_width, 0.f - 0.21f, -(wheel_base + shift) + 1.25f * CONST_TAXI_CAR_SCALE),
Eigen::Vector3f(-track_width, 0.f - 0.21f, -(wheel_base + shift) + 1.25f * CONST_TAXI_CAR_SCALE),
Eigen::Vector3f(track_width, 0.f - 0.21f, (wheel_base - shift) + 1.1f * CONST_TAXI_CAR_SCALE),
Eigen::Vector3f(-track_width, 0.f - 0.21f, (wheel_base - shift) + 1.1f * CONST_TAXI_CAR_SCALE)
};
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]);
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(state.taxiCar.wheelAngle, -Eigen::Vector3f::UnitX())).toRotationMatrix());
if (isFront[i]) {
renderer.RotateMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(state.taxiCar.steeringAngle, Eigen::Vector3f::UnitY())).toRotationMatrix());
}
renderer.DrawVertexRenderStruct(carWheelMesh);
renderer.PopMatrix();
}
}
renderer.PopMatrix();
}
void Location::drawGameNight() void Location::drawGameNight()
{ {
// --- Determine which lights are active this frame --- // --- Determine which lights are active this frame ---
@ -1216,6 +1281,8 @@ namespace ZL
plWorldXZ, plLimitXZ, cameraViewInverse, ambientColor, fogColor); plWorldXZ, plLimitXZ, cameraViewInverse, ambientColor, fogColor);
} }
drawNpcCar();
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height); for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
if (editorMode == EditorMode::Navigation) { if (editorMode == EditorMode::Navigation) {
@ -1651,6 +1718,132 @@ namespace ZL
} }
} }
} }
updateNpcCar(delta);
}
void Location::updateNpcCar(int64_t deltaMs)
{
const float dt = static_cast<float>(deltaMs) / 1000.0f;
NpcCar& car = state.taxiCar;
Eigen::Vector3f target = car.position;
float throttle = 0.f;
bool hasTarget = false;
bool waypointsOver = false;
if (car.mode == NpcCar::Mode::FOLLOW_WAYPOINTS) {
if (!car.waypoints.empty()) {
if (car.currentWaypoint >= car.waypoints.size()) {
car.currentWaypoint = 0;
}
Eigen::Vector3f toTarget = car.waypoints[car.currentWaypoint] - car.position;
toTarget.y() = 0.f;
if (toTarget.norm() < car.waypointReachRadius) {
car.currentWaypoint = car.currentWaypoint + 1;
std::cout << "Waypoint current: " << car.currentWaypoint << std::endl;
if (car.currentWaypoint == car.waypoints.size())
{
std::cout << "waypointsOver" << std::endl;
waypointsOver = true;
}
}
if (waypointsOver) {
throttle = 0.f;
hasTarget = false;
car.mode = NpcCar::Mode::NONE;
}
else
{
target = car.waypoints[car.currentWaypoint];
throttle = 1.0f;
hasTarget = true;
}
}
}
else
{
throttle = 0.f;
}
float targetHeading = car.rotation;
if (hasTarget) {
Eigen::Vector3f toTarget = target - car.position;
toTarget.y() = 0.f;
if (toTarget.squaredNorm() > 1e-4f) {
targetHeading = std::atan2(-toTarget.x(), -toTarget.z());
}
}
float angleDiff = targetHeading - car.rotation;
while (angleDiff > M_PI) angleDiff -= 2.0f * static_cast<float>(M_PI);
while (angleDiff < -M_PI) angleDiff += 2.0f * static_cast<float>(M_PI);
const float turnIntent = max(-1.0f, min(1.0f, angleDiff * 2.0f));
const float targetSteer = turnIntent * NpcCar::maxSteerAngle;
const float steerLerp = min(1.f, dt * 8.f);
car.steeringAngle += (targetSteer - car.steeringAngle) * steerLerp;
if (throttle > 0.f) {
car.velocity += NpcCar::acceleration * dt * throttle;
}
else if (throttle < 0.f) {
const float brakeForce = NpcCar::acceleration * dt * (-throttle);
if (car.velocity > 0.f) {
car.velocity = max(0.f, car.velocity - brakeForce);
}
else {
car.velocity = min(0.f, car.velocity + brakeForce);
}
}
else {
const float resistance = NpcCar::friction * dt;
if (car.velocity > 0.f) {
car.velocity = max(0.f, car.velocity - resistance);
}
else if (car.velocity < 0.f) {
car.velocity = min(0.f, car.velocity + resistance);
}
}
car.velocity = max(-NpcCar::maxReverseSpeed, min(NpcCar::maxSpeed, car.velocity));
const float oldRotation = car.rotation;
if (std::abs(car.velocity) > 0.01f) {
const float speedFactor = car.velocity / NpcCar::maxSpeed;
car.rotation += turnIntent * NpcCar::turnRate * dt * speedFactor;
}
/*
if (navigation.isReady() && !isCarFootprintWalkable(car.position, car.rotation)) {
car.rotation = oldRotation;
}
*/
const Eigen::Vector3f forward(-std::sin(car.rotation), 0.f, -std::cos(car.rotation));
const Eigen::Vector3f totalDelta = forward * car.velocity * dt;
const float totalDist = totalDelta.norm();
const float maxSubstep = 0.2f;
const int substeps = max(1, static_cast<int>(std::ceil(totalDist / maxSubstep)));
const Eigen::Vector3f stepDelta = totalDelta / static_cast<float>(substeps);
for (int s = 0; s < substeps; ++s) {
Eigen::Vector3f candidate = car.position + stepDelta;
car.position = candidate;
}
state.taxiCar.wheelAngle += car.velocity * 4.f * dt;
while (state.taxiCar.wheelAngle > 2.0f * static_cast<float>(M_PI)) {
state.taxiCar.wheelAngle -= 2.0f * static_cast<float>(M_PI);
}
if (state.taxiArrivedCallbackCalled == false)
{
Eigen::Vector3f toTarget = state.taxiCar.position - state.taxiCarTriggerPosition;
if (toTarget.squaredNorm() < 9.f) {
scriptEngine.callCallTaxiCallback();
state.taxiArrivedCallbackCalled = true;
}
}
} }
void Location::handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my) void Location::handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my)
@ -1874,6 +2067,12 @@ namespace ZL
return dialogueSystem.getFlag(flag); return dialogueSystem.getFlag(flag);
} }
void Location::onTaxiCalled()
{
state.taxiCar.waypoints = state.taxiCarWaypoints;
state.taxiCar.mode = NpcCar::Mode::FOLLOW_WAYPOINTS;
}
// ---- Save / Load ---- // ---- Save / Load ----
void Location::save(nlohmann::json& out) const void Location::save(nlohmann::json& out) const

View File

@ -19,6 +19,7 @@
#include <functional> #include <functional>
#include <cstdint> #include <cstdint>
#include <unordered_map> #include <unordered_map>
namespace ZL namespace ZL
{ {
@ -133,6 +134,16 @@ namespace ZL
bool playBattleMusic = false; bool playBattleMusic = false;
std::shared_ptr<Texture> carTexture;
VertexRenderStruct carMesh;
std::shared_ptr<Texture> carWheelTexture;
VertexRenderStruct carWheelMesh;
void setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer); void setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer);
void setupNavigation(const std::vector<std::string>& paths); void setupNavigation(const std::vector<std::string>& paths);
bool switchNavigation(int index); bool switchNavigation(int index);
@ -145,10 +156,12 @@ namespace ZL
void drawGameDarklands(); void drawGameDarklands();
void drawGameNight(); void drawGameNight();
void drawNightShadowDepthPass(const PointLight& light); void drawNightShadowDepthPass(const PointLight& light);
void drawNpcCar();
bool setNavigationAreaAvailable(const std::string& areaName, bool available); bool setNavigationAreaAvailable(const std::string& areaName, bool available);
void update(int64_t deltaMs); void update(int64_t deltaMs);
void updateNpcCar(int64_t deltaMs);
void handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my); void handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my);
void handleUp(int64_t fingerId, int mx, int my); void handleUp(int64_t fingerId, int mx, int my);
@ -160,6 +173,8 @@ namespace ZL
void setDialogueFlag(const std::string& flag, int value); void setDialogueFlag(const std::string& flag, int value);
int getDialogueFlag(const std::string& flag) const; int getDialogueFlag(const std::string& flag) const;
void onTaxiCalled();
// ---- Save / Load ---- // ---- Save / Load ----
// Serialises LocationState + all Character/InteractiveObject sub-states + Lua globals. // Serialises LocationState + all Character/InteractiveObject sub-states + Lua globals.
void save(nlohmann::json& out) const override; void save(nlohmann::json& out) const override;

View File

@ -18,6 +18,91 @@ void LocationState::save(nlohmann::json& out) const
out["isDawn"] = isDawn; out["isDawn"] = isDawn;
out["tutorialInteractiveObjectsLocked"] = tutorialInteractiveObjectsLocked; out["tutorialInteractiveObjectsLocked"] = tutorialInteractiveObjectsLocked;
// Taxi stuff:
nlohmann::json taxiJson;
taxiJson["taxiCar"] = {
{"positionX", taxiCar.position.x()},
{"positionY", taxiCar.position.y()},
{"positionZ", taxiCar.position.z()},
{"rotation", taxiCar.rotation},
{"velocity", taxiCar.velocity},
{"steeringAngle", taxiCar.steeringAngle},
{"mode", static_cast<int>(taxiCar.mode)},
{"waypoints", nlohmann::json::array()},
{"currentWaypoint", taxiCar.currentWaypoint},
{"waypointReachRadius", taxiCar.waypointReachRadius}
};
nlohmann::json taxiWaypoints = nlohmann::json::array();
for (int i = 0; i < taxiCar.waypoints.size(); ++i) {
taxiWaypoints.push_back({
{"x", taxiCar.waypoints[i].x()},
{"y", taxiCar.waypoints[i].y()},
{"z", taxiCar.waypoints[i].z()}
});
}
taxiJson["taxiCar"]["waypoints"] = std::move(taxiWaypoints);
taxiJson["taxiCarInitialState"] = {
{"positionX", taxiCarInitialState.position.x()},
{"positionY", taxiCarInitialState.position.y()},
{"positionZ", taxiCarInitialState.position.z()},
{"rotation", taxiCarInitialState.rotation},
{"velocity", taxiCarInitialState.velocity},
{"steeringAngle", taxiCarInitialState.steeringAngle},
{"mode", static_cast<int>(taxiCarInitialState.mode)},
{"waypoints", nlohmann::json::array()},
{"currentWaypoint", taxiCarInitialState.currentWaypoint},
{"waypointReachRadius", taxiCarInitialState.waypointReachRadius}
};
nlohmann::json taxiInitialWaypoints = nlohmann::json::array();
for (int i = 0; i < taxiCarInitialState.waypoints.size(); ++i) {
taxiInitialWaypoints.push_back({
{"x", taxiCarInitialState.waypoints[i].x()},
{"y", taxiCarInitialState.waypoints[i].y()},
{"z", taxiCarInitialState.waypoints[i].z()}
});
}
taxiJson["taxiCarInitialState"]["waypoints"] = std::move(taxiInitialWaypoints);
nlohmann::json taxiDefaultWaypoints = nlohmann::json::array();
for (int i = 0; i < taxiCarWaypoints.size(); ++i) {
taxiDefaultWaypoints.push_back({
{"x", taxiCarWaypoints[i].x()},
{"y", taxiCarWaypoints[i].y()},
{"z", taxiCarWaypoints[i].z()}
});
}
taxiJson["taxiDefaultWaypoints"] = taxiDefaultWaypoints;
/* taxiCarTriggerPosition = Eigen::Vector3f(
taxiJson.value("taxiCarTriggerPositionX", 0.f),
taxiJson.value("taxiCarTriggerPositionY", 0.f),
taxiJson.value("taxiCarTriggerPositionZ", 0.f)
);*/
taxiJson["taxiCarTriggerPositionX"] = taxiCarTriggerPosition.x();
taxiJson["taxiCarTriggerPositionY"] = taxiCarTriggerPosition.y();
taxiJson["taxiCarTriggerPositionZ"] = taxiCarTriggerPosition.z();
// {"y", taxiCarTriggerPosition.y()},
// {"z", taxiCarTriggerPosition.z()}
//};
taxiJson["taxiArrivedCallbackCalled"] = taxiArrivedCallbackCalled;
//questJournal.save(questJson);
out["taxi"] = std::move(taxiJson);
} }
void LocationState::load(const nlohmann::json& in) void LocationState::load(const nlohmann::json& in)
@ -36,6 +121,106 @@ void LocationState::load(const nlohmann::json& in)
isDawn = in.value("isDawn", false); isDawn = in.value("isDawn", false);
tutorialInteractiveObjectsLocked = in.value("tutorialInteractiveObjectsLocked", false); tutorialInteractiveObjectsLocked = in.value("tutorialInteractiveObjectsLocked", false);
nlohmann::json taxiJson = in["taxi"];
taxiArrivedCallbackCalled = taxiJson.value("taxiArrivedCallbackCalled", false);
//----- Taxi State ----
nlohmann::json taxiCarJson = taxiJson["taxiCar"];
taxiCar.position = Eigen::Vector3f(
taxiCarJson.value("positionX", 0.f),
taxiCarJson.value("positionY", 0.f),
taxiCarJson.value("positionZ", 0.f)
);
taxiCar.rotation = taxiCarJson.value("rotation", 0.f);
taxiCar.velocity = taxiCarJson.value("velocity", 0.f);
taxiCar.steeringAngle = taxiCarJson.value("steeringAngle", 0.f);
/*taxiCar.acceleration = taxiCarJson.value("acceleration", 20.f);
taxiCar.friction = taxiCarJson.value("friction", 6.f);
taxiCar.maxSpeed = taxiCarJson.value("maxSpeed", 24.f);
taxiCar.maxReverseSpeed = taxiCarJson.value("maxReverseSpeed", 8.f);
taxiCar.turnRate = taxiCarJson.value("turnRate", 1.8f);
taxiCar.maxSteerAngle = taxiCarJson.value("maxSteerAngle", 0.6f);*/
taxiCar.mode = static_cast<NpcCar::Mode>(taxiCarJson.value("mode", 0));
taxiCar.waypoints.clear();
if (taxiCarJson.contains("waypoints") && taxiCarJson["waypoints"].is_array()) {
for (int i = 0; i < static_cast<int>(taxiCarJson["waypoints"].size()); ++i)
taxiCar.waypoints.push_back(Eigen::Vector3f(
taxiCarJson["waypoints"][i].value("x", 0.f),
taxiCarJson["waypoints"][i].value("y", 0.f),
taxiCarJson["waypoints"][i].value("z", 0.f)
));
}
taxiCar.currentWaypoint = taxiCarJson.value("currentWaypoint", 0);
taxiCar.waypointReachRadius = taxiCarJson.value("waypointReachRadius", 3.f);
taxiCar.wheelAngle = taxiCarJson.value("wheelAngle", 0.f);
//--------- Taxi initial state -----
nlohmann::json taxiCarInitialStateJson = taxiJson["taxiCarInitialState"];
taxiCarInitialState.position = Eigen::Vector3f(
taxiCarInitialStateJson.value("positionX", 0.f),
taxiCarInitialStateJson.value("positionY", 0.f),
taxiCarInitialStateJson.value("positionZ", 0.f)
);
taxiCarInitialState.rotation = taxiCarInitialStateJson.value("rotation", 0.f);
taxiCarInitialState.velocity = taxiCarInitialStateJson.value("velocity", 0.f);
taxiCarInitialState.steeringAngle = taxiCarInitialStateJson.value("steeringAngle", 0.f);
/*
taxiCarInitialState.acceleration = taxiCarInitialStateJson.value("acceleration", 20.f);
taxiCarInitialState.friction = taxiCarInitialStateJson.value("friction", 6.f);
taxiCarInitialState.maxSpeed = taxiCarInitialStateJson.value("maxSpeed", 24.f);
taxiCarInitialState.maxReverseSpeed = taxiCarInitialStateJson.value("maxReverseSpeed", 8.f);
taxiCarInitialState.turnRate = taxiCarInitialStateJson.value("turnRate", 1.8f);
taxiCarInitialState.maxSteerAngle = taxiCarInitialStateJson.value("maxSteerAngle", 0.6f);*/
taxiCarInitialState.mode = static_cast<NpcCar::Mode>(taxiCarInitialStateJson.value("mode", 0));
taxiCarInitialState.waypoints.clear();
if (taxiCarInitialStateJson.contains("waypoints") && taxiCarInitialStateJson["waypoints"].is_array()) {
for (int i = 0; i < static_cast<int>(taxiCarInitialStateJson["waypoints"].size()); ++i)
taxiCarInitialState.waypoints.push_back(Eigen::Vector3f(
taxiCarInitialStateJson["waypoints"][i].value("x", 0.f),
taxiCarInitialStateJson["waypoints"][i].value("y", 0.f),
taxiCarInitialStateJson["waypoints"][i].value("z", 0.f)
));
}
taxiCarInitialState.currentWaypoint = taxiCarInitialStateJson.value("currentWaypoint", 0);
taxiCarInitialState.waypointReachRadius = taxiCarInitialStateJson.value("waypointReachRadius", 3.f);
taxiCarInitialState.wheelAngle = taxiCarInitialStateJson.value("wheelAngle", 0.f);
taxiCarWaypoints.clear();
if (taxiJson.contains("taxiDefaultWaypoints") && taxiJson["taxiDefaultWaypoints"].is_array()) {
for (int i = 0; i < static_cast<int>(taxiJson["taxiDefaultWaypoints"].size()); ++i)
taxiCarWaypoints.push_back(Eigen::Vector3f(
taxiJson["taxiDefaultWaypoints"][i].value("x", 0.f),
taxiJson["taxiDefaultWaypoints"][i].value("y", 0.f),
taxiJson["taxiDefaultWaypoints"][i].value("z", 0.f)
));
}
taxiCarTriggerPosition = Eigen::Vector3f(
taxiJson.value("taxiCarTriggerPositionX", 0.f),
taxiJson.value("taxiCarTriggerPositionY", 0.f),
taxiJson.value("taxiCarTriggerPositionZ", 0.f)
);
} }
} // namespace ZL } // namespace ZL

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "external/nlohmann/json.hpp" #include "external/nlohmann/json.hpp"
#include "ISaveable.h" #include "ISaveable.h"
#include "NpcCar.h"
namespace ZL { namespace ZL {
@ -26,6 +27,13 @@ struct LocationState : public ISaveable {
// ---- Tutorial ---- // ---- Tutorial ----
bool tutorialInteractiveObjectsLocked = false; bool tutorialInteractiveObjectsLocked = false;
NpcCar taxiCarInitialState;
NpcCar taxiCar;
bool taxiArrivedCallbackCalled = false;
Vector3f taxiCarTriggerPosition;
std::vector<Vector3f> taxiCarWaypoints;
// (trigger/teleport zone runtime flags are serialised by id directly in Location::save/load) // (trigger/teleport zone runtime flags are serialised by id directly in Location::save/load)
// ---- Serialisation ---- // ---- Serialisation ----

View File

@ -1087,14 +1087,24 @@ namespace ZL {
uiManager.setButtonCallback("mapGo", [this](const std::string&) { uiManager.setButtonCallback("mapGo", [this](const std::string&) {
gameState_.tutorialNeedOpenTaxiScreen = false; gameState_.tutorialNeedOpenTaxiScreen = false;
if (callTaxiFunc) if (gameState_.taxiIsCalled == false)
{ {
callTaxiFunc(); gameState_.taxiIsCalled = true;
if (callTaxiFunc)
{
callTaxiFunc();
}
gameState_.money -= 500;
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
}
else
{
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi004");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
} }
gameState_.money -= 500;
closePhoneEntirely();
if (startDialogueFunc) startDialogueFunc("dialog_taxi002");
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");
}); });
audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg"); audioPlayer_.playSoundAsync("audio/537061__imafoley__message-pop-sound.ogg");

11
src/NpcCar.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "NpcCar.h"
namespace ZL
{
const float NpcCar::acceleration = 10.0f;
const float NpcCar::friction = 8.0f;
const float NpcCar::maxSpeed = 18.0f;
const float NpcCar::maxReverseSpeed = 8.0f;
const float NpcCar::turnRate = 1.8f;
const float NpcCar::maxSteerAngle = 0.6f;
}

30
src/NpcCar.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
#include "render/Renderer.h"
#include "Environment.h"
namespace ZL {
struct NpcCar
{
enum class Mode { FOLLOW_WAYPOINTS, NONE };
Eigen::Vector3f position = Eigen::Vector3f(-100.f, -100.f, -100.f);
float rotation = 0.f;
float velocity = 0.f;
float steeringAngle = 0.f;
static const float acceleration;
static const float friction;
static const float maxSpeed;
static const float maxReverseSpeed;
static const float turnRate;
static const float maxSteerAngle;
Mode mode = Mode::NONE;
std::vector<Eigen::Vector3f> waypoints;
size_t currentWaypoint = 0;
float waypointReachRadius = 3.0f;
float wheelAngle = 0.f;
};
}