This commit is contained in:
2024-03-27 22:38:48 +02:00
parent a5aed4266d
commit 88fd764928
14 changed files with 813 additions and 341 deletions

View File

@@ -1,21 +0,0 @@
{
"ID": "c095f9ac4989a46afd7fe3821f086e2e",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 65045,
"Data": [
{
"ID": "c095f9ac4989a46afd7fe3821f086e2e",
"TypeName": "FlaxEngine.Scene",
"LightmapSettings": {
"IndirectLightingIntensity": 1.0,
"GlobalObjectsScale": 1.0,
"ChartsPadding": 3,
"AtlasSize": 1024,
"BounceCount": 1,
"CompressLightmaps": true,
"UseGeometryWithNoMaterials": true,
"Quality": 10
}
}
]
}

View File

@@ -1,7 +1,7 @@
{ {
"ID": "194e05f445ece24ec5448d886e1334df", "ID": "194e05f445ece24ec5448d886e1334df",
"TypeName": "FlaxEngine.SceneAsset", "TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 6407, "EngineBuild": 65046,
"Data": [ "Data": [
{ {
"ID": "194e05f445ece24ec5448d886e1334df", "ID": "194e05f445ece24ec5448d886e1334df",
@@ -17,23 +17,18 @@
"Quality": 10 "Quality": 10
} }
}, },
{
"ID": "c95a3dab492c1b2046ce2191daa2b111",
"TypeName": "Game.Q3MapImporter",
"ParentID": "194e05f445ece24ec5448d886e1334df",
"V": {
"mapPath": "Assets/Maps/aerowalk.map",
"importLights": true,
"BrightnessMultiplier": 0.8227397,
"LightRadiusMultiplier": 9.458821,
"StaticBatching": true
}
},
{ {
"ID": "ff6b6db54b5aa08e7286ef86246149ef", "ID": "ff6b6db54b5aa08e7286ef86246149ef",
"PrefabID": "cb74184545f392e5c67815808bc63e58", "PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "9e1b61dc44338f962e69f78ecb3d0536", "PrefabObjectID": "9e1b61dc44338f962e69f78ecb3d0536",
"ParentID": "194e05f445ece24ec5448d886e1334df", "ParentID": "194e05f445ece24ec5448d886e1334df",
"Transform": {
"Translation": {
"X": 3.0,
"Y": 0.0,
"Z": 0.0
}
},
"V": {} "V": {}
}, },
{ {
@@ -50,13 +45,13 @@
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef", "ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"Transform": { "Transform": {
"Translation": { "Translation": {
"X": 1027.0, "X": 1819.0,
"Y": 457.0, "Y": 1058.0,
"Z": 0.0 "Z": 0.0
} }
}, },
"Data": { "Data": {
"Text": "0 tris\n 0 drawcalls\n-2147483648fps2\n60fps" "Text": "0 tris\n 0 drawcalls\n15fps2\n15fps"
} }
}, },
{ {
@@ -73,6 +68,13 @@
"TypeName": "FlaxEngine.UIControl", "TypeName": "FlaxEngine.UIControl",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef", "ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"Name": "CrosshairWidget", "Name": "CrosshairWidget",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 1.0,
"Z": 0.0
}
},
"Control": "FlaxEngine.GUI.Image", "Control": "FlaxEngine.GUI.Image",
"Data": { "Data": {
"Brush": { "Brush": {
@@ -117,8 +119,8 @@
"Offsets": { "Offsets": {
"Left": 0.0, "Left": 0.0,
"Right": 0.0, "Right": 0.0,
"Top": 0.0, "Top": 1.0,
"Bottom": 0.0 "Bottom": -1.0
}, },
"Scale": { "Scale": {
"X": 1.0, "X": 1.0,
@@ -149,30 +151,6 @@
"TypeName": "Game.CrosshairWidget", "TypeName": "Game.CrosshairWidget",
"ParentID": "2fe5467d4e92726e24227cbcbcbd2844", "ParentID": "2fe5467d4e92726e24227cbcbcbd2844",
"V": {} "V": {}
},
{
"ID": "8736d067492170db415102997d187ff7",
"TypeName": "FlaxEngine.DirectionalLight",
"ParentID": "194e05f445ece24ec5448d886e1334df",
"IsActive": false,
"Name": "DirectionalLight",
"Transform": {
"Translation": {
"X": -370.8681335449219,
"Y": 191.241943359375,
"Z": -134.10745239257813
},
"Orientation": {
"X": 0.8119235038757324,
"Y": -7.162299908713976e-8,
"Z": -7.162299908713976e-8,
"W": 0.5837640166282654
}
},
"Brightness": 21.700000762939454,
"ViewDistance": 15400.0,
"ShadowsDistance": 9715.0,
"ShadowsFadeDistance": 5000.0
} }
] ]
} }

View File

@@ -0,0 +1,107 @@
{
"ID": "a916228c48fe3a0e89ff0985d4ad2fca",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 65045,
"Data": [
{
"ID": "a916228c48fe3a0e89ff0985d4ad2fca",
"TypeName": "FlaxEngine.Scene",
"LightmapSettings": {
"IndirectLightingIntensity": 1.0,
"GlobalObjectsScale": 1.0,
"ChartsPadding": 3,
"AtlasSize": 1024,
"BounceCount": 1,
"CompressLightmaps": true,
"UseGeometryWithNoMaterials": true,
"Quality": 10
}
},
{
"ID": "6ee4b1e34ce62731b943e586b9864ae2",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "a916228c48fe3a0e89ff0985d4ad2fca",
"Name": "CubeFloor",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 10.555465698242188,
"Z": 0.0
},
"Scale": {
"X": 3.7614870071411135,
"Y": 0.26607516407966616,
"Z": 3.4711759090423586
}
},
"Model": "b43f0f8f4aaba3f3156896a5a22ba493",
"Buffer": {
"Entries": [
{
"Material": "00000000000000000000000000000000",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
},
{
"ID": "88b1ed59418cb010695115991acaa790",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "6ee4b1e34ce62731b943e586b9864ae2",
"Name": "BoxCollider"
},
{
"ID": "5aee089144314eac43865588f949cbe2",
"TypeName": "FlaxEngine.RigidBody",
"ParentID": "a916228c48fe3a0e89ff0985d4ad2fca",
"Name": "RigidBody",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 92.45675659179688,
"Z": -42.916717529296878
}
},
"Mass": 27.00000762939453
},
{
"ID": "9a4e12084b6613849096a9b285b72c53",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "5aee089144314eac43865588f949cbe2",
"Name": "BoxCollider",
"Transform": {
"Scale": {
"X": 0.30000001192092898,
"Y": 0.30000001192092898,
"Z": 0.30000001192092898
}
}
},
{
"ID": "6212e97240b1373f995b779a65a8a5f3",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "5aee089144314eac43865588f949cbe2",
"Name": "Cube",
"Transform": {
"Scale": {
"X": 0.30000001192092898,
"Y": 0.30000001192092898,
"Z": 0.30000001192092898
}
},
"Model": "b43f0f8f4aaba3f3156896a5a22ba493",
"Buffer": {
"Entries": [
{
"Material": "00000000000000000000000000000000",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
}
]
}

View File

@@ -0,0 +1,107 @@
{
"ID": "f749e5d141e1384c05e49abe92a4fb90",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 65045,
"Data": [
{
"ID": "f749e5d141e1384c05e49abe92a4fb90",
"TypeName": "FlaxEngine.Scene",
"LightmapSettings": {
"IndirectLightingIntensity": 1.0,
"GlobalObjectsScale": 1.0,
"ChartsPadding": 3,
"AtlasSize": 1024,
"BounceCount": 1,
"CompressLightmaps": true,
"UseGeometryWithNoMaterials": true,
"Quality": 10
}
},
{
"ID": "8048c4f041c327d1bbd03ab890f73405",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "f749e5d141e1384c05e49abe92a4fb90",
"Name": "CubeFloor",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 10.555465698242188,
"Z": 0.0
},
"Scale": {
"X": 3.7614870071411135,
"Y": 0.26607516407966616,
"Z": 3.4711759090423586
}
},
"Model": "b43f0f8f4aaba3f3156896a5a22ba493",
"Buffer": {
"Entries": [
{
"Material": "00000000000000000000000000000000",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
},
{
"ID": "c26bd5b24ea23e14a6bd77b1ff3e6a19",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "8048c4f041c327d1bbd03ab890f73405",
"Name": "BoxCollider"
},
{
"ID": "3ebecf744a613387694b3b9432a576f5",
"TypeName": "FlaxEngine.RigidBody",
"ParentID": "f749e5d141e1384c05e49abe92a4fb90",
"Name": "RigidBody",
"Transform": {
"Translation": {
"X": 0.0,
"Y": 92.45675659179688,
"Z": -42.916717529296878
}
},
"Mass": 27.00000762939453
},
{
"ID": "3be79c2b48f15d4ab126fcbb34104efb",
"TypeName": "FlaxEngine.BoxCollider",
"ParentID": "3ebecf744a613387694b3b9432a576f5",
"Name": "BoxCollider",
"Transform": {
"Scale": {
"X": 0.30000001192092898,
"Y": 0.30000001192092898,
"Z": 0.30000001192092898
}
}
},
{
"ID": "8d3acad54ec87dc0bccd0c9b68bd09a8",
"TypeName": "FlaxEngine.StaticModel",
"ParentID": "3ebecf744a613387694b3b9432a576f5",
"Name": "Cube",
"Transform": {
"Scale": {
"X": 0.30000001192092898,
"Y": 0.30000001192092898,
"Z": 0.30000001192092898
}
},
"Model": "b43f0f8f4aaba3f3156896a5a22ba493",
"Buffer": {
"Entries": [
{
"Material": "00000000000000000000000000000000",
"ShadowsMode": 3,
"Visible": true,
"ReceiveDecals": true
}
]
}
}
]
}

View File

@@ -0,0 +1,207 @@
{
"ID": "5524fb9c40412196af3d79a9daae64cc",
"TypeName": "FlaxEngine.SceneAsset",
"EngineBuild": 65045,
"Data": [
{
"ID": "5524fb9c40412196af3d79a9daae64cc",
"TypeName": "FlaxEngine.Scene",
"LightmapSettings": {
"IndirectLightingIntensity": 1.0,
"GlobalObjectsScale": 1.0,
"ChartsPadding": 3,
"AtlasSize": 1024,
"BounceCount": 1,
"CompressLightmaps": true,
"UseGeometryWithNoMaterials": true,
"Quality": 10
}
},
{
"ID": "c95a3dab492c1b2046ce2191daa2b111",
"TypeName": "Game.Q3MapImporter",
"ParentID": "5524fb9c40412196af3d79a9daae64cc",
"V": {
"mapPath": "Assets/Maps/aerowalk.map",
"importLights": true,
"BrightnessMultiplier": 0.8227397,
"LightRadiusMultiplier": 9.458821,
"StaticBatching": true
}
},
{
"ID": "3a7aeb9c482dce809d729287977859be",
"TypeName": "Game.MultiSceneScript",
"ParentID": "5524fb9c40412196af3d79a9daae64cc",
"V": {}
},
{
"ID": "ff6b6db54b5aa08e7286ef86246149ef",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "9e1b61dc44338f962e69f78ecb3d0536",
"ParentID": "5524fb9c40412196af3d79a9daae64cc",
"IsActive": false,
"V": {}
},
{
"ID": "02119c7243cb3a4a4ffcd395ff07e23d",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "e94561104b27c841e6ab0bb479bde17a",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"V": {}
},
{
"ID": "ad0c546649722a6c7a6b9aa8fdcac019",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "926bc11f416c9cef57d383875a480ded",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"Transform": {
"Translation": {
"X": -101.0,
"Y": -22.0,
"Z": 0.0
}
},
"Data": {}
},
{
"ID": "35b34b0c4476f0ed43aa8fb4d5f2eebc",
"PrefabID": "cb74184545f392e5c67815808bc63e58",
"PrefabObjectID": "85ddca4e46ed0c030d063599ac716e96",
"ParentID": "ad0c546649722a6c7a6b9aa8fdcac019",
"V": {
"control": "ad0c546649722a6c7a6b9aa8fdcac019"
}
},
{
"ID": "2fe5467d4e92726e24227cbcbcbd2844",
"TypeName": "FlaxEngine.UIControl",
"ParentID": "ff6b6db54b5aa08e7286ef86246149ef",
"Name": "CrosshairWidget",
"Control": "FlaxEngine.GUI.Image",
"Data": {
"Brush": {
"$type": "FlaxEngine.GUI.MaterialBrush, FlaxEngine.CSharp",
"Material": "3f912eea48c6e2438fe49881210cb7d7"
},
"Margin": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"Color": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"MouseOverColor": {
"R": 1.0,
"G": 1.0,
"B": 1.0,
"A": 1.0
},
"DisabledTint": {
"R": 0.5019608,
"G": 0.5019608,
"B": 0.5019608,
"A": 1.0
},
"KeepAspectRatio": false,
"ClipChildren": true,
"CullChildren": true,
"AnchorMin": {
"X": 0.0,
"Y": 0.0
},
"AnchorMax": {
"X": 1.0,
"Y": 1.0
},
"Offsets": {
"Left": 0.0,
"Right": 0.0,
"Top": 0.0,
"Bottom": 0.0
},
"Scale": {
"X": 1.0,
"Y": 1.0
},
"Pivot": {
"X": 0.5,
"Y": 0.5
},
"Shear": {
"X": 0.0,
"Y": 0.0
},
"Rotation": 0.0,
"BackgroundColor": {
"R": 0.0,
"G": 0.0,
"B": 0.0,
"A": 0.0
},
"Enabled": true,
"Visible": true,
"AutoFocus": false
}
},
{
"ID": "e12c6b914501fde5098a14a350c2809c",
"TypeName": "Game.CrosshairWidget",
"ParentID": "2fe5467d4e92726e24227cbcbcbd2844",
"V": {}
},
{
"ID": "8736d067492170db415102997d187ff7",
"TypeName": "FlaxEngine.DirectionalLight",
"ParentID": "5524fb9c40412196af3d79a9daae64cc",
"IsActive": false,
"Name": "DirectionalLight",
"Transform": {
"Translation": {
"X": -370.8681335449219,
"Y": 191.241943359375,
"Z": -134.10745239257813
},
"Orientation": {
"X": 0.8119235038757324,
"Y": -7.162299908713976e-8,
"Z": -7.162299908713976e-8,
"W": 0.5837640166282654
}
},
"Brightness": 21.700000762939454,
"ViewDistance": 15400.0,
"ShadowsDistance": 9715.0,
"ShadowsFadeDistance": 5000.0
},
{
"ID": "6d29a4d44ce988b4b1844caa39c2a2bd",
"TypeName": "FlaxEngine.Camera",
"ParentID": "5524fb9c40412196af3d79a9daae64cc",
"Name": "Camera",
"Transform": {
"Translation": {
"X": 136.9144744873047,
"Y": 131.739990234375,
"Z": -495.9844665527344
},
"Orientation": {
"X": 0.09739881008863449,
"Y": -0.05181961879134178,
"Z": 0.005078235175460577,
"W": 0.9938824772834778
},
"Scale": {
"X": 1.0006136894226075,
"Y": 0.999918520450592,
"Z": 1.0005552768707276
}
}
}
]
}

View File

@@ -1,7 +1,7 @@
{ {
"ID": "f94d5aae457aeba67033a8a4ca753214", "ID": "f94d5aae457aeba67033a8a4ca753214",
"TypeName": "FlaxEditor.Content.Settings.GraphicsSettings", "TypeName": "FlaxEditor.Content.Settings.GraphicsSettings",
"EngineBuild": 6407, "EngineBuild": 65045,
"Data": { "Data": {
"UseVSync": false, "UseVSync": false,
"AAQuality": 3, "AAQuality": 3,
@@ -31,7 +31,7 @@
}, },
"GI": { "GI": {
"OverrideFlags": 63, "OverrideFlags": 63,
"Mode": 0, "Mode": 1,
"Intensity": 1.0, "Intensity": 1.0,
"BounceIntensity": 1.0, "BounceIntensity": 1.0,
"TemporalResponse": 0.0, "TemporalResponse": 0.0,

BIN
Content/Visual Script.flax Normal file

Binary file not shown.

View File

@@ -91,7 +91,7 @@ namespace Game
private int GetFontCharacterWidth() private int GetFontCharacterWidth()
{ {
Font font = Font.GetFont(); Font font = Font?.GetFont();
if (!font) if (!font)
return 0; return 0;
return (int)font.MeasureText("a").X; // hacky, but works for fixed-size fonts... return (int)font.MeasureText("a").X; // hacky, but works for fixed-size fonts...
@@ -99,7 +99,7 @@ namespace Game
public int GetFontHeight() public int GetFontHeight()
{ {
Font font = Font.GetFont(); Font font = Font?.GetFont();
if (font == null) if (font == null)
return (int)Height; return (int)Height;
@@ -108,7 +108,7 @@ namespace Game
private int GetHeightInLines() private int GetHeightInLines()
{ {
Font font = Font.GetFont(); Font font = Font?.GetFont();
if (!font) if (!font)
return 0; return 0;
return (int)(Height / (font.Height / Platform.DpiScale)); // number of fully visible lines return (int)(Height / (font.Height / Platform.DpiScale)); // number of fully visible lines
@@ -323,7 +323,6 @@ namespace Game
} }
} }
Render2D.FillRectangle(selectionRect, selectionColor); Render2D.FillRectangle(selectionRect, selectionColor);
layout.Bounds.Y += lineHeight; layout.Bounds.Y += lineHeight;

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using FlaxEngine; using FlaxEngine;
using FlaxEngine.Assertions; using FlaxEngine.Assertions;
using FlaxEngine.Json; using FlaxEngine.Json;
@@ -98,40 +99,70 @@ namespace Game
else else
NetworkManager.RegisterClientMessageCallback(OnMessage); NetworkManager.RegisterClientMessageCallback(OnMessage);
if (IsLocalClient)
PhysicsScene localPhysicsScene = Physics.FindOrCreateScene(IsLocalClient ? "ClientPhysicsScene" : "ServerPhysicsScene");
Guid sceneGuid = JsonSerializer.ParseID(IsLocalClient ? "c095f9ac4989a46afd7fe3821f086e2e" : "59dd37cc444d5d7015759389c6153c4c");
string sceneData = $@"
{{
""ID"": ""{JsonSerializer.GetStringID(sceneGuid)}"",
""TypeName"": ""FlaxEngine.SceneAsset"",
""EngineBuild"": 65046,
""Data"": [
{{
""ID"": ""{JsonSerializer.GetStringID(sceneGuid)}"",
""TypeName"": ""FlaxEngine.Scene"",
""LightmapSettings"": {{
""IndirectLightingIntensity"": 1.0,
""GlobalObjectsScale"": 1.0,
""ChartsPadding"": 3,
""AtlasSize"": 1024,
""BounceCount"": 1,
""CompressLightmaps"": true,
""UseGeometryWithNoMaterials"": true,
""Quality"": 10
}}
}}
]
}}";
{ {
PhysicsScene localPhysicsScene = Physics.FindOrCreateScene("LocalPhysicsScene");
Guid localClientSceneGuid = JsonSerializer.ParseID("c095f9ac4989a46afd7fe3821f086e2e");
var onSceneLoaded = (Scene loadedScene, Guid id) => var onSceneLoaded = (Scene loadedScene, Guid id) =>
{ {
if (localClientSceneGuid == id) if (sceneGuid == id)
{ {
loadedScene.PhysicsScene = localPhysicsScene; loadedScene.PhysicsScene = localPhysicsScene;
scene = loadedScene; //scene = loadedScene;
} }
}; };
try try
{ {
Level.SceneLoaded += onSceneLoaded; Level.SceneLoaded += onSceneLoaded;
Level.LoadScene(new SceneReference(localClientSceneGuid)); //Level.LoadScene(new SceneReference(sceneGuid));
scene = Level.LoadSceneFromBytes(Encoding.ASCII.GetBytes(sceneData));
} }
finally finally
{ {
Level.SceneLoaded -= onSceneLoaded; Level.SceneLoaded -= onSceneLoaded;
} }
} }
else
scene = Level.GetScene(0);
Assert.IsTrue(scene); Assert.IsTrue(scene);
scene.Name = IsLocalClient ? "ClientScene" : "ServerScene";
Level.SceneLoaded += OnLevelLoaded; Level.SceneLoaded += OnLevelLoaded;
//Scripting.LateUpdate += OnLateUpdatePre; //Scripting.LateUpdate += OnLateUpdatePre;
Scripting.LateFixedUpdate += OnLateUpdatePre; Scripting.LateFixedUpdate += OnLateUpdatePre;
worldSpawn = scene.FindActor("WorldSpawn") ?? Level.FindActor("WorldSpawn");
var importer = FlaxEngine.Object.New<Q3MapImporter>();
importer.mapPath = @"C:\dev\GoakeFlax\Assets\Maps\aerowalk.map";
importer.LoadCollidersOnly = false;//IsServer;
importer.Parent = scene;
//importer.Enabled = true;
worldSpawn = scene.FindActor("WorldSpawn");// ?? Level.FindActor("WorldSpawn");
Assert.IsTrue(worldSpawn); Assert.IsTrue(worldSpawn);
} }

View File

@@ -49,7 +49,7 @@ namespace Game
public string mapPath;// = @"C:\dev\Goake\maps\aerowalk\aerowalk.map"; public string mapPath;// = @"C:\dev\Goake\maps\aerowalk\aerowalk.map";
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map"; //private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map";
public bool importLights = false; public bool importLights = true;
private bool generateSdf = true; private bool generateSdf = true;
private bool childModelSdf = true; private bool childModelSdf = true;
@@ -116,6 +116,19 @@ namespace Game
} }
} }
public bool LoadCollidersOnly
{
get => collidersOnly;
set
{
if (collidersOnly == value)
return;
collidersOnly = value;
dirtyLights = true;
dirtyMap = true;
}
}
private static void QuickHull(Float3[] points, out Float3[] outVertices) private static void QuickHull(Float3[] points, out Float3[] outVertices)
{ {
@@ -333,6 +346,7 @@ namespace Game
private bool sceneLighting = false; private bool sceneLighting = false;
private bool sceneShadows = false; private bool sceneShadows = false;
private bool staticBatching = false; private bool staticBatching = false;
private bool collidersOnly = false;
private bool globalIllumination = false; private bool globalIllumination = false;
public override void OnUpdate() public override void OnUpdate()
{ {
@@ -457,6 +471,9 @@ namespace Game
private void LoadMap(bool forceLoad) private void LoadMap(bool forceLoad)
{ {
if (string.IsNullOrEmpty(mapPath))
return;
Stopwatch sw = Stopwatch.StartNew(); Stopwatch sw = Stopwatch.StartNew();
@@ -492,9 +509,10 @@ namespace Game
// FlaxEngine.Debug.Log("No WorldSpawn, loading map"); // FlaxEngine.Debug.Log("No WorldSpawn, loading map");
bool oneMesh = false; bool oneMesh = false;
bool useStaticBatching = StaticBatching; bool useStaticBatching = StaticBatching && !LoadCollidersOnly;
bool convexMesh = true; bool convexMesh = true;
FlaxEngine.Debug.Log("Loading map, static batching: " + useStaticBatching); FlaxEngine.Debug.Log("Loading map, static batching: " + useStaticBatching);
{ {
string matBasePath = Path.Combine(AssetManager.ContentPath, "Materials"); string matBasePath = Path.Combine(AssetManager.ContentPath, "Materials");
@@ -743,14 +761,24 @@ namespace Game
brushIndex = 0; brushIndex = 0;
foreach (BrushGeometry geom in brushGeometries) foreach (BrushGeometry geom in brushGeometries)
{ {
StaticModel childModel = worldSpawnActor.AddChild<StaticModel>(); Actor childModel;
childModel.Name = "Brush_" + brushIndex; if (LoadCollidersOnly)
childModel.Model = geom.model; {
childModel.Position = geom.offset; childModel = worldSpawnActor.AddChild<EmptyActor>();
//childModel.DrawModes = DrawPass.None; }
else
{
StaticModel staticModel = worldSpawnActor.AddChild<StaticModel>();
staticModel.Model = geom.model;
//staticModel.DrawModes = DrawPass.None;
for (int i = 0; i < geom.meshes.Length; i++) for (int i = 0; i < geom.meshes.Length; i++)
childModel.SetMaterial(i, geom.meshes[i].material); staticModel.SetMaterial(i, geom.meshes[i].material);
childModel = staticModel;
}
childModel.Name = "Brush_" + brushIndex;
childModel.Position = geom.offset;
BrushScript brushScript = childModel.AddScript<BrushScript>(); BrushScript brushScript = childModel.AddScript<BrushScript>();
@@ -760,16 +788,17 @@ namespace Game
bool isClipMaterial = false; bool isClipMaterial = false;
bool isMissingMaterial = false; bool isMissingMaterial = false;
if (geom.meshes.Length == 1) if (geom.meshes.Length == 1 && !LoadCollidersOnly)
{ {
MaterialParameter info = geom.meshes[0].material.GetParameter("IsClipMaterial"); MaterialParameter info = geom.meshes[0].material.GetParameter("IsClipMaterial");
if (info != null && (bool)info.Value) if (info != null && (bool)info.Value)
{ {
var entries = childModel.Entries; StaticModel staticModel = childModel.As<StaticModel>();
var entries = staticModel.Entries;
entries[0].Visible = false; entries[0].Visible = false;
entries[0].ShadowsMode = ShadowsCastingMode.None; entries[0].ShadowsMode = ShadowsCastingMode.None;
entries[0].ReceiveDecals = false; entries[0].ReceiveDecals = false;
childModel.Entries = entries; staticModel.Entries = entries;
isClipMaterial = true; isClipMaterial = true;
} }
@@ -777,14 +806,17 @@ namespace Game
isMissingMaterial = true; isMissingMaterial = true;
} }
/*{ /*
var entries = childModel.Entries; if (!LoadCollidersOnly)
{
StaticModel staticModel = childModel.As<StaticModel>();
var entries = staticModel.Entries;
for (int i=0; i < entries.Length; i++) for (int i=0; i < entries.Length; i++)
entries[i].Visible = false; entries[i].Visible = false;
childModel.Entries = entries; staticModel.Entries = entries;
}*/ }*/
if (!isClipMaterial && !isMissingMaterial) if (!isClipMaterial && !isMissingMaterial && !LoadCollidersOnly)
sdfModels.Add(geom.model); sdfModels.Add(geom.model);
CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>(); CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>();
@@ -1286,11 +1318,9 @@ namespace Game
private void ParseLight(MapEntity entity, ref int lightIndex) private void ParseLight(MapEntity entity, ref int lightIndex)
{ {
LightWithShadow light; Actor actor;
Float3? lightTargetPosition = null; Float3? lightTargetPosition = null;
if (entity.properties.TryGetValue("target", out string targetName)) if (entity.properties.TryGetValue("target", out string targetName))
{ {
var target = root.entities.FirstOrDefault(x => var target = root.entities.FirstOrDefault(x =>
@@ -1300,148 +1330,155 @@ namespace Game
lightTargetPosition = ParseOrigin(target.properties["origin"]); lightTargetPosition = ParseOrigin(target.properties["origin"]);
} }
if (!lightTargetPosition.HasValue) if (LoadCollidersOnly)
light = worldSpawnActor.AddChild<PointLight>(); actor = worldSpawnActor.AddChild<EmptyActor>();
else if (!lightTargetPosition.HasValue)
actor = worldSpawnActor.AddChild<PointLight>();
else else
light = worldSpawnActor.AddChild<SpotLight>(); actor = worldSpawnActor.AddChild<SpotLight>();
if (!lightTargetPosition.HasValue)
actor.Name = "Light_" + lightIndex;
else
actor.Name = "SpotLight_" + lightIndex;
//Console.Print("light"); //Console.Print("light");
//PointLight light = worldSpawnActor.AddChild<PointLight>(); //PointLight light = worldSpawnActor.AddChild<PointLight>();
//LightWithShadow light = new PointLight(); //LightWithShadow light = new PointLight();
var pointLight = light as PointLight; //var light = actor as LightWithShadow;
var spotLight = light as SpotLight;
if (spotLight != null) actor.IsActive = sceneLighting;
light.Name = "SpotLight_" + lightIndex; actor.LocalPosition = ParseOrigin(entity.properties["origin"]);
else actor.Layer = 1;
light.Name = "Light_" + lightIndex;
light.IsActive = sceneLighting;
light.LocalPosition = ParseOrigin(entity.properties["origin"]);
if (lightTargetPosition.HasValue) if (lightTargetPosition.HasValue)
light.Orientation = Quaternion.LookAt(light.LocalPosition, lightTargetPosition.Value); actor.Orientation = Quaternion.LookAt(actor.LocalPosition, lightTargetPosition.Value);
if (entity.properties.TryGetValue("_color", out string colorStr)) if (actor is LightWithShadow light)
light.Color = ParseColor(colorStr);
float lightamm = 300f;
if (entity.properties.TryGetValue("light", out string lightStr))
lightamm = float.Parse(lightStr);
float radamm = 64f;
if (entity.properties.TryGetValue("radius", out string radStr))
radamm = float.Parse(radStr);
bool castShadows = true;
if (entity.properties.TryGetValue("castshadows", out string castShadowsStr))
castShadows = int.Parse(castShadowsStr) != 0;
light.Layer = 1;
if (pointLight != null)
{ {
pointLight.UseInverseSquaredFalloff = false; var pointLight = light as PointLight;
pointLight.FallOffExponent = 8; var spotLight = light as SpotLight;
pointLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
}
if (spotLight != null)
{
spotLight.UseInverseSquaredFalloff = false;
spotLight.FallOffExponent = 8;
spotLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
spotLight.InnerConeAngle = 65f;
spotLight.OuterConeAngle = 80f;
}
light.ShadowsDistance = 500f; if (entity.properties.TryGetValue("_color", out string colorStr))
light.ShadowsDepthBias = 0.027f;//0.005f; light.Color = ParseColor(colorStr);
int preset = 3; float lightamm = 300f;
if (preset == 0) // most accurate?, huge radius and low performance if (entity.properties.TryGetValue("light", out string lightStr))
{ lightamm = float.Parse(lightStr);
light.Brightness = lightamm / 93f;
light.ShadowsDepthBias = 0.0565f; float radamm = 64f;
if (entity.properties.TryGetValue("radius", out string radStr))
radamm = float.Parse(radStr);
light.Brightness *= 0.7837f; bool castShadows = true;
if (entity.properties.TryGetValue("castshadows", out string castShadowsStr))
castShadows = int.Parse(castShadowsStr) != 0;
if (pointLight != null) if (pointLight != null)
{ {
pointLight.Radius = radamm * 12.5f; pointLight.UseInverseSquaredFalloff = false;
pointLight.FallOffExponent = 3.33f; pointLight.FallOffExponent = 8;
pointLight.Radius *= 0.83375f; pointLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
} }
if (spotLight != null)
var hsv = light.Color.ToHSV();
hsv.Y *= 0.8f;
light.Color = Color.FromHSV(hsv);
}
else if (preset == 1) //
{
if (pointLight != null)
{ {
pointLight.Radius = 250f; spotLight.UseInverseSquaredFalloff = false;
pointLight.FallOffExponent = 2f; spotLight.FallOffExponent = 8;
spotLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
spotLight.InnerConeAngle = 65f;
spotLight.OuterConeAngle = 80f;
} }
light.Brightness = (lightamm / 128f) * 1.25f;
}
else if (preset == 2)
{
if (pointLight != null)
{
pointLight.Radius = 200f;
pointLight.FallOffExponent = 2f;
}
light.Brightness = (lightamm / 128f) * 1.6f;
}
else //if (preset == 3)
{
bool inverse = false;
float finalRadius = radamm * LightRadiusMultiplier;
light.Brightness = (lightamm / 128f) * BrightnessMultiplier;
light.ShadowsNormalOffsetScale = 10f;
light.ShadowsFadeDistance = 100f; // for debugging
light.ShadowsDistance = 500f; light.ShadowsDistance = 500f;
light.ShadowsDepthBias = 0.027f;//0.005f;
var hsv = light.Color.ToHSV(); int preset = 3;
hsv.Y *= SaturationMultiplier; if (preset == 0) // most accurate?, huge radius and low performance
light.Color = Color.FromHSV(hsv);
light.IndirectLightingIntensity = IndirectLightMultiplier;
light.ShadowsDepthBias = 0.0565f;
// if low quality shadows
//light.ShadowsDepthBias = 0.2492f;
if (spotLight != null)
{ {
// huge aliasing with spot lights for some reason? light.Brightness = lightamm / 93f;
light.ShadowsDepthBias = 0.7f;
light.ShadowsDepthBias = 0.0565f;
light.Brightness *= 0.7837f;
if (pointLight != null)
{
pointLight.Radius = radamm * 12.5f;
pointLight.FallOffExponent = 3.33f;
pointLight.Radius *= 0.83375f;
}
var hsv = light.Color.ToHSV();
hsv.Y *= 0.8f;
light.Color = Color.FromHSV(hsv);
} }
else if (preset == 1) //
{
if (pointLight != null)
{
pointLight.Radius = 250f;
pointLight.FallOffExponent = 2f;
}
if (inverse) light.Brightness = (lightamm / 128f) * 1.25f;
{
light.Brightness *= 20000f;
finalRadius *= 0.7f;
} }
else if (preset == 2)
{
if (pointLight != null)
{
pointLight.Radius = 200f;
pointLight.FallOffExponent = 2f;
}
if (pointLight != null) light.Brightness = (lightamm / 128f) * 1.6f;
{
pointLight.UseInverseSquaredFalloff = inverse;
pointLight.Radius = finalRadius;
pointLight.FallOffExponent = FallOffExponent;
} }
if (spotLight != null) else //if (preset == 3)
{ {
spotLight.UseInverseSquaredFalloff = inverse; bool inverse = false;
spotLight.Radius = finalRadius; float finalRadius = radamm * LightRadiusMultiplier;
spotLight.FallOffExponent = FallOffExponent;
light.Brightness = (lightamm / 128f) * BrightnessMultiplier;
light.ShadowsNormalOffsetScale = 10f;
light.ShadowsFadeDistance = 100f; // for debugging
light.ShadowsDistance = 500f;
var hsv = light.Color.ToHSV();
hsv.Y *= SaturationMultiplier;
light.Color = Color.FromHSV(hsv);
light.IndirectLightingIntensity = IndirectLightMultiplier;
light.ShadowsDepthBias = 0.0565f;
// if low quality shadows
//light.ShadowsDepthBias = 0.2492f;
if (spotLight != null)
{
// huge aliasing with spot lights for some reason?
light.ShadowsDepthBias = 0.7f;
}
if (inverse)
{
light.Brightness *= 20000f;
finalRadius *= 0.7f;
}
if (pointLight != null)
{
pointLight.UseInverseSquaredFalloff = inverse;
pointLight.Radius = finalRadius;
pointLight.FallOffExponent = FallOffExponent;
}
if (spotLight != null)
{
spotLight.UseInverseSquaredFalloff = inverse;
spotLight.Radius = finalRadius;
spotLight.FallOffExponent = FallOffExponent;
}
} }
} }

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using FlaxEngine;
using FlaxEngine.Json;
namespace Game;
/// <summary>
/// MultiSceneScript Script.
/// </summary>
public class MultiSceneScript : Script
{
private PhysicsScene phystest;
private PhysicsScene phystest2;
public override void OnStart()
{
phystest = Physics.FindOrCreateScene("phystest");
phystest2 = Physics.FindOrCreateScene("phystest2");
Level.SceneLoaded += OnSceneLoaded;
Level.LoadScene(new SceneReference(JsonSerializer.ParseID("a916228c48fe3a0e89ff0985d4ad2fca")));
Level.SceneLoaded -= OnSceneLoaded;
Level.SceneLoaded += OnSceneLoaded2;
Level.LoadScene(new SceneReference(JsonSerializer.ParseID("f749e5d141e1384c05e49abe92a4fb90")));
Level.SceneLoaded -= OnSceneLoaded2;
}
private void OnSceneLoaded(Scene scene, Guid id)
{
scene.PhysicsScene = phystest;
}
private void OnSceneLoaded2(Scene scene, Guid id)
{
scene.PhysicsScene = phystest2;
}
}

View File

@@ -6,154 +6,148 @@ using FlaxEditor.CustomEditors.Dedicated;
using FlaxEditor.Scripting; using FlaxEditor.Scripting;
#endif #endif
namespace Game namespace Game;
{
#if FLAX_EDITOR #if FLAX_EDITOR
[CustomEditor(typeof(PlayerActor))] [CustomEditor(typeof(PlayerActor))]
public class PlayerActorEditor : ActorEditor public class PlayerActorEditor : ActorEditor
{
protected override List<ItemInfo> GetItemsForType(ScriptType type)
{ {
protected override List<ItemInfo> GetItemsForType(ScriptType type) var items = GetItemsForType(type, type.IsClass, true);
// Remove all Rigid Body options
items.RemoveAll(x => x.Display?.Group == "Rigid Body");
// Inject scripts editor
ScriptMemberInfo scriptsMember = type.GetProperty("Scripts");
if (scriptsMember != ScriptMemberInfo.Null)
{ {
var items = GetItemsForType(type, type.IsClass, true); ItemInfo item = new ItemInfo(scriptsMember)
// Remove all Rigid Body options
items.RemoveAll(x => x.Display?.Group == "Rigid Body");
// Inject scripts editor
ScriptMemberInfo scriptsMember = type.GetProperty("Scripts");
if (scriptsMember != ScriptMemberInfo.Null)
{ {
ItemInfo item = new ItemInfo(scriptsMember) CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor))
{ };
CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor)) items.Add(item);
};
items.Add(item);
}
return items;
} }
return items;
} }
}
#endif #endif
public class SomeActor : EmptyActor public class PlayerActor : RigidBody//, INetworkSerializable
{
private PlayerMovement playerMovement;
public CapsuleCollider capsuleCollider;
public BoxCollider boxCollider;
public MeshCollider meshCollider;
//[NetworkReplicated]
public uint PlayerId = uint.MaxValue;
/*public PlayerActor()
{ {
// Default internal values for RigidBody
IsKinematic = true;
EnableGravity = false;
LinearDamping = 0f;
AngularDamping = 0f;
Constraints = RigidbodyConstraints.LockRotation;
}*/
} public override void OnBeginPlay()
public class PlayerActor : RigidBody//, INetworkSerializable
{ {
private PlayerMovement playerMovement; // Default internal values for RigidBody
public CapsuleCollider capsuleCollider; IsKinematic = true;
public BoxCollider boxCollider; EnableGravity = false;
public MeshCollider meshCollider; LinearDamping = 0f;
AngularDamping = 0f;
Constraints = RigidbodyConstraints.LockRotation;
//[NetworkReplicated] base.OnBeginPlay();
public uint PlayerId = uint.MaxValue;
/*public PlayerActor() playerMovement = FindScript<PlayerMovement>();
{ capsuleCollider = GetChild<CapsuleCollider>();
// Default internal values for RigidBody boxCollider = GetChild<BoxCollider>();
IsKinematic = true; meshCollider = GetChild<MeshCollider>();
EnableGravity = false; //playerRigidBody = FindActor<RigidBody>();
LinearDamping = 0f;
AngularDamping = 0f;
Constraints = RigidbodyConstraints.LockRotation;
}*/
public override void OnBeginPlay()
{
// Default internal values for RigidBody
IsKinematic = true;
EnableGravity = false;
LinearDamping = 0f;
AngularDamping = 0f;
Constraints = RigidbodyConstraints.LockRotation;
base.OnBeginPlay();
playerMovement = FindScript<PlayerMovement>();
capsuleCollider = GetChild<CapsuleCollider>();
boxCollider = GetChild<BoxCollider>();
meshCollider = GetChild<MeshCollider>();
//playerRigidBody = FindActor<RigidBody>();
//Console.Print("OnBeginPlay playerid: " + PlayerId.ToString()); //Console.Print("OnBeginPlay playerid: " + PlayerId.ToString());
//playerMovement.input = new PlayerInputNetwork(); //playerMovement.input = new PlayerInputNetwork();
} }
public override void OnEnable() public override void OnEnable()
{
// Trigger OnEnable manually, does not seem to propagate when parent gets enabled/disabled
playerMovement.Enabled = true;
//NetworkReplicator.AddObject(this);
}
public override void OnDisable()
{
playerMovement.Enabled = false;
//NetworkReplicator.RemoveObject(this);
}
//[NetworkRpc(client: true)]
public void Initialize(uint playerId, Float3 newPosition, Float3 eulerAngles)
{
if (PlayerId == playerId) // FIXME
return;
FindActor("PlayerModel").IsActive = true;
IsActive = true;
PlayerId = playerId;
playerMovement.SetInput(playerId);
if (playerId == NetworkManager.LocalPlayerClientId)
{ {
// Trigger OnEnable manually, does not seem to propagate when parent gets enabled/disabled FindActor("CameraHolder").IsActive = true;
playerMovement.Enabled = true; //FindActor("ViewModelHolder").IsActive = true;
//NetworkReplicator.AddObject(this); FindActor("PlayerModel").IsActive = false;
} }
SetPosition(newPosition);
SetRotation(eulerAngles);
//else
// FindActor("PlayerModel").IsActive = true;
//IsActive = true;
}
public override void OnDisable() //[NetworkRpc(server: true)]
{ public void UpdateNetworkInput(PlayerInputState inputState/*, Float4 viewDeltaXYMoveForwardRight, bool attacking, bool jumping*/)
playerMovement.Enabled = false; {
//NetworkReplicator.RemoveObject(this); if (playerMovement.input is not PlayerInputNetwork playerInputNetwork)
} return;
//[NetworkRpc(client: true)] //PlayerInputState inputState = new PlayerInputState(frame, viewDeltaXYMoveForwardRight.X, viewDeltaXYMoveForwardRight.Y, viewDeltaXYMoveForwardRight.Z, viewDeltaXYMoveForwardRight.W, attacking, jumping);
public void Initialize(uint playerId, Float3 newPosition, Float3 eulerAngles) //playerInputNetwork.currentState.input = inputState;
{ playerInputNetwork.SetState(inputState.frame, inputState);
if (PlayerId == playerId) // FIXME }
return;
FindActor("PlayerModel").IsActive = true; public void SetPosition(Float3 newPosition)
IsActive = true; {
Position = newPosition;
playerMovement.movementState.position = newPosition;
}
PlayerId = playerId; public void SetRotation(Float3 eulerAngles)
playerMovement.SetInput(playerId); {
if (playerId == NetworkManager.LocalPlayerClientId) playerMovement.ResetRotation(eulerAngles);
{ }
FindActor("CameraHolder").IsActive = true;
//FindActor("ViewModelHolder").IsActive = true;
FindActor("PlayerModel").IsActive = false;
}
SetPosition(newPosition);
SetRotation(eulerAngles);
//else
// FindActor("PlayerModel").IsActive = true;
//IsActive = true;
}
//[NetworkRpc(server: true)] public Float3 GetRotation()
public void UpdateNetworkInput(PlayerInputState inputState/*, Float4 viewDeltaXYMoveForwardRight, bool attacking, bool jumping*/) {
{ return playerMovement.viewAngles;
if (playerMovement.input is not PlayerInputNetwork playerInputNetwork) }
return;
//PlayerInputState inputState = new PlayerInputState(frame, viewDeltaXYMoveForwardRight.X, viewDeltaXYMoveForwardRight.Y, viewDeltaXYMoveForwardRight.Z, viewDeltaXYMoveForwardRight.W, attacking, jumping); //[NetworkRpc(client: true)]
//playerInputNetwork.currentState.input = inputState; public void Teleport(Float3 newPosition, Float3 eulerAngles)
playerInputNetwork.SetState(inputState.frame, inputState); {
} SetPosition(newPosition);
SetRotation(eulerAngles);
public void SetPosition(Float3 newPosition)
{
Position = newPosition;
playerMovement.movementState.position = newPosition;
}
public void SetRotation(Float3 eulerAngles)
{
playerMovement.ResetRotation(eulerAngles);
}
public Float3 GetRotation()
{
return playerMovement.viewAngles;
}
//[NetworkRpc(client: true)]
public void Teleport(Float3 newPosition, Float3 eulerAngles)
{
SetPosition(newPosition);
SetRotation(eulerAngles);
}
} }
} }

View File

@@ -1302,7 +1302,7 @@ namespace Game
velocity.Y = jumpVel; velocity.Y = jumpVel;
} }
else else
velocity = Float3.Up * jumpVel; velocity = Float3.Up * jumpVel + new Float3(1, 0, 1) * velocity;
movementState.onGround = false; movementState.onGround = false;

View File

@@ -6,13 +6,6 @@
"executablePath": "C:/dev/Flax/FlaxEngine/Binaries/Editor/Win64/Development/FlaxEditor.exe", "executablePath": "C:/dev/Flax/FlaxEngine/Binaries/Editor/Win64/Development/FlaxEditor.exe",
"commandLineArgs": "-project \"C:/dev/GoakeFlax\"", "commandLineArgs": "-project \"C:/dev/GoakeFlax\"",
"nativeDebugging": false "nativeDebugging": false
},
"Game Debug": {
"commandName": "Executable",
"workingDirectory": "C:/dev/GoakeFlax",
"executablePath": "C:/dev/Flax/FlaxEngine/Binaries/Editor/Win64/Debug/FlaxEditor.exe",
"commandLineArgs": "-project \"C:/dev/GoakeFlax\"",
"nativeDebugging": false
} }
} }
} }