diff --git a/godot/Scenes/Characters/first_person_player.tscn b/godot/Scenes/Characters/first_person_player.tscn index 71fb28c..7c4a05a 100644 --- a/godot/Scenes/Characters/first_person_player.tscn +++ b/godot/Scenes/Characters/first_person_player.tscn @@ -2,8 +2,7 @@ [sub_resource type="CapsuleMesh" id="CapsuleMesh_ky6st"] -[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_qjfxs"] -points = PackedVector3Array(-0.125207, -0.532801, -0.480507, 0.0227831, 0.47607, 0.498884, 0.169713, 0.559144, 0.464172, 0.231051, -0.803591, 0.320455, 0.40741, 0.651043, -0.243523, -0.482789, 0.594843, 0.0822132, -0.362868, -0.682312, 0.289697, 0.469044, -0.654529, -0.0662713, -0.127444, 0.842701, -0.338103, -0.393435, -0.683942, -0.244717, 0.438255, 0.623309, 0.200849, 0.0841477, 0.977454, 0.114795, -0.0682023, -0.976458, -0.12927, 0.20055, -0.563129, -0.451454, -0.185527, 0.595453, -0.453475, -0.273363, 0.592268, 0.407754, -0.00693649, -0.476823, 0.49966, 0.375821, -0.588614, 0.316955, 0.111579, 0.563059, -0.481177, -0.41725, 0.527866, -0.270497, -0.484546, -0.596972, -0.0665097, -0.279747, 0.908561, 0.0533361, -0.250197, -0.880712, 0.205319, 0.263647, -0.902771, -0.127394, 0.293368, 0.871526, -0.157196, 0.373412, -0.526319, -0.328246, 0.499663, 0.476641, -0.00688856, 0.0531056, 0.875001, 0.324703, -0.154543, -0.590854, 0.465879, -0.0972799, -0.782358, -0.398188, -0.387649, -0.498171, 0.31565, -0.30068, -0.587995, -0.388901) +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_snsyg"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gwsuw"] resource_name = "Beta_Joints_MAT1" @@ -3274,25 +3273,25 @@ nodes/output/position = Vector2(860, 160) node_connections = [&"ground_air_transition", 0, &"iwr_blend", &"ground_air_transition", 1, &"Air", &"iwr_blend", 0, &"Idle", &"iwr_blend", 1, &"Walk", &"iwr_blend", 2, &"Run", &"output", 0, &"ground_air_transition"] [node name="FirstPersonPlayer" type="FirstPersonPlayer"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) [node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) visible = false layers = 2 mesh = SubResource("CapsuleMesh_ky6st") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -visible = false -shape = SubResource("ConvexPolygonShape3D_qjfxs") +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("CapsuleShape3D_snsyg") [node name="Head" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.578545, 0) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.579, 0) [node name="Camera" type="Camera3D" parent="Head"] cull_mask = 1048573 [node name="Mesh" type="Node3D" parent="."] -transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -1, 0) +transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) [node name="Armature" type="Node3D" parent="Mesh"] transform = Transform3D(0.01, 0, 0, 0, -3.57628e-09, -0.01, 0, 0.01, -3.57628e-09, 0, 0, 0) diff --git a/godot/Scenes/Characters/player.tscn b/godot/Scenes/Characters/player.tscn index cc90c2c..a7b4cc0 100644 --- a/godot/Scenes/Characters/player.tscn +++ b/godot/Scenes/Characters/player.tscn @@ -254,9 +254,7 @@ _surfaces = [{ }] blend_shape_mode = 0 -[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_mm42w"] -radius = 0.283343 -height = 1.84319 +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p1dvg"] [sub_resource type="Animation" id="Animation_jas7c"] resource_name = "Air-loop" @@ -3273,10 +3271,8 @@ nodes/output/position = Vector2(860, 160) node_connections = [&"ground_air_transition", 0, &"iwr_blend", &"ground_air_transition", 1, &"Air", &"iwr_blend", 0, &"Idle", &"iwr_blend", 1, &"Walk", &"iwr_blend", 2, &"Run", &"output", 0, &"ground_air_transition"] [node name="Player" type="Player"] -velocity = Vector3(0, -5821.84, 0) [node name="Mesh" type="Node3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0730165, 0) [node name="Armature" type="Node3D" parent="Mesh"] transform = Transform3D(0.01, 0, 0, 0, -3.57628e-09, -0.01, 0, 0.01, -3.57628e-09, 0, 0, 0) @@ -3286,43 +3282,43 @@ bones/0/name = "Hips" bones/0/parent = -1 bones/0/rest = Transform3D(1, -5.00981e-07, 6.47142e-09, 0, 0.0129164, 0.999917, -5.01023e-07, -0.999917, 0.0129164, -7.72729e-06, 1.55432, -104.275) bones/0/enabled = true -bones/0/position = Vector3(-0.00545547, 1.5608, -104.173) -bones/0/rotation = Quaternion(-0.673975, -0.26086, 0.257429, 0.641436) +bones/0/position = Vector3(-0.00545729, 1.56079, -104.173) +bones/0/rotation = Quaternion(-0.674952, -0.262938, 0.255891, 0.640175) bones/0/scale = Vector3(1, 1, 1) bones/1/name = "Spine" bones/1/parent = 0 bones/1/rest = Transform3D(1, 4.9454e-07, 3.97682e-08, -4.9454e-07, 0.98715, 0.159796, 3.97681e-08, -0.159796, 0.98715, -4.1641e-10, 10.1824, 4.47034e-08) bones/1/enabled = true bones/1/position = Vector3(-4.1641e-10, 10.1824, 4.47034e-08) -bones/1/rotation = Quaternion(0.0494452, 0.00102938, -0.0281418, 0.99838) +bones/1/rotation = Quaternion(0.0492163, 0.000532408, -0.02752, 0.998409) bones/1/scale = Vector3(1, 1, 1) bones/2/name = "Spine1" bones/2/parent = 1 bones/2/rest = Transform3D(1, 4.13003e-14, -6.10621e-16, -4.13003e-14, 1, 5.96046e-08, 6.10624e-16, -5.96046e-08, 1, -6.45306e-12, 10.0027, 2.63751e-06) bones/2/enabled = true bones/2/position = Vector3(-6.45306e-12, 10.0027, 2.63751e-06) -bones/2/rotation = Quaternion(0.25634, 0.00456356, -0.0680245, 0.964179) +bones/2/rotation = Quaternion(0.255913, 0.00352153, -0.0657837, 0.964453) bones/2/scale = Vector3(1, 1, 1) bones/3/name = "Spine2" bones/3/parent = 2 bones/3/rest = Transform3D(1, 7.40298e-08, -1.9083e-09, -7.40543e-08, 0.999668, -0.0257692, -2.13163e-14, 0.0257692, 0.999668, -6.39488e-13, 9.32208, -1.54972e-06) bones/3/enabled = true bones/3/position = Vector3(-6.39488e-13, 9.32208, -1.54972e-06) -bones/3/rotation = Quaternion(0.268751, 0.00362875, -0.0681548, 0.960789) +bones/3/rotation = Quaternion(0.268319, 0.00267362, -0.0658236, 0.961075) bones/3/scale = Vector3(1, 1, 1) bones/4/name = "Neck" bones/4/parent = 3 bones/4/rest = Transform3D(1, -1.45661e-13, -1.46549e-14, 1.45661e-13, 1, -1.86265e-08, 1.46549e-14, 1.86265e-08, 1, 4.13195e-10, 16.8654, 4.15668e-13) bones/4/enabled = true bones/4/position = Vector3(4.13195e-10, 16.8654, 4.15668e-13) -bones/4/rotation = Quaternion(0.0150258, 0.0423437, -0.0448451, 0.997983) +bones/4/rotation = Quaternion(0.0137645, 0.0488776, -0.0564687, 0.997112) bones/4/scale = Vector3(1, 1, 1) bones/5/name = "Head" bones/5/parent = 4 bones/5/rest = Transform3D(1, 7.74936e-14, 5.77316e-15, -7.74936e-14, 1, 4.47035e-08, -5.77316e-15, -4.47035e-08, 1, -1.07566e-07, 9.3419, 2.84104) bones/5/enabled = true bones/5/position = Vector3(-1.07566e-07, 9.3419, 2.84104) -bones/5/rotation = Quaternion(0.00920543, 0.0563305, 0.022933, 0.998106) +bones/5/rotation = Quaternion(0.011752, 0.0558241, 0.0292939, 0.997942) bones/5/scale = Vector3(1, 1, 1) bones/6/name = "HeadTop_End" bones/6/parent = 5 @@ -3336,42 +3332,42 @@ bones/7/parent = 3 bones/7/rest = Transform3D(-0.205696, -0.977364, 0.0494833, -0.129005, -0.0230424, -0.991376, 0.970076, -0.210305, -0.121346, -4.56997, 11.1959, -0.806634) bones/7/enabled = true bones/7/position = Vector3(-4.56997, 11.1959, -0.806634) -bones/7/rotation = Quaternion(-0.407796, 0.575185, -0.614273, -0.354307) +bones/7/rotation = Quaternion(-0.41009, 0.574024, -0.615595, -0.351234) bones/7/scale = Vector3(1, 1, 1) bones/8/name = "RightArm" bones/8/parent = 7 bones/8/rest = Transform3D(0.978563, 0.205696, 0.0101912, -0.205948, 0.977364, 0.0484225, -2.57045e-07, -0.0494833, 0.998775, -3.57628e-07, 10.8382, -1.46913e-05) bones/8/enabled = true bones/8/position = Vector3(1.96774e-07, 10.8382, -3.20984e-07) -bones/8/rotation = Quaternion(0.203226, 0.203129, -0.0329129, 0.957264) +bones/8/rotation = Quaternion(0.211294, 0.201632, -0.0386556, 0.955618) bones/8/scale = Vector3(1, 1, 1) bones/9/name = "RightForeArm" bones/9/parent = 8 bones/9/rest = Transform3D(1, -5.8991e-08, -1.67444e-07, 5.8991e-08, 1, -9.42509e-15, 1.67444e-07, -4.52622e-16, 1, -1.01963e-05, 27.8415, -1.44409e-05) bones/9/enabled = true bones/9/position = Vector3(-1.00907e-05, 27.8415, -3.06037e-05) -bones/9/rotation = Quaternion(0.016868, -0.0422137, -0.187411, 0.981229) +bones/9/rotation = Quaternion(0.0174234, -0.0442375, -0.187662, 0.981082) bones/9/scale = Vector3(1, 1, 1) bones/10/name = "RightHand" bones/10/parent = 9 bones/10/rest = Transform3D(1, -1.90228e-09, 1.90222e-09, 1.90228e-09, 1, 1.10216e-13, -1.90222e-09, -1.10212e-13, 1, 1.54253e-05, 28.3288, 1.70057e-05) bones/10/enabled = true bones/10/position = Vector3(1.5054e-05, 28.3288, 8.42971e-07) -bones/10/rotation = Quaternion(-0.29465, 0.0869538, -0.124768, 0.943426) +bones/10/rotation = Quaternion(-0.311762, 0.048629, -0.109617, 0.942562) bones/10/scale = Vector3(1, 1, 1) bones/11/name = "RightHandThumb1" bones/11/parent = 10 bones/11/rest = Transform3D(0.888246, 0.459367, 6.78003e-07, -0.396939, 0.767535, -0.503319, -0.231209, 0.447071, 0.864101, 2.68185, 2.46481, 1.57399) bones/11/enabled = true bones/11/position = Vector3(2.68185, 2.46481, 1.57397) -bones/11/rotation = Quaternion(0.2394, 0.160363, -0.215536, 0.933014) +bones/11/rotation = Quaternion(0.248563, 0.146822, -0.244856, 0.925584) bones/11/scale = Vector3(1, 1, 1) bones/12/name = "RightHandThumb2" bones/12/parent = 11 bones/12/rest = Transform3D(0.999824, -0.0185942, -0.0023841, 0.0186051, 0.999816, 0.00460874, 0.00229796, -0.00465229, 0.999986, 3.93391e-06, 4.18899, 7.30372e-06) bones/12/enabled = true bones/12/position = Vector3(-4.17233e-06, 4.18898, -1.18934e-05) -bones/12/rotation = Quaternion(-0.115742, 0.0900667, 0.192157, 0.970344) +bones/12/rotation = Quaternion(-0.107896, 0.082565, 0.177687, 0.974663) bones/12/scale = Vector3(1, 1, 1) bones/13/name = "RightHandThumb3" bones/13/parent = 12 @@ -3392,14 +3388,14 @@ bones/15/parent = 10 bones/15/rest = Transform3D(1, 0.000328245, -7.43808e-08, -0.000328245, 1, 2.44166e-11, 7.43808e-08, -1.4988e-15, 1, 2.25983, 9.10829, 0.517869) bones/15/enabled = true bones/15/position = Vector3(2.25983, 9.10828, 0.517853) -bones/15/rotation = Quaternion(0.11025, 0.00650945, 0.00551306, 0.993867) +bones/15/rotation = Quaternion(0.0830017, 0.00512602, 0.00685563, 0.996513) bones/15/scale = Vector3(1, 1, 1) bones/16/name = "RightHandIndex2" bones/16/parent = 15 bones/16/rest = Transform3D(1, -0.000511482, 3.19887e-07, 0.000511482, 1, 1.0708e-05, -3.25364e-07, -1.07078e-05, 1, -7.49751e-08, 3.69999, 1.65342e-05) bones/16/enabled = true bones/16/position = Vector3(1.82747e-07, 3.7, 7.39788e-07) -bones/16/rotation = Quaternion(0.165573, 0.0101262, 0.00848687, 0.986109) +bones/16/rotation = Quaternion(0.154202, 0.00991445, 0.00963483, 0.987943) bones/16/scale = Vector3(1, 1, 1) bones/17/name = "RightHandIndex3" bones/17/parent = 16 @@ -3420,14 +3416,14 @@ bones/19/parent = 10 bones/19/rest = Transform3D(1, 0.0010033, 8.39909e-08, -0.0010033, 1, 6.61679e-11, -8.39908e-08, -1.50436e-10, 1, -2.58012e-05, 9.53251, 4.75128e-05) bones/19/enabled = true bones/19/position = Vector3(-2.61725e-05, 9.5325, 3.135e-05) -bones/19/rotation = Quaternion(0.1721, 0.00873778, 0.0157109, 0.984915) +bones/19/rotation = Quaternion(0.147732, 0.0111146, 0.0265099, 0.98861) bones/19/scale = Vector3(1, 1, 1) bones/20/name = "RightHandMiddle2" bones/20/parent = 19 bones/20/rest = Transform3D(0.999998, -0.00169976, 6.79326e-08, 0.00169976, 0.999998, 5.1725e-06, -7.67245e-08, -5.17238e-06, 1, 4.37467e-07, 3.70001, 1.65339e-05) bones/20/enabled = true bones/20/position = Vector3(5.8697e-08, 3.70001, -3.01458e-05) -bones/20/rotation = Quaternion(0.29122, 0.00291729, -0.0159203, 0.956519) +bones/20/rotation = Quaternion(0.254491, 0.00271635, -0.01288, 0.966986) bones/20/scale = Vector3(1, 1, 1) bones/21/name = "RightHandMiddle3" bones/21/parent = 20 @@ -3448,14 +3444,14 @@ bones/23/parent = 10 bones/23/rest = Transform3D(1, -0.000311951, 2.28835e-07, 0.000311951, 1, 7.13874e-11, -2.28835e-07, -1.97758e-15, 1, -1.86514, 9.1036, 0.0430626) bones/23/enabled = true bones/23/position = Vector3(-1.86514, 9.1036, 0.0430626) -bones/23/rotation = Quaternion(0.230492, 0.00939941, 0.0756768, 0.970082) +bones/23/rotation = Quaternion(0.181591, 0.0278997, 0.069303, 0.980532) bones/23/scale = Vector3(1, 1, 1) bones/24/name = "RightHandRing2" bones/24/parent = 23 bones/24/rest = Transform3D(1, 0.000442856, 1.18525e-07, -0.000442856, 1, 5.28028e-06, -1.16186e-07, -5.28033e-06, 1, -2.23002e-07, 3.37928, 6.29645e-07) bones/24/enabled = true bones/24/position = Vector3(-2.23002e-07, 3.37928, 6.29645e-07) -bones/24/rotation = Quaternion(0.355641, -0.00404305, -0.0360694, 0.933917) +bones/24/rotation = Quaternion(0.317146, -0.00384532, -0.0329689, 0.947796) bones/24/scale = Vector3(1, 1, 1) bones/25/name = "RightHandRing3" bones/25/parent = 24 @@ -3476,14 +3472,14 @@ bones/27/parent = 10 bones/27/rest = Transform3D(0.999999, -0.00104089, 1.35743e-07, 0.00104089, 0.999999, -8.47695e-06, -1.26919e-07, 8.47709e-06, 1, -3.80628, 8.07669, 0.486713) bones/27/enabled = true bones/27/position = Vector3(-3.80628, 8.07668, 0.486696) -bones/27/rotation = Quaternion(0.293242, 0.0144781, 0.0775827, 0.952775) +bones/27/rotation = Quaternion(0.247856, 0.00925302, 0.0721828, 0.96606) bones/27/scale = Vector3(1, 1, 1) bones/28/name = "RightHandPinky2" bones/28/parent = 27 bones/28/rest = Transform3D(0.999999, -0.00169266, 2.0762e-07, 0.00169266, 0.999999, 1.21108e-06, -2.0967e-07, -1.21073e-06, 1, 1.02501e-06, 3.6, -1.07715e-07) bones/28/enabled = true bones/28/position = Vector3(1.02501e-06, 3.6, -1.07715e-07) -bones/28/rotation = Quaternion(0.398295, -0.018258, -0.0590211, 0.915175) +bones/28/rotation = Quaternion(0.356941, -0.017438, -0.057749, 0.932177) bones/28/scale = Vector3(1, 1, 1) bones/29/name = "RightHandPinky3" bones/29/parent = 28 @@ -3504,42 +3500,42 @@ bones/31/parent = 3 bones/31/rest = Transform3D(-0.205707, 0.977362, -0.0494651, 0.129002, -0.0230232, -0.991377, -0.970074, -0.210314, -0.121346, 4.57045, 11.1957, -0.806628) bones/31/enabled = true bones/31/position = Vector3(4.57045, 11.1957, -0.806628) -bones/31/rotation = Quaternion(0.488057, 0.536105, -0.568538, 0.388789) +bones/31/rotation = Quaternion(0.48725, 0.536206, -0.569594, 0.388114) bones/31/scale = Vector3(1, 1, 1) bones/32/name = "LeftArm" bones/32/parent = 31 bones/32/rest = Transform3D(0.978561, -0.205707, -0.0101878, 0.20596, 0.977363, 0.0484042, 1.67638e-08, -0.0494647, 0.998776, 1.19209e-07, 10.8377, -7.69096e-07) bones/32/enabled = true bones/32/position = Vector3(1.19209e-07, 10.8377, -7.69096e-07) -bones/32/rotation = Quaternion(0.185302, -0.209923, 0.138081, 0.950015) +bones/32/rotation = Quaternion(0.176075, -0.211821, 0.127993, 0.952758) bones/32/scale = Vector3(1, 1, 1) bones/33/name = "LeftForeArm" bones/33/parent = 32 bones/33/rest = Transform3D(1, -7.91888e-10, 1.53855e-09, 7.9189e-10, 1, -1.06455e-06, -1.53855e-09, 1.06455e-06, 1, 6.43076e-07, 27.8415, 7.54874e-06) bones/33/enabled = true bones/33/position = Vector3(6.43076e-07, 27.8415, 7.54874e-06) -bones/33/rotation = Quaternion(0.0734728, -0.0260904, 0.146778, 0.986092) +bones/33/rotation = Quaternion(0.0710945, -0.0137076, 0.17137, 0.982543) bones/33/scale = Vector3(1, 1, 1) bones/34/name = "LeftHand" bones/34/parent = 33 bones/34/rest = Transform3D(1, 1.34242e-08, -1.34244e-08, -1.34242e-08, 1, -2.38631e-07, 1.34244e-08, 2.38631e-07, 1, 6.6208e-06, 28.3288, 7.55342e-06) bones/34/enabled = true bones/34/position = Vector3(6.6208e-06, 28.3288, 7.55342e-06) -bones/34/rotation = Quaternion(-0.269413, 0.00612019, 0.168673, 0.948118) +bones/34/rotation = Quaternion(-0.264837, 0.0075152, 0.176516, 0.94797) bones/34/scale = Vector3(1, 1, 1) bones/35/name = "LeftHandThumb1" bones/35/parent = 34 bones/35/rest = Transform3D(0.8891, -0.457712, -1.3113e-06, 0.395629, 0.768507, -0.502867, 0.230169, 0.447099, 0.864364, -2.68173, 2.46615, 1.57617) bones/35/enabled = true bones/35/position = Vector3(-2.68173, 2.46615, 1.57617) -bones/35/rotation = Quaternion(0.284649, -0.0891071, 0.106222, 0.948553) +bones/35/rotation = Quaternion(0.284339, -0.0840352, 0.103361, 0.949424) bones/35/scale = Vector3(1, 1, 1) bones/36/name = "LeftHandThumb2" bones/36/parent = 35 bones/36/rest = Transform3D(0.999863, 0.0164218, 0.00212004, -0.0164305, 0.999857, 0.00411473, -0.00205216, -0.004149, 0.999989, 3.03984e-06, 4.1871, 3.07148e-06) bones/36/enabled = true bones/36/position = Vector3(2.98023e-07, 4.18709, 1.43951e-05) -bones/36/rotation = Quaternion(-0.012463, -0.00528461, -0.0347495, 0.999304) +bones/36/rotation = Quaternion(-0.0138929, -0.00574121, -0.0316338, 0.999386) bones/36/scale = Vector3(1, 1, 1) bones/37/name = "LeftHandThumb3" bones/37/parent = 36 @@ -3560,14 +3556,14 @@ bones/39/parent = 34 bones/39/rest = Transform3D(1, 8.81505e-05, -2.88796e-08, -8.81505e-05, 1, -2.25531e-06, 2.86808e-08, 2.25531e-06, 1, -2.25986, 9.10932, 0.518009) bones/39/enabled = true bones/39/position = Vector3(-2.25986, 9.10932, 0.518024) -bones/39/rotation = Quaternion(0.0830108, 0.0388407, 0.0514195, 0.994463) +bones/39/rotation = Quaternion(0.0770195, 0.0389847, 0.0515855, 0.994931) bones/39/scale = Vector3(1, 1, 1) bones/40/name = "LeftHandIndex2" bones/40/parent = 39 bones/40/rest = Transform3D(1, -0.000210313, 1.21517e-07, 0.000210313, 1, -1.2441e-06, -1.21255e-07, 1.24412e-06, 1, -7.90296e-08, 3.70001, -2.50717e-05) bones/40/enabled = true bones/40/position = Vector3(-1.00166e-07, 3.69999, 4.91004e-06) -bones/40/rotation = Quaternion(0.162598, -0.00866607, -0.00498977, 0.986642) +bones/40/rotation = Quaternion(0.161606, -0.00865864, -0.0051118, 0.986804) bones/40/scale = Vector3(1, 1, 1) bones/41/name = "LeftHandIndex3" bones/41/parent = 40 @@ -3588,14 +3584,14 @@ bones/43/parent = 34 bones/43/rest = Transform3D(1, 6.33157e-05, -1.5605e-08, -6.33157e-05, 1, 1.85453e-06, 1.57224e-08, -1.85453e-06, 1, -3.57426e-05, 9.5334, -7.29997e-05) bones/43/enabled = true bones/43/position = Vector3(-3.58482e-05, 9.53341, -4.3386e-05) -bones/43/rotation = Quaternion(0.166169, -0.0258238, -0.0800847, 0.982501) +bones/43/rotation = Quaternion(0.160956, -0.0268348, -0.0830034, 0.983099) bones/43/scale = Vector3(1, 1, 1) bones/44/name = "LeftHandMiddle2" bones/44/parent = 43 bones/44/rest = Transform3D(1, -4.26227e-05, 1.84394e-07, 4.26227e-05, 1, -5.17247e-06, -1.84174e-07, 5.17248e-06, 1, 7.8513e-07, 3.70001, 5.89059e-07) bones/44/enabled = true bones/44/position = Vector3(7.8513e-07, 3.70001, 5.89059e-07) -bones/44/rotation = Quaternion(0.199962, 3.23689e-06, 0.0137906, 0.979707) +bones/44/rotation = Quaternion(0.211036, -2.03901e-05, 0.0148582, 0.977365) bones/44/scale = Vector3(1, 1, 1) bones/45/name = "LeftHandMiddle3" bones/45/parent = 44 @@ -3616,14 +3612,14 @@ bones/47/parent = 34 bones/47/rest = Transform3D(1, -1.26778e-05, 1.44174e-07, 1.26778e-05, 1, 1.85554e-06, -1.44198e-07, -1.85554e-06, 1, 1.86508, 9.10454, 0.0429883) bones/47/enabled = true bones/47/position = Vector3(1.86508, 9.10454, 0.0430176) -bones/47/rotation = Quaternion(0.289842, -0.0611307, -0.118318, 0.947763) +bones/47/rotation = Quaternion(0.297001, -0.0708289, -0.113667, 0.945438) bones/47/scale = Vector3(1, 1, 1) bones/48/name = "LeftHandRing2" bones/48/parent = 47 bones/48/rest = Transform3D(1, 7.29823e-08, -5.63593e-08, -7.29826e-08, 1, -5.17351e-06, 5.63589e-08, 5.17351e-06, 1, 7.46404e-07, 3.15002, 2.05661e-06) bones/48/enabled = true bones/48/position = Vector3(7.46404e-07, 3.15002, 2.05661e-06) -bones/48/rotation = Quaternion(0.289539, -0.000320947, 0.024351, 0.956857) +bones/48/rotation = Quaternion(0.299352, -0.000364506, 0.0249265, 0.953817) bones/48/scale = Vector3(1, 1, 1) bones/49/name = "LeftHandRing3" bones/49/parent = 48 @@ -3644,14 +3640,14 @@ bones/51/parent = 34 bones/51/rest = Transform3D(0.999992, -0.00408962, 4.99198e-08, 0.00408962, 0.999992, 1.03318e-05, -9.21724e-08, -1.03315e-05, 1, 3.80626, 8.07779, 0.486838) bones/51/enabled = true bones/51/position = Vector3(3.80626, 8.07779, 0.486867) -bones/51/rotation = Quaternion(0.327025, -0.0820818, -0.129876, 0.932443) +bones/51/rotation = Quaternion(0.327225, -0.0828698, -0.126651, 0.932746) bones/51/scale = Vector3(1, 1, 1) bones/52/name = "LeftHandPinky2" bones/52/parent = 51 bones/52/rest = Transform3D(1, 0.000421534, -2.89811e-07, -0.000421534, 1, 6.05504e-06, 2.92363e-07, -6.05491e-06, 1, 5.8622e-07, 3.59999, 1.86631e-05) bones/52/enabled = true bones/52/position = Vector3(-9.29924e-07, 3.59999, -1.33763e-05) -bones/52/rotation = Quaternion(0.35166, 0.00795197, 0.0407161, 0.935208) +bones/52/rotation = Quaternion(0.360969, 0.00803003, 0.0406202, 0.931658) bones/52/scale = Vector3(1, 1, 1) bones/53/name = "LeftHandPinky3" bones/53/parent = 52 @@ -3672,28 +3668,28 @@ bones/55/parent = 0 bones/55/rest = Transform3D(-1, -5.15831e-07, -6.28369e-08, 5.14419e-07, -0.999785, 0.0207118, -7.35073e-08, 0.0207118, 0.999785, -8.20779, -6.77175, -1.51222) bones/55/enabled = true bones/55/position = Vector3(-8.20779, -6.77175, -1.51222) -bones/55/rotation = Quaternion(-0.171821, 0.578667, 0.782421, 0.153099) +bones/55/rotation = Quaternion(-0.17425, 0.59257, 0.774068, 0.138983) bones/55/scale = Vector3(1, 1, 1) bones/56/name = "RightLeg" bones/56/parent = 55 bones/56/rest = Transform3D(1, -3.11163e-08, -6.95594e-08, 3.63214e-08, 0.997098, 0.0761275, 6.69888e-08, -0.0761275, 0.997098, 7.40101e-07, 44.3715, -4.82482e-08) bones/56/enabled = true bones/56/position = Vector3(7.40101e-07, 44.3715, -4.82482e-08) -bones/56/rotation = Quaternion(-0.914553, -0.0261421, 0.0810702, 0.395396) +bones/56/rotation = Quaternion(-0.923313, -0.0260744, 0.0789081, 0.374948) bones/56/scale = Vector3(1, 1, 1) bones/57/name = "RightFoot" bones/57/parent = 56 bones/57/rest = Transform3D(1, 2.89989e-07, -6.30721e-08, -2.18905e-07, 0.577278, -0.816548, -2.00379e-07, 0.816548, 0.577278, -1.88774e-07, 44.5278, 5.80588e-07) bones/57/enabled = true bones/57/position = Vector3(-1.88774e-07, 44.5278, 5.80588e-07) -bones/57/rotation = Quaternion(0.264136, 0.0252433, 0.0430909, 0.963192) +bones/57/rotation = Quaternion(0.272201, 0.039937, 0.0662076, 0.959129) bones/57/scale = Vector3(1, 1, 1) bones/58/name = "RightToeBase" bones/58/parent = 57 bones/58/rest = Transform3D(1, 1.2381e-07, -1.08868e-07, -1.64751e-07, 0.775226, -0.631684, 6.18842e-09, 0.631684, 0.775226, -5.1651e-07, 13.8169, -1.90205e-06) bones/58/enabled = true bones/58/position = Vector3(-5.1651e-07, 13.8169, -1.90205e-06) -bones/58/rotation = Quaternion(0.317939, -1.00007e-07, -1.98108e-07, 0.948111) +bones/58/rotation = Quaternion(0.316531, -1.75597e-07, 4.4775e-07, 0.948582) bones/58/scale = Vector3(1, 1, 1) bones/59/name = "RightToe_End" bones/59/parent = 58 @@ -3707,21 +3703,21 @@ bones/60/parent = 0 bones/60/rest = Transform3D(-1, -5.37325e-07, -1.73336e-07, 5.33615e-07, -0.999785, 0.0207348, -1.84441e-07, 0.0207348, 0.999785, 8.20779, -6.77179, -1.51221) bones/60/enabled = true bones/60/position = Vector3(8.20779, -6.77179, -1.51221) -bones/60/rotation = Quaternion(0.15404, 0.603026, 0.780016, -0.0648573) +bones/60/rotation = Quaternion(0.147747, 0.598258, 0.783679, -0.0781332) bones/60/scale = Vector3(1, 1, 1) bones/61/name = "LeftLeg" bones/61/parent = 60 bones/61/rest = Transform3D(1, -2.27105e-08, -2.66928e-07, 4.29763e-08, 0.997095, 0.0761695, 2.64423e-07, -0.0761695, 0.997095, 8.49408e-07, 44.3714, 5.43912e-09) bones/61/enabled = true bones/61/position = Vector3(8.49408e-07, 44.3714, 5.43912e-09) -bones/61/rotation = Quaternion(-0.898276, -0.00139739, 0.0107046, 0.439299) +bones/61/rotation = Quaternion(-0.896348, 0.0043123, -0.00358725, 0.443317) bones/61/scale = Vector3(1, 1, 1) bones/62/name = "LeftFoot" bones/62/parent = 61 bones/62/rest = Transform3D(1, 2.78454e-07, -1.41493e-07, -2.76279e-07, 0.577262, -0.816559, -1.45696e-07, 0.816559, 0.577262, 6.62281e-07, 44.5279, 6.18865e-08) bones/62/enabled = true bones/62/position = Vector3(6.62281e-07, 44.5279, 6.18865e-08) -bones/62/rotation = Quaternion(0.40896, -0.0618288, -0.11995, 0.902519) +bones/62/rotation = Quaternion(0.417055, -0.0641341, -0.125439, 0.897896) bones/62/scale = Vector3(1, 1, 1) bones/63/name = "LeftToeBase" bones/63/parent = 62 @@ -3747,17 +3743,8 @@ mesh = SubResource("ArrayMesh_1w418") skin = SubResource("Skin_l3wpu") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.908729, 0) -shape = SubResource("CapsuleShape3D_mm42w") - -[node name="SpringArmPivot" type="SpringArmPivot" parent="."] - -[node name="SpringArm3D" type="SpringArm3D" parent="SpringArmPivot"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.31667, 0) -spring_length = 2.0 -margin = 0.2 - -[node name="Camera3D" type="Camera3D" parent="SpringArmPivot/SpringArm3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("CapsuleShape3D_p1dvg") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] root_node = NodePath("../Mesh") diff --git a/godot/Scenes/Levels/client_world.tscn b/godot/Scenes/Levels/client_world.tscn new file mode 100644 index 0000000..3035263 --- /dev/null +++ b/godot/Scenes/Levels/client_world.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://bqv0m8kbr300b"] + +[ext_resource type="PackedScene" path="res://Scenes/Levels/world.tscn" id="1_ajsqk"] + +[node name="World" type="ClientWorld"] + +[node name="WorldContent" parent="." instance=ExtResource("1_ajsqk")] diff --git a/godot/Scenes/Levels/server_world.tscn b/godot/Scenes/Levels/server_world.tscn new file mode 100644 index 0000000..fa8c865 --- /dev/null +++ b/godot/Scenes/Levels/server_world.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://c2p67anlxe3mk"] + +[ext_resource type="PackedScene" path="res://Scenes/Levels/world.tscn" id="1_tecss"] + +[node name="World" type="ServerWorld"] + +[node name="WorldContent" parent="." instance=ExtResource("1_tecss")] diff --git a/godot/Scenes/Levels/world.tscn b/godot/Scenes/Levels/world.tscn index 8413269..98553bc 100644 --- a/godot/Scenes/Levels/world.tscn +++ b/godot/Scenes/Levels/world.tscn @@ -1,13 +1,12 @@ -[gd_scene load_steps=18 format=3 uid="uid://coue2qehpn4fr"] +[gd_scene load_steps=17 format=3 uid="uid://cl8gww414apoq"] -[ext_resource type="Texture2D" path="res://Assets/Textures/Sky.png" id="1_mnexj"] -[ext_resource type="Texture2D" path="res://Assets/Textures/Black.png" id="2_fkwcn"] -[ext_resource type="Texture2D" path="res://Assets/Textures/Orange.png" id="3_ux02w"] -[ext_resource type="Texture2D" path="res://Assets/Textures/Green.png" id="4_wp15n"] -[ext_resource type="PackedScene" uid="uid://d38w4ae3qj0k4" path="res://Scenes/Characters/first_person_player.tscn" id="5_8ctht"] +[ext_resource type="Texture2D" path="res://Assets/Textures/Sky.png" id="1_tcyn8"] +[ext_resource type="Texture2D" path="res://Assets/Textures/Black.png" id="2_j33w8"] +[ext_resource type="Texture2D" path="res://Assets/Textures/Orange.png" id="3_n1lus"] +[ext_resource type="Texture2D" path="res://Assets/Textures/Green.png" id="4_klpsf"] [sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_6c4vd"] -panorama = ExtResource("1_mnexj") +panorama = ExtResource("1_tcyn8") [sub_resource type="Sky" id="Sky_5ngqa"] sky_material = SubResource("PanoramaSkyMaterial_6c4vd") @@ -19,7 +18,7 @@ tonemap_mode = 2 glow_enabled = true [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ajchh"] -albedo_texture = ExtResource("2_fkwcn") +albedo_texture = ExtResource("2_j33w8") uv1_triplanar = true [sub_resource type="PlaneMesh" id="PlaneMesh_mmup0"] @@ -30,7 +29,7 @@ size = Vector2(50, 50) data = PackedVector3Array(25, 0, 25, -25, 0, 25, 25, 0, -25, -25, 0, 25, -25, 0, -25, 25, 0, -25) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jkvud"] -albedo_texture = ExtResource("3_ux02w") +albedo_texture = ExtResource("3_n1lus") uv1_triplanar = true [sub_resource type="BoxMesh" id="BoxMesh_plpqy"] @@ -45,7 +44,7 @@ left_to_right = -2.0 size = Vector3(5, 5, 5) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pfpgv"] -albedo_texture = ExtResource("4_wp15n") +albedo_texture = ExtResource("4_klpsf") uv1_triplanar = true [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_rit6o"] @@ -87,4 +86,4 @@ surface_material_override/0 = SubResource("StandardMaterial3D_pfpgv") [node name="CollisionShape3D" type="CollisionShape3D" parent="Slope/StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_rit6o") -[node name="FirstPersonPlayer" parent="." instance=ExtResource("5_8ctht")] +[node name="Players" type="Node" parent="."] diff --git a/godot/Scenes/Menus/mainmenu.tscn b/godot/Scenes/Menus/mainmenu.tscn index 3b4a107..d097b93 100644 --- a/godot/Scenes/Menus/mainmenu.tscn +++ b/godot/Scenes/Menus/mainmenu.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://bqfqg7xwwlxd8"] -[node name="Main Menu" type="MainMenu"] +[node name="MainMenu" type="MainMenu"] anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 diff --git a/godot/Scenes/Network/networking.tscn b/godot/Scenes/Network/networking.tscn new file mode 100644 index 0000000..edbb3c6 --- /dev/null +++ b/godot/Scenes/Network/networking.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://clafls1xhludi"] + +[node name="NetworkInterface" type="NetworkInterface"] diff --git a/godot/Scenes/Network/server.tscn b/godot/Scenes/Network/server.tscn new file mode 100644 index 0000000..0bc31e6 --- /dev/null +++ b/godot/Scenes/Network/server.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://us5sb4a0kq8d"] + +[node name="Server" type="Server"] diff --git a/godot/Scenes/main.tscn b/godot/Scenes/main.tscn new file mode 100644 index 0000000..ee40fa4 --- /dev/null +++ b/godot/Scenes/main.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://4jt0v2b2l4rt"] + +[ext_resource type="PackedScene" path="res://Scenes/Network/networking.tscn" id="1_06ibn"] +[ext_resource type="PackedScene" path="res://Scenes/Menus/mainmenu.tscn" id="2_lavg1"] + +[node name="Main" type="Main"] + +[node name="Network" parent="." instance=ExtResource("1_06ibn")] + +[node name="MainMenu" parent="." instance=ExtResource("2_lavg1")] diff --git a/godot/bin/Blitz3.gdextension b/godot/bin/Blitz3.gdextension index be8f5b5..b0d66f2 100644 --- a/godot/bin/Blitz3.gdextension +++ b/godot/bin/Blitz3.gdextension @@ -1,5 +1,5 @@ [icons] -Blitz3 = "res://icon.svg" +Blitz3 = "res://icon.png" [configuration] diff --git a/godot/icon.png b/godot/icon.png new file mode 100644 index 0000000..755d910 --- /dev/null +++ b/godot/icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a29c524f37c3bf78181fdf5a37f9411af5a1c8cc8d556289cc9fa5389e97acbb +size 52765 diff --git a/godot/icon.svg b/godot/icon.svg deleted file mode 100644 index b370ceb..0000000 --- a/godot/icon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/godot/project.godot b/godot/project.godot index c562b59..a64f2c6 100644 --- a/godot/project.godot +++ b/godot/project.godot @@ -11,9 +11,9 @@ config_version=5 [application] config/name="Blitz3" -run/main_scene="res://Scenes/Levels/world.tscn" +run/main_scene="res://Scenes/main.tscn" config/features=PackedStringArray("4.2", "Forward Plus") -config/icon="res://icon.svg" +config/icon="res://icon.png" [display] diff --git a/include/blitz/common/NonCopyable.h b/include/blitz/common/NonCopyable.h new file mode 100644 index 0000000..308a744 --- /dev/null +++ b/include/blitz/common/NonCopyable.h @@ -0,0 +1,25 @@ +#pragma once + +/** + * \file NonCopyable.h + * \brief File containing the blitz::NonCopyable class + */ + +namespace blitz { + +/** + * \class NonCopyable + * \brief Class used to make a class non copyable + * \note Inherit from this class privately to make a class non copyable + */ +class NonCopyable { + public: + NonCopyable(const NonCopyable&) = delete; + NonCopyable& operator=(const NonCopyable&) = delete; + + protected: + NonCopyable() {} + ~NonCopyable() {} +}; + +} // namespace blitz diff --git a/include/blitz/common/Types.h b/include/blitz/common/Types.h new file mode 100644 index 0000000..1208204 --- /dev/null +++ b/include/blitz/common/Types.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace blitz { + +using EntityID = std::uint64_t; +using PeerID = std::int32_t; +using PlayerID = PeerID; + +} // namespace blitz diff --git a/include/blitz/godot/NetworkInterface.h b/include/blitz/godot/NetworkInterface.h new file mode 100644 index 0000000..483a190 --- /dev/null +++ b/include/blitz/godot/NetworkInterface.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include + +namespace blitz { + +class NetworkInterface : public godot::Node, public protocol::PacketDispatcher { + GDCLASS(NetworkInterface, godot::Node) + protected: + static void _bind_methods(); + + public: + NetworkInterface(); + ~NetworkInterface(); + + void BroadcastPacket(const protocol::Packet& a_Packet); + void SendPacket(PeerID a_Peer, const protocol::Packet& a_Packet); + + godot::Error JoinGame(const godot::String& a_Address, uint16_t a_Port); + godot::Error CreateGame(uint16_t a_Port, bool a_Dedicated = false); + + void ShutdownNetwork(); + + void _ready() override; + + private: + void RecievePacketDataReliable(godot::PackedByteArray a_PacketData); + void RecievePacketDataUnreliable(godot::PackedByteArray a_PacketData); + void RecievePacketDataUnreliableOrdered(godot::PackedByteArray a_PacketData); + + void OnPlayerConnected(PeerID a_PeerId); + void OnPlayerDisconnected(PeerID a_PeerId); + void OnConnectOk(); + void OnConnectFail(); + void OnServerDisconnected(); +}; + +} // namespace blitz \ No newline at end of file diff --git a/include/blitz/godot/World.h b/include/blitz/godot/World.h new file mode 100644 index 0000000..24476d7 --- /dev/null +++ b/include/blitz/godot/World.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +#include + +namespace blitz { + +class Player; +class NetworkInterface; + +class World : public godot::Node3D, public protocol::PacketHandler { + GDCLASS(World, godot::Node3D) + protected: + static void _bind_methods(); + + World(); + ~World(); + + public: + // Godot overrides + void _ready() override; + + Player* GetPlayerById(PlayerID a_PlayerId); + + void HandlePacket(const protocol::packets::PlayerJoin&) override; + void HandlePacket(const protocol::packets::PlayerLeave&) override; + + protected: + NetworkInterface* m_NetworkInterface; + godot::Node* m_Players; + float m_PassedTime; + + + virtual void AddPlayer(PlayerID a_PlayerId, godot::String a_PlayerName); + virtual void RemovePlayer(PlayerID a_PlayerId); + virtual void SetPlayerPositionAndRotation( + PlayerID a_PlayerId, const godot::Vector3& a_Position, const godot::Vector3& a_Rotation, const godot::Vector3& a_Velocity); +}; +} // namespace blitz \ No newline at end of file diff --git a/include/blitz/protocol/ByteBuffer.h b/include/blitz/protocol/ByteBuffer.h new file mode 100644 index 0000000..95adeda --- /dev/null +++ b/include/blitz/protocol/ByteBuffer.h @@ -0,0 +1,94 @@ +#pragma once + +#include +#include +#include +#include + +namespace blitz { +namespace protocol { + +class PlayerInfo; + +class ByteBuffer { + private: + godot::PackedByteArray m_Buffer; + std::size_t m_ReadOffset; + + public: + class ReadError : public std::runtime_error { + public: + ReadError(const std::string& msg) : std::runtime_error(msg) {} + }; + + ByteBuffer(godot::PackedByteArray&& a_Buffer) : m_Buffer(std::move(a_Buffer)), m_ReadOffset(0) {} + ByteBuffer() : m_ReadOffset(0) { + m_Buffer.resize(0); + } + + const godot::PackedByteArray& GetByteArray() const { + return m_Buffer; + } + + godot::PackedByteArray& GetByteArray() { + return m_Buffer; + } + + // Integers + ByteBuffer& operator<<(int8_t a_Data); + ByteBuffer& operator>>(int8_t& a_Data); + ByteBuffer& operator<<(uint8_t a_Data); + ByteBuffer& operator>>(uint8_t& a_Data); + + ByteBuffer& operator<<(int16_t a_Data); + ByteBuffer& operator>>(int16_t& a_Data); + ByteBuffer& operator<<(uint16_t a_Data); + ByteBuffer& operator>>(uint16_t& a_Data); + + ByteBuffer& operator<<(int32_t a_Data); + ByteBuffer& operator>>(int32_t& a_Data); + ByteBuffer& operator<<(uint32_t a_Data); + ByteBuffer& operator>>(uint32_t& a_Data); + + ByteBuffer& operator<<(int64_t a_Data); + ByteBuffer& operator>>(int64_t& a_Data); + ByteBuffer& operator<<(uint64_t a_Data); + ByteBuffer& operator>>(uint64_t& a_Data); + + ByteBuffer& operator<<(float a_Data); + ByteBuffer& operator>>(float& a_Data); + ByteBuffer& operator<<(double a_Data); + ByteBuffer& operator>>(double& a_Data); + + ByteBuffer& operator<<(const godot::String& a_Data); + ByteBuffer& operator>>(godot::String& a_Data); + + ByteBuffer& operator<<(const godot::Vector3& a_Data); + ByteBuffer& operator>>(godot::Vector3& a_Data); + + template + ByteBuffer& operator<<(const std::vector& a_Data) { + *this << static_cast(a_Data.size()); + for (const T& data : a_Data) { + *this << data; + } + return *this; + } + + template + ByteBuffer& operator>>(std::vector& a_Data) { + std::uint32_t arraySize; + *this >> arraySize; + a_Data.resize(arraySize); + for (std::uint32_t i = 0; i < arraySize; i++) { + *this >> a_Data[i]; + } + return *this; + } + + ByteBuffer& operator<<(const PlayerInfo& a_Data); + ByteBuffer& operator>>(PlayerInfo& a_Data); +}; + +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketData.h b/include/blitz/protocol/PacketData.h new file mode 100644 index 0000000..2c5174c --- /dev/null +++ b/include/blitz/protocol/PacketData.h @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include +#include + +namespace blitz { +namespace protocol { + +struct PlayerInfo { + PlayerID m_PlayerId; + godot::String m_PlayerName; +}; + +namespace data { + +struct PlayerLogin { + godot::String m_PlayerName; +}; + +struct UpdateHealth { + float m_NewHealth; +}; + +struct LoggingSuccess { + PlayerID m_PlayerId; +}; + +struct PlayerDeath {}; + +struct PlayerJoin { + PlayerInfo m_Player; +}; + +struct PlayerLeave { + PlayerID m_PlayerId; +}; + +struct PlayerStats {}; + +struct PlayerList { + std::vector m_Players; +}; + +struct ServerConfig {}; + +struct ServerTps {}; + +struct UpdateGameState {}; + +struct KeepAlive { + std::uint64_t m_KeepAliveId; +}; + +struct Disconnect {}; + +struct ChatMessage { + godot::String m_Text; +}; + +struct PlayerPositionAndRotation { + PlayerID m_Player; + godot::Vector3 m_Position; + godot::Vector3 m_Rotation; + godot::Vector3 m_Velocity; +}; + +struct PlayerShoot {}; + +} // namespace data +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketDeclare.h b/include/blitz/protocol/PacketDeclare.h new file mode 100644 index 0000000..dd19355 --- /dev/null +++ b/include/blitz/protocol/PacketDeclare.h @@ -0,0 +1,55 @@ +#pragma once + +/** + * \file PacketDeclare.h + * \brief Holds the definitions of the packets (but not their content) + */ + +namespace blitz { +namespace protocol { + +/** + * \enum PacketSender + * \brief Indicate who should send a packet + */ +enum class PacketSenderType { + /** Sent by clients and server */ + Both = 1, + /** Sent by clients to the server */ + Client, + /** Sent by server to the clients */ + Server, +}; + +enum class PacketSendType { + Reliable = 1, + Unreliable, + UnreliableOrdered, +}; + + +/** + * \def DeclareAllPacket + * \brief Avoids repetitive operations on packets + */ +#define DeclareAllPacket() \ + DeclarePacket(ChatMessage, Reliable, Both) \ + DeclarePacket(Disconnect, Reliable, Both) \ + DeclarePacket(KeepAlive, Reliable, Both) \ + DeclarePacket(LoggingSuccess, Reliable, Server) \ + DeclarePacket(PlayerDeath, Reliable, Server) \ + DeclarePacket(PlayerJoin, Reliable, Server) \ + DeclarePacket(PlayerLeave, Reliable, Server) \ + DeclarePacket(PlayerList, Reliable, Server) \ + DeclarePacket(PlayerLogin, Reliable, Client) \ + DeclarePacket(PlayerPositionAndRotation, Unreliable, Both) \ + DeclarePacket(PlayerShoot, Reliable, Both) \ + DeclarePacket(PlayerStats, Reliable, Server) \ + DeclarePacket(ServerConfig, Reliable, Server) \ + DeclarePacket(ServerTps, Reliable, Server) \ + DeclarePacket(UpdateGameState, Reliable, Server) \ + DeclarePacket(UpdateHealth, Reliable, Client) + + +} // namespace protocol +} // namespace blitz \ No newline at end of file diff --git a/include/blitz/protocol/PacketDispatcher.h b/include/blitz/protocol/PacketDispatcher.h new file mode 100644 index 0000000..4e9b32d --- /dev/null +++ b/include/blitz/protocol/PacketDispatcher.h @@ -0,0 +1,58 @@ +#pragma once + +/** + * \file PacketDispatcher.h + * \brief File containing the blitz::protocol::PacketDispatcher class + */ + +#include +#include + +#include + +namespace blitz { +namespace protocol { + +class PacketHandler; + +/** + * \class PacketDispatcher + * \brief Class used to dispatch packets + */ +class PacketDispatcher : private NonCopyable { + private: + std::map> m_Handlers; + + public: + /** + * \brief Constructor + */ + PacketDispatcher() {} + + /** + * \brief Dispatch a packet + * \param packet The packet to dispatch + */ + void Dispatch(const Packet& packet); + + /** + * \brief Register a packet handler + * \param type The packet type + * \param handler The packet handler + */ + void RegisterHandler(PacketType type, PacketHandler& handler); + /** + * \brief Unregister a packet handler + * \param type The packet type + * \param handler The packet handler + */ + void UnregisterHandler(PacketType type, PacketHandler& handler); + /** + * \brief Unregister a packet handler + * \param handler The packet handler + */ + void UnregisterHandler(PacketHandler& handler); +}; + +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketFactory.h b/include/blitz/protocol/PacketFactory.h new file mode 100644 index 0000000..88ed43f --- /dev/null +++ b/include/blitz/protocol/PacketFactory.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +namespace blitz { +namespace protocol { +namespace PacketFactory { + +template::value>::type> +std::unique_ptr CreatePacket() { + return std::make_unique(); +} + +const std::unique_ptr& CreateReadOnlyPacket(PacketType a_Type); + +void Init(); + +} // namespace PacketFactory +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketHandler.h b/include/blitz/protocol/PacketHandler.h new file mode 100644 index 0000000..e99b731 --- /dev/null +++ b/include/blitz/protocol/PacketHandler.h @@ -0,0 +1,34 @@ +#pragma once + +/** + * \file PacketHandler.h + * \brief File containing the blitz::protocol::PacketHandler class + */ + +#include +#include + +namespace blitz { +namespace protocol { + +class PacketDispatcher; + +#define DeclarePacket(PacketName, ...) virtual void Visit(const packets::PacketName&); virtual void HandlePacket(const packets::PacketName&) {} + +/** + * \class PacketHandler + * \brief Class used to handle packets + */ +class PacketHandler : public PacketVisitor { + public: + PacketHandler() {} + ~PacketHandler() {} + + DeclareAllPacket() + +}; + +#undef DeclarePacket + +} // namespace protocol +} // namespace blitz \ No newline at end of file diff --git a/include/blitz/protocol/PacketSender.h b/include/blitz/protocol/PacketSender.h new file mode 100644 index 0000000..a3a1afc --- /dev/null +++ b/include/blitz/protocol/PacketSender.h @@ -0,0 +1,60 @@ +#pragma once + +#include + +namespace blitz { + +class NetworkInterface; + +namespace protocol { + +#define DeclarePacket(PacketName, Reliability, ...) void Visit(const protocol::packets::PacketName& a_Packet) override; + + + + + +/////////////////////// +/* PacketBroadcaster */ +/////////////////////// +class PacketBroadcaster : public protocol::PacketVisitor { + private: + NetworkInterface& m_NetworkInterface; + + public: + PacketBroadcaster(NetworkInterface& a_NetworkInterface) : m_NetworkInterface(a_NetworkInterface) {} + + void BroadcastPacket(const protocol::Packet& a_Packet) { + Check(a_Packet); + } + + DeclareAllPacket() +}; + + + + + + +////////////////// +/* PacketSender */ +////////////////// +class PacketSender : public protocol::PacketVisitor { + private: + NetworkInterface& m_NetworkInterface; + PeerID m_PeerId; + + public: + PacketSender(PeerID a_PeerId, NetworkInterface& a_NetworkInterface) : m_PeerId(a_PeerId), m_NetworkInterface(a_NetworkInterface) {} + + void SendPacket(const protocol::Packet& a_Packet) { + Check(a_Packet); + } + + DeclareAllPacket() +}; + +#undef DeclarePacket + +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketSerializer.h b/include/blitz/protocol/PacketSerializer.h new file mode 100644 index 0000000..f797525 --- /dev/null +++ b/include/blitz/protocol/PacketSerializer.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include + +namespace blitz { +namespace protocol { + +using PacketPtr = std::unique_ptr; + +namespace PacketSerializer { + +godot::PackedByteArray Serialize(const Packet& a_Packet); + +std::unique_ptr Deserialize(godot::PackedByteArray& a_Data); + +} +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/PacketVisitor.h b/include/blitz/protocol/PacketVisitor.h new file mode 100644 index 0000000..1f41f53 --- /dev/null +++ b/include/blitz/protocol/PacketVisitor.h @@ -0,0 +1,39 @@ +#pragma once + +/** + * \file PacketVisitor.h + * \brief File containing the blitz::protocol::PacketVisitor class + */ + +#include + +namespace blitz { +namespace protocol { + +#define DeclarePacket(PacketName, ...) \ + /** This function is called when the packet processed by PacketVisitor::Check is a PacketName */ \ + virtual void Visit(const packets::PacketName&) {} + +/** + * \class PacketVisitor + * \brief This class uses double-dispatch in order to find the real type of a packet + */ +class PacketVisitor : private NonCopyable { + protected: + PacketVisitor() {} + virtual ~PacketVisitor() {} + + public: + /** + * \brief Calls the right PacketVisitor::Visit method corresponding to the real type of the packet + * \param packet the Packet to visit + */ + void Check(const Packet& packet); + + DeclareAllPacket() +}; + +#undef DeclarePacket + +} // namespace protocol +} // namespace blitz diff --git a/include/blitz/protocol/Packets.h b/include/blitz/protocol/Packets.h new file mode 100644 index 0000000..f0d47f6 --- /dev/null +++ b/include/blitz/protocol/Packets.h @@ -0,0 +1,112 @@ +#pragma once + +/** + * \file Packets.h + * \brief File containing the definitions of the packets + */ + +#include +#include +#include + +namespace blitz { +namespace protocol { + +class PacketVisitor; + +/** A Packet id is 8 bits wide */ +using PacketID = std::uint8_t; + +#define DeclarePacket(PacketName, ...) /** PacketName */ PacketName, + +/** + * \enum PacketType + * \brief Map a Packet to an id + */ +enum class PacketType : PacketID { + + DeclareAllPacket() + + /** The number of packets */ + PACKET_COUNT +}; + + +#undef DeclarePacket + + +class Packet : private NonCopyable { + public: + /** + * \return The real type of the packet + */ + virtual PacketType GetType() const = 0; + + /** + * \brief The network peer who sent the packet + */ + PeerID m_Sender; + + private: + /** Use a PacketVisitor to make double-dispatch possible */ + virtual void Accept(PacketVisitor& a_Visitor) const = 0; + + friend class PacketVisitor; +}; + + + + + +namespace packets { + +/** + * \class ConcretePacket + * \brief A Packet associated with an id and holding data + * \tparam PT The packet type + * \tparam Data The structure holding the data of the packet (in blitz::protocol::data namespace) + */ +template +class ConcretePacket : public Packet { + public: + /** The type of the struct holding the data */ + using PacketDataType = Data; + + /** The structure holding the actual data */ + PacketDataType m_Data; + + /** Construct the packet with data of type PacketDataType */ + ConcretePacket(const PacketDataType& a_Data = {}); + + constexpr PacketType GetType() const override { + return PT; + }; + + private: + void Accept(PacketVisitor& a_Visitor) const override; +}; + + + + + +// define BLITZ_INSTANCIATE_PACKETS +// before including this file +// if you want to instantiate templates +#ifdef BLITZ_INSTANCIATE_PACKETS +#define DeclarePacket(PacketName, ...) \ + using PacketName = ConcretePacket; \ + template class ConcretePacket; +#else +#define DeclarePacket(PacketName, ...) /** Defines the PacketName packet */ \ + using PacketName = ConcretePacket; +#endif + +DeclareAllPacket() + +#undef DeclarePacket + +} // namespace packets + +} // namespace protocol +} // namespace blitz diff --git a/include/client/ClientWorld.h b/include/client/ClientWorld.h new file mode 100644 index 0000000..919abca --- /dev/null +++ b/include/client/ClientWorld.h @@ -0,0 +1,21 @@ +#include + +namespace blitz { + +class ClientWorld : public World { + GDCLASS(ClientWorld, World) + protected: + static void _bind_methods(); + + public: + ClientWorld(); + ~ClientWorld(); + void _process(float delta); + + void HandlePacket(const protocol::packets::PlayerPositionAndRotation&) override; + + private: + void UpdatePlayerPos(); +}; + +} // namespace blitz \ No newline at end of file diff --git a/src/FirstPersonPlayer.h b/include/client/FirstPersonPlayer.h similarity index 64% rename from src/FirstPersonPlayer.h rename to include/client/FirstPersonPlayer.h index 3236b30..9e7c2bc 100644 --- a/src/FirstPersonPlayer.h +++ b/include/client/FirstPersonPlayer.h @@ -1,14 +1,11 @@ #pragma once -#include -#include -#include +#include #include -#include namespace blitz { -class FirstPersonPlayer : public godot::CharacterBody3D { +class FirstPersonPlayer : public Player { GDCLASS(FirstPersonPlayer, godot::CharacterBody3D) protected: static void _bind_methods(); @@ -19,14 +16,12 @@ class FirstPersonPlayer : public godot::CharacterBody3D { // Godot overrides void _unhandled_input(const godot::Ref&); - void _physics_process(float delta); - void _ready(); + void _physics_process(float delta) override; + void _ready() override; private: - godot::AnimationTree* m_AnimationTree; godot::Camera3D* m_Camera; godot::Node3D* m_Head; - godot::Node3D* m_Mesh; float m_BobTime; float m_Speed; diff --git a/include/client/Main.h b/include/client/Main.h new file mode 100644 index 0000000..71bf9b4 --- /dev/null +++ b/include/client/Main.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace blitz { + +class Main : public godot::Node { + GDCLASS(Main, godot::Node) + protected: + static void _bind_methods(); + + public: + Main(); + ~Main(); + + void _ready() override; + + void ChangeScene(bool a_Server); +}; + +} // namespace blitz \ No newline at end of file diff --git a/src/MainMenu.h b/include/client/MainMenu.h similarity index 58% rename from src/MainMenu.h rename to include/client/MainMenu.h index b6d3961..73157c9 100644 --- a/src/MainMenu.h +++ b/include/client/MainMenu.h @@ -2,6 +2,7 @@ #include #include +#include namespace blitz { @@ -19,12 +20,20 @@ class MainMenu : public godot::Control { private: godot::Button* m_JoinButton; - godot::Button* m_CreateButton; - godot::Button* m_QuitButton; + godot::Button* m_CreateButton; + godot::Button* m_QuitButton; - void OnJoinPressed(); - void OnCreatePressed(); - void OnQuitPressed(); + NetworkInterface* m_NetworkInterface; + + void OnConnected(); + void OnDisconnected(); + + void OnJoinPressed(); + void OnCreatePressed(); + void OnQuitPressed(); + + void DisableButtons(); + void EnableButtons(); }; } // namespace blitz \ No newline at end of file diff --git a/src/Player.h b/include/client/Player.h similarity index 57% rename from src/Player.h rename to include/client/Player.h index 5fdea94..e65d84b 100644 --- a/src/Player.h +++ b/include/client/Player.h @@ -3,8 +3,12 @@ #include #include #include +#include namespace blitz { + +class World; + class Player : public godot::CharacterBody3D { GDCLASS(Player, godot::CharacterBody3D); @@ -16,22 +20,24 @@ class Player : public godot::CharacterBody3D { Player(); ~Player(); - void _ready(); - void _physics_process(float delta); + void _ready() override; + virtual void _physics_process(float delta); void animate(float delta); - private: - godot::Node3D* m_PlayerMesh; - godot::Node3D* m_SpringArmPivot; + godot::Vector3 GetCameraRotation() const; + void SetCameraRotation(const godot::Vector3& a_Rotation); + + PlayerID GetId() const { + return m_PeerId; + } + + protected: + godot::Node3D* m_Mesh; godot::AnimationTree* m_AnimationTree; godot::Vector3 m_SnapVector; - float m_Speed; - /* - @onready var player_mesh : Node3D = $Mesh -@onready var spring_arm_pivot : Node3D = $SpringArmPivot -@onready var animator : AnimationTree = $AnimationTree + PeerID m_PeerId; - */ + friend class World; }; } // namespace blitz diff --git a/include/server/Server.h b/include/server/Server.h new file mode 100644 index 0000000..2f6c7ab --- /dev/null +++ b/include/server/Server.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + +namespace blitz { + +class Lobby; +class NetworkInterface; + +class Server : public godot::Node { + GDCLASS(Server, godot::Node) + protected: + static void _bind_methods(); + + public: + Server(); + ~Server(); + + void _ready() override; + + void OnPlayerConnect(PeerID a_PeerId); + void OnPlayerDisconnect(PeerID a_PeerId); + + private: + Lobby* m_Lobby; + NetworkInterface* m_NetworkInterface; + + godot::TypedArray m_Peers; +}; + +} // namespace blitz \ No newline at end of file diff --git a/include/server/ServerWorld.h b/include/server/ServerWorld.h new file mode 100644 index 0000000..fda4380 --- /dev/null +++ b/include/server/ServerWorld.h @@ -0,0 +1,23 @@ +#include + +namespace blitz { + +class ServerWorld : public World { + GDCLASS(ServerWorld, World) + protected: + static void _bind_methods(); + + public: + ServerWorld(); + ~ServerWorld(); + void _process(float delta); + + void HandlePacket(const protocol::packets::PlayerPositionAndRotation&) override; + + void SyncPlayersPos(); + + protected: + virtual void AddPlayer(PlayerID a_PlayerId, godot::String a_PlayerName); +}; + +} // namespace blitz \ No newline at end of file diff --git a/src/MainMenu.cpp b/src/MainMenu.cpp deleted file mode 100644 index 20e7fc5..0000000 --- a/src/MainMenu.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "MainMenu.h" - -#include -#include - -using namespace godot; - -static constexpr char MainScenePath[] = "res://Scenes/Levels/world.tscn"; - -namespace blitz { - -void MainMenu::_bind_methods() {} - -MainMenu::MainMenu() {} - -MainMenu::~MainMenu() {} - -void MainMenu::_ready() { - Node* container = find_child("Container"); - DEV_ASSERT(container); - - m_JoinButton = Object::cast_to