brush texture to material mapping and material changes

This commit is contained in:
GoaLitiuM
2021-08-22 22:21:55 +03:00
parent 7466590d4f
commit 995e9bdbce
55 changed files with 777 additions and 338 deletions

34
Assets/Maps/cube_q1.map Normal file
View File

@@ -0,0 +1,34 @@
// Game: Goake
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"_tb_textures" "textures/common"
// brush 0
{
( 0 0 -16 ) ( 0 1 -16 ) ( 0 0 -15 ) common/slick2 0 0 0 4 4
( 0 0 -16 ) ( 0 0 -15 ) ( 1 0 -16 ) common/slick2 0 0 0 4 4
( 0 0 -512 ) ( 1 0 -512 ) ( 0 1 -512 ) common/slick2 0 0 0 4 4
( 80 64 0 ) ( 80 65 0 ) ( 81 64 0 ) common/slick2 0 0 0 4 4
( 80 512 0 ) ( 81 512 0 ) ( 80 512 1 ) common/slick2 0 0 0 4 4
( 512 64 0 ) ( 512 64 1 ) ( 512 65 0 ) common/slick2 0 0 0 4 4
}
// brush 1
{
( 128 384 128 ) ( 128 385 128 ) ( 128 384 129 ) common/slick2 0 0 0 1 1
( 128 384 128 ) ( 128 384 129 ) ( 129 384 128 ) common/slick2 0 0 0 1 1
( 128 384 128 ) ( 129 384 128 ) ( 128 385 128 ) common/slick2 0 0 0 1 1
( 192 448 192 ) ( 192 449 192 ) ( 193 448 192 ) common/slick2 0 0 0 1 1
( 192 448 192 ) ( 193 448 192 ) ( 192 448 193 ) common/slick2 0 0 0 1 1
( 192 448 192 ) ( 192 448 193 ) ( 192 449 192 ) common/slick2 0 0 0 1 1
}
// brush 2
{
( 256 384 128 ) ( 256 385 128 ) ( 256 384 129 ) common/slick2 0 0 90 1 1
( 256 384 128 ) ( 256 384 129 ) ( 257 384 128 ) common/slick2 0 0 90 1 1
( 256 384 128 ) ( 257 384 128 ) ( 256 385 128 ) common/slick2 0 0 90 1 1
( 320 448 192 ) ( 320 449 192 ) ( 321 448 192 ) common/slick2 0 0 90 1 1
( 320 448 192 ) ( 321 448 192 ) ( 320 448 193 ) common/slick2 0 0 90 1 1
( 320 448 192 ) ( 320 448 193 ) ( 320 449 192 ) common/slick2 0 0 90 1 1
}
}

View File

@@ -216,4 +216,63 @@
( 624 576.78980575614889 114.7520585344753 ) ( 625 576.78980575614889 114.7520585344753 ) ( 624 577.48446479013558 115.47139835693415 ) common/slick 0 0 180 1 1 0 0 0
( 704 626.60775672407669 177.85651027935376 ) ( 704 625.88841691338689 178.5511686390937 ) ( 704 627.30241508381675 178.57585009004364 ) common/slick -32 0 0 1 1 0 0 0
}
// brush 24
{
( -128 352 32 ) ( -128 353 32 ) ( -128 352 33 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -32 352 32 ) ( -32 352 33 ) ( -31 352 32 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -32 352 32 ) ( -31 352 32 ) ( -32 353 32 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( 32 416 160 ) ( 32 417 160 ) ( 33 416 160 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( 32 416 48 ) ( 33 416 48 ) ( 32 416 49 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( 32 416 48 ) ( 32 416 49 ) ( 32 417 48 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
}
// brush 25
{
( -784 432 48 ) ( -784 433 48 ) ( -784 432 49 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -336 432 48 ) ( -336 432 49 ) ( -335 432 48 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -336 432 48 ) ( -335 432 48 ) ( -336 433 48 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -224 560 64 ) ( -224 561 64 ) ( -223 560 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -224 720 64 ) ( -223 720 64 ) ( -224 720 65 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -304 560 64 ) ( -304 560 65 ) ( -304 561 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
}
// brush 26
{
( -608 720 48 ) ( -608 721 48 ) ( -608 720 49 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -576 720 48 ) ( -576 720 49 ) ( -575 720 48 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -576 720 16 ) ( -575 720 16 ) ( -576 721 16 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -176 832 64 ) ( -176 833 64 ) ( -175 832 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -176 864 64 ) ( -175 864 64 ) ( -176 864 65 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -144 832 64 ) ( -144 832 65 ) ( -144 833 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
}
// brush 27
{
( -576 720 64 ) ( -576 721 64 ) ( -576 720 65 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -576 720 64 ) ( -576 720 65 ) ( -575 720 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -576 720 64 ) ( -575 720 64 ) ( -576 721 64 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -176 832 128 ) ( -176 833 128 ) ( -175 832 128 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -176 832 80 ) ( -175 832 80 ) ( -176 832 81 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -304 832 80 ) ( -304 832 81 ) ( -304 833 80 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
}
// brush 28
{
( -576 720 128 ) ( -576 721 128 ) ( -576 720 129 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
( -576 720 128 ) ( -576 720 129 ) ( -575 720 128 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
( -576 720 128 ) ( -575 720 128 ) ( -576 721 128 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
( -464 832 224 ) ( -464 833 224 ) ( -463 832 224 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
( -464 832 144 ) ( -463 832 144 ) ( -464 832 145 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
( -464 832 144 ) ( -464 832 145 ) ( -464 833 144 ) dev/dev_128_red 0 0 0 0.0625 0.0625 0 0 0
}
// brush 29
{
( -464 720 128 ) ( -464 721 128 ) ( -464 720 129 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -464 720 128 ) ( -464 720 129 ) ( -463 720 128 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -464 720 128 ) ( -463 720 128 ) ( -464 721 128 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -304 832 224 ) ( -304 833 224 ) ( -303 832 224 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -304 832 144 ) ( -303 832 144 ) ( -304 832 145 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
( -304 832 144 ) ( -304 832 145 ) ( -304 833 144 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
}
}
// entity 1
{
"classname" "info_player_deathmatch"
"origin" "-368 544 120"
}

View File

@@ -0,0 +1,35 @@
// Game: Goake
// Format: Valve
// entity 0
{
"classname" "worldspawn"
"mapversion" "220"
"_tb_textures" "textures/common"
// brush 0
{
( 0 0 -32 ) ( 0 1 -32 ) ( 0 0 -31 ) common/slick2 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 4 4
( 0 0 -32 ) ( 0 0 -31 ) ( 1 0 -32 ) common/slick2 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 4 4
( 0 0 -512 ) ( 1 0 -512 ) ( 0 1 -512 ) common/slick2 [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 4 4
( 128 128 0 ) ( 128 129 0 ) ( 129 128 0 ) common/slick2 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 4 4
( 128 512 0 ) ( 129 512 0 ) ( 128 512 1 ) common/slick2 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 4 4
( 512 128 0 ) ( 512 128 1 ) ( 512 129 0 ) common/slick2 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 4 4
}
// brush 1
{
( 128 320 128 ) ( 128 321 128 ) ( 128 320 129 ) common/slick2 [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 128 320 128 ) ( 128 320 129 ) ( 129 320 128 ) common/slick2 [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 128 320 128 ) ( 129 320 128 ) ( 128 321 128 ) common/slick2 [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 192 384 192 ) ( 192 385 192 ) ( 193 384 192 ) common/slick2 [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
( 192 384 192 ) ( 193 384 192 ) ( 192 384 193 ) common/slick2 [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
( 192 384 192 ) ( 192 384 193 ) ( 192 385 192 ) common/slick2 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
}
// brush 2
{
( 256 320 128 ) ( 256 321 128 ) ( 256 320 129 ) common/slick2 [ 0 4.37114e-08 -1 0 ] [ 0 1 4.37114e-08 0 ] 90 1 1
( 256 320 128 ) ( 256 320 129 ) ( 257 320 128 ) common/slick2 [ -4.37114e-08 0 -1 0 ] [ -1 0 4.37114e-08 0 ] 90 1 1
( 256 320 128 ) ( 257 320 128 ) ( 256 321 128 ) common/slick2 [ 4.37114e-08 -1 0 0 ] [ 1 4.37114e-08 0 0 ] 90 1 1
( 320 384 192 ) ( 320 385 192 ) ( 321 384 192 ) common/slick2 [ -4.37114e-08 -1 0 0 ] [ -1 4.37114e-08 0 0 ] 90 1 1
( 320 384 192 ) ( 321 384 192 ) ( 320 384 193 ) common/slick2 [ 4.37114e-08 0 -1 0 ] [ 1 0 4.37114e-08 0 ] 90 1 1
( 320 384 192 ) ( 320 384 193 ) ( 320 385 192 ) common/slick2 [ 0 -4.37114e-08 -1 0 ] [ 0 -1 4.37114e-08 0 ] 90 1 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

View File

@@ -0,0 +1,98 @@
{
"ID": "2d0e518b47d735c98312dd87cc42d6d7",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6224,
"Data": [
{
"ID": "999a202c47de967d2bdfd09abcc6df4e",
"TypeName": "FlaxEngine.RigidBody",
"Name": "PlayerPrefab",
"OverrideMass": true,
"Mass": 10.0,
"LinearDamping": 0.0,
"AngularDamping": 0.0,
"Constraints": 56,
"IsKinematic": true,
"EnableGravity": false
},
{
"ID": "b29a58f545071ca393afaab21faa83ad",
"TypeName": "Game.PlayerMovement",
"ParentID": "999a202c47de967d2bdfd09abcc6df4e",
"V": {}
},
{
"ID": "a67383834fc3f6f1106e8099e5557e32",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "999a202c47de967d2bdfd09abcc6df4e",
"Name": "RootActor"
},
{
"ID": "b8fc420f4efe96fa2b4042bd98fd3e74",
"TypeName": "FlaxEngine.Camera",
"ParentID": "a67383834fc3f6f1106e8099e5557e32",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 28.7337646484375,
"Z": 0.0
}
},
"Near": 1.0
},
{
"ID": "226bdb004e72848777178a9d1f207cbf",
"TypeName": "FlaxEngine.AudioListener",
"ParentID": "b8fc420f4efe96fa2b4042bd98fd3e74",
"Name": "AudioListener"
},
{
"ID": "8bd80bca49ac35da66aabaa2e473851d",
"TypeName": "FlaxEngine.CapsuleCollider",
"ParentID": "999a202c47de967d2bdfd09abcc6df4e",
"IsActive": false,
"Name": "CapsuleCollider",
"Transform": {
"Orientation": {
"X": 0.0,
"Y": 0.0,
"Z": 0.7071068286895752,
"W": 0.7071068286895752
}
},
"ContactOffset": 0.0,
"Material": "d99b8b6f40198beea4703dadd642150e",
"Radius": 16.0,
"Height": 52.0
},
{
"ID": "d9d61d314ad79d49ba08059cef50f802",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "999a202c47de967d2bdfd09abcc6df4e",
"Name": "BoxCollider",
"ContactOffset": 0.0,
"Material": "ffe0e84c49607480f67a3994a7fe11a8",
"Size": {
"X": 32.0,
"Y": 84.0,
"Z": 32.0
}
},
{
"ID": "b377cc03418270d87e8a5b92cb5374ea",
"TypeName": "FlaxEngine.MeshCollider",
"ParentID": "999a202c47de967d2bdfd09abcc6df4e",
"IsActive": false,
"Name": "CylinderCollider",
"Transform": {
"Scale": {
"X": 0.3199999928474426,
"Y": 0.8399999737739563,
"Z": 0.3199999928474426
}
},
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
}
]
}

View File

@@ -0,0 +1,99 @@
{
"ID": "29864325492125902977e192357b5147",
"TypeName": "FlaxEngine.Prefab",
"EngineBuild": 6224,
"Data": [
{
"ID": "b72b57504e7963aecdfeae91018803f3",
"TypeName": "FlaxEngine.RigidBody",
"ParentID": "00000000000000000000000000000000",
"Name": "PlayerSpectatorPrefab",
"OverrideMass": true,
"Mass": 10.0,
"LinearDamping": 0.0,
"AngularDamping": 0.0,
"Constraints": 56,
"IsKinematic": true,
"EnableGravity": false
},
{
"ID": "c698b95d4fe85d18dc803589428c3d14",
"TypeName": "Game.CameraMovement",
"ParentID": "b72b57504e7963aecdfeae91018803f3",
"V": {}
},
{
"ID": "4e86d9d4498838d4871975bc1e555668",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "b72b57504e7963aecdfeae91018803f3",
"Name": "RootActor"
},
{
"ID": "c5161c384c4dcdd49465c7883a21fc22",
"TypeName": "FlaxEngine.Camera",
"ParentID": "4e86d9d4498838d4871975bc1e555668",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 28.7337646484375,
"Z": 0.0
}
},
"Near": 1.0
},
{
"ID": "c49f64704eebfe5dd33b11a3a2c819db",
"TypeName": "FlaxEngine.AudioListener",
"ParentID": "c5161c384c4dcdd49465c7883a21fc22",
"Name": "AudioListener"
},
{
"ID": "e05594b04c26050c67c89d83ccb8895d",
"TypeName": "FlaxEngine.CapsuleCollider",
"ParentID": "b72b57504e7963aecdfeae91018803f3",
"IsActive": false,
"Name": "CapsuleCollider",
"Transform": {
"Orientation": {
"X": 0.0,
"Y": 0.0,
"Z": 0.7071068286895752,
"W": 0.7071068286895752
}
},
"ContactOffset": 0.0,
"Material": "d99b8b6f40198beea4703dadd642150e",
"Radius": 16.0,
"Height": 52.0
},
{
"ID": "38f5b9ac4b96ccecc6cf629bca69faf0",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "b72b57504e7963aecdfeae91018803f3",
"Name": "BoxCollider",
"ContactOffset": 0.0,
"Material": "ffe0e84c49607480f67a3994a7fe11a8",
"Size": {
"X": 32.0,
"Y": 84.0,
"Z": 32.0
}
},
{
"ID": "45aa3b4241acfa70733735b0c7e387ca",
"TypeName": "FlaxEngine.MeshCollider",
"ParentID": "b72b57504e7963aecdfeae91018803f3",
"IsActive": false,
"Name": "CylinderCollider",
"Transform": {
"Scale": {
"X": 0.3199999928474426,
"Y": 0.8399999737739563,
"Z": 0.3199999928474426
}
},
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
}
]
}

View File

@@ -1,7 +1,7 @@
{
"ID": "3c7bc3854d42f9b1b0fea9ba0d7fa8e9",
"TypeName": "FlaxEditor.Content.Settings.GameSettings",
"EngineBuild": 6222,
"EngineBuild": 6224,
"Data": {
"ProductName": "Goake",
"CompanyName": "GoaLitiuM",
@@ -15,6 +15,9 @@
"Graphics": "f94d5aae457aeba67033a8a4ca753214",
"GameCooking": "af2e52554f7faed7b4937181dd22d166",
"Streaming": "3a6ffc3a43e684f77cfed1a1f8f6bd0e",
"CustomSettings": {
"BrushMaterials": "29a0b0c54b40eb3e6857ffb4c9cab71e"
},
"WindowsPlatform": "4a5eec97484253fed72934860ae62c40"
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
{
"ID": "0733cc9b40d3d05366be64bbd9b59e21",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 6223,
"EngineBuild": 6224,
"Data": [
{
"ID": "0733cc9b40d3d05366be64bbd9b59e21",
@@ -25,117 +25,61 @@
}
},
{
"ID": "4ef1f38b4569142b55b0ff935525d47a",
"TypeName": "FlaxEngine.RigidBody",
"ParentID": "0733cc9b40d3d05366be64bbd9b59e21",
"Name": "PlayerPrefab",
"Transform": {
"Translation": {
"X": -354.623291015625,
"Y": 176.5519256591797,
"Z": 61.111427307128909
}
},
"OverrideMass": true,
"Mass": 10.0,
"LinearDamping": 0.0,
"AngularDamping": 0.0,
"Constraints": 56,
"IsKinematic": true,
"EnableGravity": false
"ID": "d9110dd14d9950a23388b894f38cfb87",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "999a202c47de967d2bdfd09abcc6df4e",
"ParentID": "0733cc9b40d3d05366be64bbd9b59e21"
},
{
"ID": "e3bab01a4912873fc2e9ff855a214bf7",
"TypeName": "Game.PlayerMovement",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"V": {}
"ID": "81cc91774240802618913ba28e68051e",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b29a58f545071ca393afaab21faa83ad",
"ParentID": "d9110dd14d9950a23388b894f38cfb87",
"V": {
"JumpLandSound": "a9ae0bbf438b4e841277f39c3d7c7c8b"
}
},
{
"ID": "08ed03be4d537814ba01edb88f6801e1",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"Name": "RootActor"
"ID": "5c30e8d943f94a215a567bb44cc56c3b",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "a67383834fc3f6f1106e8099e5557e32",
"ParentID": "d9110dd14d9950a23388b894f38cfb87"
},
{
"ID": "499cfa784579b58bba713daa0983d705",
"TypeName": "FlaxEngine.Camera",
"ParentID": "08ed03be4d537814ba01edb88f6801e1",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 28.7337646484375,
"Z": 0.0
}
},
"Near": 1.0
"ID": "b2ab19b6483303eb876d44b8e0f0eb17",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b8fc420f4efe96fa2b4042bd98fd3e74",
"ParentID": "5c30e8d943f94a215a567bb44cc56c3b"
},
{
"ID": "b59df4764594c5ee84a759b5e65bfc5a",
"TypeName": "FlaxEngine.AudioListener",
"ParentID": "08ed03be4d537814ba01edb88f6801e1",
"Name": "AudioListener"
"ID": "b6578a6342f1f971c3c08aa349ecf755",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "226bdb004e72848777178a9d1f207cbf",
"ParentID": "b2ab19b6483303eb876d44b8e0f0eb17"
},
{
"ID": "fbaa6db24f0a2a9db36bc6a043fc2572",
"TypeName": "FlaxEngine.CapsuleCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"IsActive": false,
"Name": "CapsuleCollider",
"Transform": {
"Orientation": {
"X": 0.0,
"Y": 0.0,
"Z": 0.7071068286895752,
"W": 0.7071068286895752
}
},
"ContactOffset": 0.0,
"Material": "d99b8b6f40198beea4703dadd642150e",
"Radius": 16.0,
"Height": 52.0
"ID": "b453cdbd448b73911fea54814bbff4e7",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "8bd80bca49ac35da66aabaa2e473851d",
"ParentID": "d9110dd14d9950a23388b894f38cfb87"
},
{
"ID": "9677298d46e5d5d7021f7cb607bd3023",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"Name": "BoxCollider",
"ContactOffset": 0.0,
"Material": "ffe0e84c49607480f67a3994a7fe11a8",
"Size": {
"X": 32.0,
"Y": 84.0,
"Z": 32.0
}
"ID": "e842261543e7a48435f75ab83b3f9b9d",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "d9d61d314ad79d49ba08059cef50f802",
"ParentID": "d9110dd14d9950a23388b894f38cfb87"
},
{
"ID": "f472490345bbfe282aefa2aa027e0138",
"TypeName": "FlaxEngine.MeshCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"IsActive": false,
"Name": "CylinderCollider",
"Transform": {
"Scale": {
"X": 0.3199999928474426,
"Y": 0.8399999737739563,
"Z": 0.3199999928474426
}
},
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
"ID": "e1bd1f734f59807b618a47813903805c",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b377cc03418270d87e8a5b92cb5374ea",
"ParentID": "d9110dd14d9950a23388b894f38cfb87"
},
{
"ID": "b5d566374477944e69bdc2b86249883b",
"TypeName": "FlaxEngine.UICanvas",
"ParentID": "0733cc9b40d3d05366be64bbd9b59e21",
"Name": "DefaultHudPrefab",
"Transform": {
"Orientation": {
"X": 1.0,
"Y": 4.371138828673793e-8,
"Z": 4.371138828673793e-8,
"W": 1.910685465164705e-15
}
},
"V": {}
},
{
@@ -174,7 +118,7 @@
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "eFPS: 120\nuFPS: -2147483648\nrFPS: -2147483648\npFPS: -2147483648\nCon: 0ms\nDirectX11\nGC memory: 11.2093MB",
"Text": "eFPS: 121\nuFPS: 120\nrFPS: 120\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 8.089344MB",
"TextColor": {
"R": 1.0,
"G": 1.0,
@@ -194,6 +138,7 @@
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
@@ -220,7 +165,7 @@
},
"Offsets": {
"Left": 0.0,
"Right": 136.0,
"Right": 143.0,
"Top": -80.0,
"Bottom": 112.0
},
@@ -260,7 +205,7 @@
"Name": "ContainerControl 0",
"Transform": {
"Translation": {
"X": 44855.0,
"X": 45644.0,
"Y": 1.5,
"Z": 0.0
}

View File

@@ -1,7 +1,7 @@
{
"ID": "a0165b834429c74b9d547c88fb3a0de0",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 6220,
"EngineBuild": 6224,
"Data": [
{
"ID": "a0165b834429c74b9d547c88fb3a0de0",
@@ -25,103 +25,53 @@
}
},
{
"ID": "4ef1f38b4569142b55b0ff935525d47a",
"TypeName": "FlaxEngine.RigidBody",
"ParentID": "a0165b834429c74b9d547c88fb3a0de0",
"Name": "PlayerPrefab",
"Transform": {
"Translation": {
"X": -354.623291015625,
"Y": 176.5519256591797,
"Z": 61.111427307128909
}
},
"OverrideMass": true,
"Mass": 10.0,
"LinearDamping": 0.0,
"AngularDamping": 0.0,
"Constraints": 56,
"IsKinematic": true,
"EnableGravity": false
"ID": "f17c6b3346a31cdc5478efa795107612",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "999a202c47de967d2bdfd09abcc6df4e",
"ParentID": "a0165b834429c74b9d547c88fb3a0de0"
},
{
"ID": "e3bab01a4912873fc2e9ff855a214bf7",
"TypeName": "Game.PlayerMovement",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"ID": "3cabff454d2e5cedc7b7f888960e1a30",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b29a58f545071ca393afaab21faa83ad",
"ParentID": "f17c6b3346a31cdc5478efa795107612",
"V": {}
},
{
"ID": "08ed03be4d537814ba01edb88f6801e1",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"Name": "RootActor"
"ID": "42423d104402e24fdc73c7a47181c52f",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "a67383834fc3f6f1106e8099e5557e32",
"ParentID": "f17c6b3346a31cdc5478efa795107612"
},
{
"ID": "499cfa784579b58bba713daa0983d705",
"TypeName": "FlaxEngine.Camera",
"ParentID": "08ed03be4d537814ba01edb88f6801e1",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 28.7337646484375,
"Z": 0.0
}
},
"Near": 1.0
"ID": "4f7d34994c8c1593092319a632b19631",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b8fc420f4efe96fa2b4042bd98fd3e74",
"ParentID": "42423d104402e24fdc73c7a47181c52f"
},
{
"ID": "b59df4764594c5ee84a759b5e65bfc5a",
"TypeName": "FlaxEngine.AudioListener",
"ParentID": "08ed03be4d537814ba01edb88f6801e1",
"Name": "AudioListener"
"ID": "5e49e47141160db3a0fd6694fe83b82d",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "226bdb004e72848777178a9d1f207cbf",
"ParentID": "4f7d34994c8c1593092319a632b19631"
},
{
"ID": "fbaa6db24f0a2a9db36bc6a043fc2572",
"TypeName": "FlaxEngine.CapsuleCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"IsActive": false,
"Name": "CapsuleCollider",
"Transform": {
"Orientation": {
"X": 0.0,
"Y": 0.0,
"Z": 0.7071068286895752,
"W": 0.7071068286895752
}
},
"ContactOffset": 0.0,
"Material": "d99b8b6f40198beea4703dadd642150e",
"Radius": 16.0,
"Height": 52.0
"ID": "85f68702418a995f023ec98ac83db597",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "8bd80bca49ac35da66aabaa2e473851d",
"ParentID": "f17c6b3346a31cdc5478efa795107612"
},
{
"ID": "9677298d46e5d5d7021f7cb607bd3023",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"Name": "BoxCollider",
"ContactOffset": 0.0,
"Material": "ffe0e84c49607480f67a3994a7fe11a8",
"Size": {
"X": 32.0,
"Y": 84.0,
"Z": 32.0
}
"ID": "30607a844f2b90ad59d033942e31de0e",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "d9d61d314ad79d49ba08059cef50f802",
"ParentID": "f17c6b3346a31cdc5478efa795107612"
},
{
"ID": "f472490345bbfe282aefa2aa027e0138",
"TypeName": "FlaxEngine.MeshCollider",
"ParentID": "4ef1f38b4569142b55b0ff935525d47a",
"IsActive": false,
"Name": "CylinderCollider",
"Transform": {
"Scale": {
"X": 0.3199999928474426,
"Y": 0.8399999737739563,
"Z": 0.3199999928474426
}
},
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
"ID": "1886c43f47484f2c2a4608866781bc76",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b377cc03418270d87e8a5b92cb5374ea",
"ParentID": "f17c6b3346a31cdc5478efa795107612"
},
{
"ID": "b5d566374477944e69bdc2b86249883b",
@@ -168,13 +118,13 @@
"Transform": {
"Translation": {
"X": 0.0,
"Y": 733.0,
"Y": 735.0,
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "eFPS: 16\nuFPS: 15\nrFPS: 15\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 8.130952MB",
"Text": "eFPS: 238\nuFPS: 238\nrFPS: 238\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 13.95565MB",
"TextColor": {
"R": 1.0,
"G": 1.0,
@@ -194,6 +144,7 @@
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
@@ -260,8 +211,8 @@
"Name": "ContainerControl 0",
"Transform": {
"Translation": {
"X": 45644.0,
"Y": 0.5,
"X": 44550.0,
"Y": 1.5,
"Z": 0.0
}
},

View File

@@ -1,7 +1,7 @@
{
"ID": "194e05f445ece24ec5448d886e1334df",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 6223,
"EngineBuild": 6224,
"Data": [
{
"ID": "194e05f445ece24ec5448d886e1334df",
@@ -26,110 +26,62 @@
}
},
{
"ID": "19bf0c4f41c16717c90e05a0bdc62e44",
"TypeName": "FlaxEngine.RigidBody",
"ID": "6c66fa4a4a5de8998eb84388d1648317",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "999a202c47de967d2bdfd09abcc6df4e",
"ParentID": "194e05f445ece24ec5448d886e1334df",
"Name": "PlayerPrefab 0",
"Transform": {
"Translation": {
"X": -32.320621490478519,
"Y": 203.23764038085938,
"Z": -187.24435424804688
"X": -571.0,
"Y": 141.0,
"Z": 587.0
}
},
"OverrideMass": true,
"Mass": 10.0,
"LinearDamping": 0.0,
"AngularDamping": 0.0,
"Constraints": 56,
"IsKinematic": true,
"EnableGravity": false
},
{
"ID": "cd7b08774b33983314862eae1a7e6567",
"TypeName": "Game.CameraMovement",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"V": {}
},
{
"ID": "d9d420ce476865e395a966913b5b32bd",
"TypeName": "Game.PlayerMovement",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"V": {},
"Enabled": false
},
{
"ID": "39992ccc4fac12dab97aa4bfb52f0041",
"TypeName": "FlaxEngine.EmptyActor",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"Name": "RootActor"
},
{
"ID": "f54fa132472299e63c8f1aa4f587c179",
"TypeName": "FlaxEngine.Camera",
"ParentID": "39992ccc4fac12dab97aa4bfb52f0041",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 28.7337646484375,
"Z": 0.0
}
},
"Near": 1.0
},
{
"ID": "a42bade1470cd988c7c76685802b0156",
"TypeName": "FlaxEngine.AudioListener",
"ParentID": "39992ccc4fac12dab97aa4bfb52f0041",
"Name": "AudioListener"
},
{
"ID": "89ff5a9540fdffc5f3ef52b3f38bf491",
"TypeName": "FlaxEngine.CapsuleCollider",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"IsActive": false,
"Name": "CapsuleCollider",
"Transform": {
"Orientation": {
"X": 0.0,
"Y": 0.0,
"Z": 0.7071068286895752,
"W": 0.7071068286895752
}
},
"ContactOffset": 0.0,
"Material": "d99b8b6f40198beea4703dadd642150e",
"Radius": 16.0,
"Height": 52.0
},
{
"ID": "5a747ea94050dc31c24017a01556aecd",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"Name": "BoxCollider",
"ContactOffset": 0.0,
"Material": "ffe0e84c49607480f67a3994a7fe11a8",
"Size": {
"X": 32.0,
"Y": 84.0,
"Z": 32.0
}
},
{
"ID": "bfc9d0ee45a71ce96838aea25a540f9c",
"TypeName": "FlaxEngine.MeshCollider",
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
"IsActive": false,
"Name": "CylinderCollider",
"Transform": {
"Scale": {
"X": 0.3199999928474426,
"Y": 0.8399999737739563,
"Z": 0.3199999928474426
}
},
"CollisionData": "593d92914c4bd54679ddec9e539bba80"
"ID": "d5c84d67417ddf09908c76b6f0582b43",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b29a58f545071ca393afaab21faa83ad",
"ParentID": "6c66fa4a4a5de8998eb84388d1648317",
"V": {
"JumpLandSound": "a9ae0bbf438b4e841277f39c3d7c7c8b"
}
},
{
"ID": "d1a76c334a514c99f8f5b2bd81abae2c",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "a67383834fc3f6f1106e8099e5557e32",
"ParentID": "6c66fa4a4a5de8998eb84388d1648317"
},
{
"ID": "357077e9405b2a7ba50198bbed8bd5f9",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b8fc420f4efe96fa2b4042bd98fd3e74",
"ParentID": "d1a76c334a514c99f8f5b2bd81abae2c"
},
{
"ID": "905d23324e7f98c9f8287e8e49a83981",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "226bdb004e72848777178a9d1f207cbf",
"ParentID": "357077e9405b2a7ba50198bbed8bd5f9"
},
{
"ID": "89c02cd64b640185d9947ab451453c4c",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "8bd80bca49ac35da66aabaa2e473851d",
"ParentID": "6c66fa4a4a5de8998eb84388d1648317"
},
{
"ID": "eebdb91647732ad3dfc7528c978cd19c",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "d9d61d314ad79d49ba08059cef50f802",
"ParentID": "6c66fa4a4a5de8998eb84388d1648317"
},
{
"ID": "3e0f83fe407b2d9ed7c734a62fad0826",
"PrefabID": "2d0e518b47d735c98312dd87cc42d6d7",
"PrefabObjectID": "b377cc03418270d87e8a5b92cb5374ea",
"ParentID": "6c66fa4a4a5de8998eb84388d1648317"
},
{
"ID": "ff6b6db54b5aa08e7286ef86246149ef",
@@ -182,7 +134,7 @@
},
"Control": "FlaxEngine.GUI.Label",
"Data": {
"Text": "eFPS: 344\nuFPS: 346\nrFPS: 346\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 62.44806MB",
"Text": "eFPS: 524\nuFPS: -2147483648\nrFPS: -2147483648\npFPS: -2147483648\nCon: 0ms\nDirectX11\nGC memory: 19.59182MB",
"TextColor": {
"R": 1.0,
"G": 1.0,
@@ -202,6 +154,7 @@
"Font": "4508d98f4aa1f0bd59362b81d47e38f4",
"Size": 10
},
"Material": null,
"Margin": {
"Left": 0.0,
"Right": 0.0,
@@ -268,7 +221,7 @@
"Name": "ContainerControl 0",
"Transform": {
"Translation": {
"X": 44550.0,
"X": 44861.0,
"Y": 1.5,
"Z": 0.0
}

View File

@@ -0,0 +1,21 @@
{
"ID": "29a0b0c54b40eb3e6857ffb4c9cab71e",
"TypeName": "Game.BrushMaterialList",
"EngineBuild": 6224,
"Data": {
"materialAssets": [
{
"name": "common/slick",
"asset": "c27c22ec429a17e827421e9a82ac79e4"
},
{
"name": "dev/dev_128_gray",
"asset": "cfe2d8d64700dc00dc2c5088ee028477"
},
{
"name": "dev/dev_128_red",
"asset": "a75d425f40ef7ba5df0fdb8d470e8a78"
}
]
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using FlaxEngine;
namespace Game
{
/// <summary>
/// List of supported materials for loaded levels.
/// Maps the given texture/shader name to Flax Material/MaterialInstance.
/// </summary>
public class BrushMaterialList
{
[EditorDisplay(name: "Material Assets")]
public BrushMaterialListEntry[] materialAssets;
}
public struct BrushMaterialListEntry
{
[EditorOrder(1)]
[EditorDisplay(name: "Name")]
public string name;
[EditorOrder(2)]
[EditorDisplay(name: "Material")]
public MaterialBase asset;
}
}

View File

@@ -320,8 +320,14 @@ namespace Game
case '\n':
break;
// brush face
// brush face (quake format):
// ( <v1> ) ( <v2> ) ( <v3> ) <shader> <x_shift> <y_shift> <rotation> <x_scale> <y_scale>
// brush face (quake3 format):
// ( <v1> ) ( <v2> ) ( <v3> ) <shader> <x_shift> <y_shift> <rotation> <x_scale> <y_scale> <content_flags> <surface_flags> <value>
// brush face (valve format):
// ( <v1> ) ( <v2> ) ( <v3> ) <shader> [ <tx1> <ty1> <tz1> <toffs1> ] [ <tx2> <ty2> <tz2> <toffs2> ] <rotation> <x_scale> <y_scale>
case '(':
{
MapFacePlane plane = new MapFacePlane();
@@ -329,13 +335,36 @@ namespace Game
plane.v2 = ParsePlaneVector3(data, ref index);
plane.v3 = ParsePlaneVector3(data, ref index);
plane.texture = ParseString(data, ref index);
plane.offset = ParseVector2(data, ref index);
plane.rotation = ParseFloat(data, ref index);
plane.scale = ParseVector2(data, ref index);
plane.contentFlags = ParseInt(data, ref index);
plane.surfaceFlags = ParseInt(data, ref index);
plane.surfaceValue = ParseInt(data, ref index);
if (true) // quake or quake3 format
{
plane.offset = ParseVector2(data, ref index);
plane.rotation = ParseFloat(data, ref index);
plane.scale = ParseVector2(data, ref index);
if (true) // quake3 format
{
plane.contentFlags = ParseInt(data, ref index);
plane.surfaceFlags = ParseInt(data, ref index);
plane.surfaceValue = ParseInt(data, ref index);
}
}
else // valve format
{
/*
// " [ "
plane.textureRight = ParseVector3(data, ref index);
plane.offset.X = ParseFloat(data, ref index);
// " ] [ "
plane.textureUp = ParseVector3(data, ref index);
plane.offset.Y = ParseFloat(data, ref index);
// " ] "
plane.rotation = ParseFloat(data, ref index);
plane.scale = ParseVector2(data, ref index);
*/
}
// Flip Y and Z
plane.v1 = new Vector3(plane.v1.X, plane.v1.Z, plane.v1.Y);
plane.v2 = new Vector3(plane.v2.X, plane.v2.Z, plane.v2.Y);
plane.v3 = new Vector3(plane.v3.X, plane.v3.Z, plane.v3.Y);

View File

@@ -31,6 +31,8 @@ namespace Game
[Limit(0, 9000), Tooltip("Base Movement speed")]
public float MoveSpeed { get; set; } = 320;
public AudioClip JumpLandSound;
private float viewPitch;
private float viewYaw;
private float viewRoll;
@@ -40,7 +42,7 @@ namespace Game
private const float collisionMargin = 0.031f * 1.666f;
private const float slopeNormal = 0.7f;
Actor rootActor;
private Actor rootActor;
private RigidBody rigidBody;
public override void OnAwake()
@@ -584,22 +586,17 @@ namespace Game
velocity += Vector3.Up * jumpVelocity;
onGround = false;
Guid jumpguid;
FlaxEngine.Json.JsonSerializer.ParseID("1ef4565844a4b36cdfda54b51f338c77", out jumpguid);
AudioClip jumpAsset = AudioClip.Find<AudioClip>(ref jumpguid);
if (jumpAsset != null && jumpAsset.IsLoaded)
if (JumpLandSound != null && JumpLandSound.IsLoaded)
{
var audioSource = new AudioSource();
audioSource.Clip = jumpAsset;
audioSource.Clip = JumpLandSound;
audioSource.Position = rootActor.Position; //new Vector3(-350, 176, 61);//rootActor.Position;
audioSource.Parent = Actor.Parent;
audioSource.Play();
Destroy(audioSource, jumpAsset.Length);
Console.Print("jumping sound!");
Destroy(audioSource, JumpLandSound.Length);
}
else if (jumpAsset == null)
else if (JumpLandSound == null)
Console.Print("jumpAsset not found");
else
Console.Print("jumpAsset not loaded");

View File

@@ -81,7 +81,7 @@ namespace Game
/// exceptionally close to each other, this value might need to be
/// adjusted.
/// </summary>
const float EPSILON = 0.0001f;
const float EPSILON = 0.001f;
/// <summary>
/// Struct representing a single face.
@@ -1086,7 +1086,10 @@ namespace Game
public class Q3MapImporter : Script
{
private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\cube.map";
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\cube_q1.map";
private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\cube_q3.map";
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\cube_valve.map";
//private string mapPath = @"C:\dev\Goake\maps\aerowalk\aerowalk.map";
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map";
@@ -1672,27 +1675,59 @@ namespace Game
byte[] mapChars = File.ReadAllBytes(mapPath);
root = MapParser.Parse(mapChars);
List<Vector3> vertices = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
List<Vector3> normals = new List<Vector3>();
if (true)
bool oneMesh = false;
bool convexMesh = true;
if (!oneMesh)
{
Dictionary<string, MaterialBase> materials = null;
var mapRootActor = Actor.AddChild<Actor>();
mapRootActor.Name = "MapRootActor";
int brushIndex = 0;
foreach (var brush in root.entities[0].brushes)
{
try
{
Vector3[] brushVertices;
TriangulateBrush3(brush, out brushVertices);
List<Vector3> vertices = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
List<Vector3> normals = new List<Vector3>();
TriangulateBrush3(brush, out Vector3[] brushVertices);
Vector2[] brushUvs = new Vector2[brushVertices.Length];
Vector3[] brushNormals = new Vector3[brushVertices.Length];
for (int i=0; i<brushVertices.Length; i+=3)
// FIXME: brush can have multiple textures
MaterialBase brushMaterial;
var textureName = brush.planes[0].texture;
if (materials == null)
{
Vector3 v1 = brushVertices[i+0];
Vector3 v2 = brushVertices[i+1];
Vector3 v3 = brushVertices[i+2];
var customSettings = Engine.GetCustomSettings("BrushMaterials");
BrushMaterialList brushMaterialList = customSettings?.CreateInstance<BrushMaterialList>();
if (brushMaterialList != null)
{
materials = brushMaterialList.materialAssets.ToDictionary(x => x.name, y => y.asset);
Console.Print("materials dictionary with " + materials.Count + " entries");
}
else
{
materials = new Dictionary<string, MaterialBase>();
Console.Print("no materials dictionary found");
}
}
if (!materials.TryGetValue(textureName, out brushMaterial))
{
Console.Print("Material '" + textureName + "' not found for brush");
materials.Add(textureName, material);
}
for (int i = 0; i < brushVertices.Length; i += 3)
{
Vector3 v1 = brushVertices[i + 0];
Vector3 v2 = brushVertices[i + 1];
Vector3 v3 = brushVertices[i + 2];
Vector3 normal = -Vector3.Cross(v3 - v1, v2 - v1).Normalized;
@@ -1701,19 +1736,19 @@ namespace Game
float uvRotation = 0f;
Vector2 uvOffset = new Vector2(0f);
bool found = false;
Vector2 textureSize = new Vector2(64f); // TODO: figure out the correct size for the material
foreach (var brushPlane in brush.planes)
{
if ((brushPlane.plane.Normal - normal).Length < 0.01f)
{
normal = brushPlane.plane.Normal; // for consistency
uvScale = 1f / brushPlane.scale / textureSize; // texture size?
uvScale = 1f / brushPlane.scale;
uvRotation = brushPlane.rotation;
uvOffset = brushPlane.offset * brushPlane.scale;
found = true;
break;
}
}
if (!found)
Console.Print("no matching plane found, bad geometry?");
@@ -1751,9 +1786,163 @@ namespace Game
Quaternion rot = Quaternion.Identity;
rot = rot * Quaternion.LookRotation(axis, axisForward);
rot = rot * Quaternion.RotationAxis(-Vector3.Forward, 180f * Mathf.DegreesToRadians);
rot = rot * Quaternion.RotationAxis(-Vector3.Forward,
180f * Mathf.DegreesToRadians);
rot = rot * Quaternion.RotationAxis(
Mathf.Abs(Vector3.Dot(axis, Vector3.Right)) > 0.01f ? Vector3.Right : axisForward2,
Mathf.Abs(Vector3.Dot(axis, Vector3.Right)) > 0.01f
? Vector3.Right
: axisForward2,
uvRotation * Mathf.DegreesToRadians);
uv1 = ((Vector2)(v1 * rot) + uvOffset) * uvScale;
uv2 = ((Vector2)(v2 * rot) + uvOffset) * uvScale;
uv3 = ((Vector2)(v3 * rot) + uvOffset) * uvScale;
}
brushUvs[i + 0] = uv1;
brushUvs[i + 1] = uv2;
brushUvs[i + 2] = uv3;
brushNormals[i + 0] = normal;
brushNormals[i + 1] = normal;
brushNormals[i + 2] = normal;
}
vertices.AddRange(brushVertices);
uvs.AddRange(brushUvs);
normals.AddRange(brushNormals);
if (vertices.Count > 0)
{
uint[] triangles = new uint[vertices.Count];
for (uint i = 0; i < vertices.Count; i++)
triangles[i] = i;
Model model = Content.CreateVirtualAsset<Model>();
model.SetupLODs(new int[] { 1 });
model.LODs[0].Meshes[0].UpdateMesh(vertices.ToArray(), (int[])(object)triangles, normals.ToArray(),
null, uvs.ToArray());
StaticModel childModel = Actor.AddChild<StaticModel>();
childModel.Name = "Brush_" + brushIndex;
childModel.Model = model;
childModel.SetMaterial(0, brushMaterial);
childModel.Parent = mapRootActor;
CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>();
if (collisionData.CookCollision(convexMesh ? CollisionDataType.ConvexMesh : CollisionDataType.TriangleMesh, vertices.ToArray(),
triangles.ToArray()))
{
bool failed = true;
if (convexMesh)
{
// fallback to triangle mesh
failed = collisionData.CookCollision(CollisionDataType.TriangleMesh,
vertices.ToArray(),
triangles.ToArray());
if (!failed)
Console.PrintWarning("Hull brush " + brushIndex.ToString() + " is not convex");
}
if (failed)
throw new Exception("failed to cook final collision");
}
var meshCollider = childModel.AddChild<MeshCollider>();
meshCollider.CollisionData = collisionData;
}
}
catch (Exception e)
{
Console.Print("Failed to hull brush " + brushIndex.ToString() + ": " + e.Message);
}
brushIndex++;
}
}
else
{
List<Vector3> vertices = new List<Vector3>();
List<Vector2> uvs = new List<Vector2>();
List<Vector3> normals = new List<Vector3>();
int brushIndex = 0;
foreach (var brush in root.entities[0].brushes)
{
try
{
TriangulateBrush3(brush, out Vector3[] brushVertices);
Vector2[] brushUvs = new Vector2[brushVertices.Length];
Vector3[] brushNormals = new Vector3[brushVertices.Length];
for (int i = 0; i < brushVertices.Length; i += 3)
{
Vector3 v1 = brushVertices[i + 0];
Vector3 v2 = brushVertices[i + 1];
Vector3 v3 = brushVertices[i + 2];
Vector3 normal = -Vector3.Cross(v3 - v1, v2 - v1).Normalized;
// fetch the texture parameters from the plane with matching normal
Vector2 uvScale = new Vector2(0f);
float uvRotation = 0f;
Vector2 uvOffset = new Vector2(0f);
bool found = false;
foreach (var brushPlane in brush.planes)
{
if ((brushPlane.plane.Normal - normal).Length < 0.01f)
{
normal = brushPlane.plane.Normal; // for consistency
uvScale = 1f / brushPlane.scale;
uvRotation = brushPlane.rotation;
uvOffset = brushPlane.offset * brushPlane.scale;
found = true;
break;
}
}
if (!found)
Console.Print("no matching plane found, bad geometry?");
Vector2 uv1, uv2, uv3;
// if quake format
{
// The texture is projected to the surface from three angles, the axis with least
// distortion is chosen here.
// Attempt to workaround most rounding errors at 45-degree angles which causes bias towards one axis.
// This behaviour is seemingly random in different engines and editors, so let's not bother.
Vector3 textureNormal = new Vector3((float)Math.Round(normal.X, 4),
(float)Math.Round(normal.Y, 4), (float)Math.Round(normal.Z, 4));
var dotX = Math.Abs(Vector3.Dot(textureNormal, Vector3.Right));
var dotY = Math.Abs(Vector3.Dot(textureNormal, Vector3.Up));
var dotZ = Math.Abs(Vector3.Dot(textureNormal, Vector3.Forward));
Vector3 axis;
if (dotY >= dotX && dotY >= dotZ)
axis = -Vector3.Up;
else if (dotX >= dotY && dotX >= dotZ)
axis = Vector3.Right;
else if (dotZ >= dotX && dotZ >= dotY)
axis = -Vector3.Forward;
else
axis = Vector3.Right;
var axisForward = Mathf.Abs(Vector3.Dot(axis, Vector3.Up)) > 0.01f
? -Vector3.Forward
: Vector3.Up;
var axisForward2 = Mathf.Abs(Vector3.Dot(axis, Vector3.Up)) > 0.01f
? Vector3.Up
: -Vector3.Forward;
Quaternion rot = Quaternion.Identity;
rot = rot * Quaternion.LookRotation(axis, axisForward);
rot = rot * Quaternion.RotationAxis(-Vector3.Forward,
180f * Mathf.DegreesToRadians);
rot = rot * Quaternion.RotationAxis(
Mathf.Abs(Vector3.Dot(axis, Vector3.Right)) > 0.01f
? Vector3.Right
: axisForward2,
uvRotation * Mathf.DegreesToRadians);
uv1 = ((Vector2)(v1 * rot) + uvOffset) * uvScale;
@@ -1778,34 +1967,33 @@ namespace Game
{
Console.Print("Failed to hull brush " + brushIndex.ToString() + ": " + e.Message);
}
brushIndex++;
}
}
if (vertices.Count > 0)
{
uint[] triangles = new uint[vertices.Count];
for (uint i = 0; i < vertices.Count; i++)
triangles[i] = i;
if (vertices.Count > 0)
{
uint[] triangles = new uint[vertices.Count];
for (uint i = 0; i < vertices.Count; i++)
triangles[i] = i;
model = Content.CreateVirtualAsset<Model>();
model.SetupLODs(new int[] { 1 });
model.LODs[0].Meshes[0].UpdateMesh(vertices.ToArray(), (int[])(object)triangles, normals.ToArray(), null, uvs.ToArray());
model = Content.CreateVirtualAsset<Model>();
model.SetupLODs(new int[] { 1 });
model.LODs[0].Meshes[0].UpdateMesh(vertices.ToArray(), (int[])(object)triangles, normals.ToArray(),
null, uvs.ToArray());
StaticModel childModel = Actor.AddChild<StaticModel>();
childModel.Name = "MapModel";
childModel.Model = model;
childModel.SetMaterial(0, material);
StaticModel childModel = Actor.AddChild<StaticModel>();
childModel.Name = "MapModel";
childModel.Model = model;
childModel.SetMaterial(0, material);
CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>();
if (collisionData.CookCollision(CollisionDataType.TriangleMesh, vertices.ToArray(), triangles.ToArray()))
throw new Exception("failed to cook final collision");
var meshCollider = childModel.AddChild<MeshCollider>();
meshCollider.CollisionData = collisionData;
// TODO: flip Y and Z
//childModel.Orientation = Quaternion.RotationYawPitchRoll(180f*Mathf.DegreesToRadians, -90f*Mathf.DegreesToRadians, 0f);
//childModel.Scale = new Vector3(1f, -1f, 1f);
CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>();
if (collisionData.CookCollision(CollisionDataType.TriangleMesh, vertices.ToArray(),
triangles.ToArray()))
throw new Exception("failed to cook final collision");
var meshCollider = childModel.AddChild<MeshCollider>();
meshCollider.CollisionData = collisionData;
}
}
}