working, fixing texture mapping
This commit is contained in:
@@ -3,29 +3,39 @@
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"_tb_textures" "textures/common;textures/dev"
|
||||
// brush 0
|
||||
{
|
||||
( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 576 -32 ) ( 0 577 -32 ) ( 0 576 -31 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 0 -32 ) ( 224 0 -31 ) ( 225 0 -32 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 224 576 -512 ) ( 225 576 -512 ) ( 224 577 -512 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 608 0 ) ( 256 609 0 ) ( 257 608 0 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 256 512 -16 ) ( 257 512 -16 ) ( 256 512 -15 ) common/slick 0 0 0 4 4 0 0 0
|
||||
( 512 608 -16 ) ( 512 608 -15 ) ( 512 609 -16 ) common/slick 0 0 0 4 4 0 0 0
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( -32 -32 48 ) ( -32 32 48 ) ( 0 0 80 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 80 ) ( 32 -32 48 ) ( -32 -32 48 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 32 32 48 ) ( -32 32 48 ) ( -32 -32 48 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 80 ) ( -32 32 48 ) ( 32 32 48 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 80 ) ( 32 32 48 ) ( 32 -32 48 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -64 -64 16 ) ( -64 -63 16 ) ( -64 -64 17 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -64 -64 16 ) ( -64 -64 17 ) ( -63 -64 16 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -64 -64 16 ) ( -63 -64 16 ) ( -64 -63 16 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 64 64 48 ) ( 64 65 48 ) ( 65 64 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 64 64 48 ) ( 65 64 48 ) ( 64 64 49 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 64 64 48 ) ( 64 64 49 ) ( 64 65 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 0 0 80 ) ( -32 32 112 ) ( -32 -32 112 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 80 ) ( -32 -32 112 ) ( 32 -32 112 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -32 32 112 ) ( 32 32 112 ) ( 32 -32 112 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 80 ) ( 32 32 112 ) ( -32 32 112 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 32 -32 112 ) ( 32 32 112 ) ( 0 0 80 ) __TB_empty 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -32 -32 48 ) ( -32 32 48 ) ( 0 0 80 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 -32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 32 48 ) ( -32 32 48 ) ( -32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( -32 32 48 ) ( 32 32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 32 48 ) ( 32 -32 48 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 0 0 80 ) ( -32 32 112 ) ( -32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( -32 -32 112 ) ( 32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( -32 32 112 ) ( 32 32 112 ) ( 32 -32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 0 0 80 ) ( 32 32 112 ) ( -32 32 112 ) common/slick 0 0 0 1 1 0 0 0
|
||||
( 32 -32 112 ) ( 32 32 112 ) ( 0 0 80 ) common/slick 0 0 0 1 1 0 0 0
|
||||
}
|
||||
}
|
||||
|
||||
33
Assets/Maps/problematic.map
Normal file
33
Assets/Maps/problematic.map
Normal file
@@ -0,0 +1,33 @@
|
||||
// Game: Goake
|
||||
// Format: Quake3
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
// brush 0
|
||||
{
|
||||
( 467.19999999999999 0 241.59999999999999 ) ( 442.21699999999998 249.83000000000001 291.56599999999997 ) ( 355.47199999999998 -55.863999999999997 465.05500000000001 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 160 8 ) ( 0 160 -248 ) ( -256 160 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 342 160 492 ) ( 426 160 492 ) ( 426 224 492 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 504 ) ( 256 0 504 ) ( 0 -256 504 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 224 8 ) ( 0 224 264 ) ( -256 224 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 147.19999999999999 0 -65.599999999999994 ) ( 122.217 -249.83000000000001 -115.566 ) ( 258.928 -55.863999999999997 157.85499999999999 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 460 160 458 ) ( 460 160 360 ) ( 460 224 360 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( -88 0 184 ) ( 111.864 124.91500000000001 283.93200000000002 ) ( 23.728000000000002 -223.45500000000001 239.864 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 160 8 ) ( 0 160 -248 ) ( -256 160 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 0 360 ) ( -256 0 360 ) ( 0 -256 360 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 224 8 ) ( 0 224 264 ) ( -256 224 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 472 0 8 ) ( 472 -256 8 ) ( 472 0 264 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 296 160 464 ) ( 296 224 464 ) ( 336 224 504 ) dev/dev_128_gray 0 0 -0 0.0625 0.0625 0 0 0
|
||||
( 241.59999999999999 0 491.19999999999999 ) ( 41.735999999999997 124.91500000000001 591.13199999999995 ) ( 129.87200000000001 -223.45500000000001 547.06399999999996 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 160 8 ) ( 0 160 -248 ) ( -256 160 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 0 224 8 ) ( 0 224 264 ) ( -256 224 8 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 308 160 458 ) ( 342 160 492 ) ( 342 224 492 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
( 467.19999999999999 0 241.59999999999999 ) ( 492.18299999999999 -249.83000000000001 191.63399999999999 ) ( 355.47199999999998 -55.863999999999997 465.05500000000001 ) dev/dev_128_gray 0 0 0 0.0625 0.0625 0 0 0
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"ID": "3c7bc3854d42f9b1b0fea9ba0d7fa8e9",
|
||||
"TypeName": "FlaxEditor.Content.Settings.GameSettings",
|
||||
"EngineBuild": 6221,
|
||||
"EngineBuild": 6222,
|
||||
"Data": {
|
||||
"ProductName": "Goake",
|
||||
"CompanyName": "GoaLitiuM",
|
||||
"FirstScene": "0733cc9b40d3d05366be64bbd9b59e21",
|
||||
"FirstScene": "194e05f445ece24ec5448d886e1334df",
|
||||
"NoSplashScreen": true,
|
||||
"Time": "a55dc3c04da4ea3744b7f1994565beac",
|
||||
"Audio": "492a33824049ba25a8bdcdb148179e67",
|
||||
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ID": "0733cc9b40d3d05366be64bbd9b59e21",
|
||||
"TypeName": "FlaxEngine.SceneAsset",
|
||||
"EngineBuild": 6219,
|
||||
"EngineBuild": 6223,
|
||||
"Data": [
|
||||
{
|
||||
"ID": "0733cc9b40d3d05366be64bbd9b59e21",
|
||||
@@ -168,13 +168,13 @@
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 0.0,
|
||||
"Y": 734.0,
|
||||
"Y": 735.0,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
"Control": "FlaxEngine.GUI.Label",
|
||||
"Data": {
|
||||
"Text": "uFPS: 504\nrFPS: 493\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 9.256392MB",
|
||||
"Text": "eFPS: 120\nuFPS: -2147483648\nrFPS: -2147483648\npFPS: -2147483648\nCon: 0ms\nDirectX11\nGC memory: 11.2093MB",
|
||||
"TextColor": {
|
||||
"R": 1.0,
|
||||
"G": 1.0,
|
||||
@@ -220,9 +220,9 @@
|
||||
},
|
||||
"Offsets": {
|
||||
"Left": 0.0,
|
||||
"Right": 143.0,
|
||||
"Right": 136.0,
|
||||
"Top": -80.0,
|
||||
"Bottom": 96.0
|
||||
"Bottom": 112.0
|
||||
},
|
||||
"Scale": {
|
||||
"X": 1.0,
|
||||
@@ -260,8 +260,8 @@
|
||||
"Name": "ContainerControl 0",
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 45676.0,
|
||||
"Y": 1.0,
|
||||
"X": 44855.0,
|
||||
"Y": 1.5,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ID": "194e05f445ece24ec5448d886e1334df",
|
||||
"TypeName": "FlaxEngine.SceneAsset",
|
||||
"EngineBuild": 6221,
|
||||
"EngineBuild": 6223,
|
||||
"Data": [
|
||||
{
|
||||
"ID": "194e05f445ece24ec5448d886e1334df",
|
||||
@@ -33,7 +33,7 @@
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": -32.320621490478519,
|
||||
"Y": 7.693744659423828,
|
||||
"Y": 203.23764038085938,
|
||||
"Z": -187.24435424804688
|
||||
}
|
||||
},
|
||||
@@ -51,6 +51,13 @@
|
||||
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
|
||||
"V": {}
|
||||
},
|
||||
{
|
||||
"ID": "d9d420ce476865e395a966913b5b32bd",
|
||||
"TypeName": "Game.PlayerMovement",
|
||||
"ParentID": "19bf0c4f41c16717c90e05a0bdc62e44",
|
||||
"V": {},
|
||||
"Enabled": false
|
||||
},
|
||||
{
|
||||
"ID": "39992ccc4fac12dab97aa4bfb52f0041",
|
||||
"TypeName": "FlaxEngine.EmptyActor",
|
||||
@@ -169,13 +176,13 @@
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 0.0,
|
||||
"Y": 506.0,
|
||||
"Y": 484.0,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
"Control": "FlaxEngine.GUI.Label",
|
||||
"Data": {
|
||||
"Text": "eFPS: 120\nuFPS: 120\nrFPS: 120\npFPS: 30\nCon: NaNms\nDirectX11\nGC memory: 8.026576MB",
|
||||
"Text": "eFPS: 121\nuFPS: -2147483648\nrFPS: -2147483648\npFPS: -2147483648\nCon: 0ms\nDirectX11\nGC memory: 9.544752MB",
|
||||
"TextColor": {
|
||||
"R": 1.0,
|
||||
"G": 1.0,
|
||||
@@ -261,8 +268,8 @@
|
||||
"Name": "ContainerControl 0",
|
||||
"Transform": {
|
||||
"Translation": {
|
||||
"X": 45279.0,
|
||||
"Y": -113.0,
|
||||
"X": 44635.0,
|
||||
"Y": -124.0,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
@@ -1,13 +1,17 @@
|
||||
{
|
||||
"ID": "af2e52554f7faed7b4937181dd22d166",
|
||||
"TypeName": "FlaxEditor.Content.Settings.BuildSettings",
|
||||
"EngineBuild": 6216,
|
||||
"EngineBuild": 6222,
|
||||
"Data": {
|
||||
"MaxAssetsPerPackage": 4096,
|
||||
"MaxPackageSizeMB": 1024,
|
||||
"ContentKey": 0,
|
||||
"ForDistribution": false,
|
||||
"SkipPackaging": false,
|
||||
"AdditionalAssets": [
|
||||
"54a1ff4a42af9f018234f7b39b1366b3",
|
||||
"1ef4565844a4b36cdfda54b51f338c77"
|
||||
],
|
||||
"ShadersNoOptimize": false,
|
||||
"ShadersGenerateDebugData": false,
|
||||
"Presets": [
|
||||
|
||||
BIN
Content/Textures/dev/slick.flax
Normal file
BIN
Content/Textures/dev/slick.flax
Normal file
Binary file not shown.
@@ -264,33 +264,53 @@ namespace Cabrito
|
||||
// Echoes text to Console
|
||||
public void Print(string text)
|
||||
{
|
||||
ConsoleLine line = new ConsoleLine(text);
|
||||
consoleLines.Add(line);
|
||||
OnPrint?.Invoke(text);
|
||||
foreach (var line in text.Split(new []{'\n'}))
|
||||
{
|
||||
ConsoleLine lineEntry = new ConsoleLine(line);
|
||||
consoleLines.Add(lineEntry);
|
||||
OnPrint?.Invoke(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Echoes warning text to Console
|
||||
public void PrintWarning(string text)
|
||||
{
|
||||
ConsoleLine line = new ConsoleLine(text);
|
||||
consoleLines.Add(line);
|
||||
OnPrint?.Invoke(text);
|
||||
foreach (var line in text.Split(new[] { '\n' }))
|
||||
{
|
||||
ConsoleLine lineEntry = new ConsoleLine(line);
|
||||
consoleLines.Add(lineEntry);
|
||||
OnPrint?.Invoke(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Echoes error text to Console
|
||||
public void PrintError(string text)
|
||||
{
|
||||
ConsoleLine line = new ConsoleLine(text);
|
||||
consoleLines.Add(line);
|
||||
OnPrint?.Invoke(text);
|
||||
foreach (var line in text.Split(new[] { '\n' }))
|
||||
{
|
||||
ConsoleLine lineEntry = new ConsoleLine(line);
|
||||
consoleLines.Add(lineEntry);
|
||||
OnPrint?.Invoke(text);
|
||||
}
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
text = text;
|
||||
}
|
||||
else
|
||||
throw new Exception(text);
|
||||
}
|
||||
|
||||
// Echoes developer/debug text to Console
|
||||
public void PrintDebug(string text)
|
||||
{
|
||||
ConsoleLine line = new ConsoleLine(text);
|
||||
consoleLines.Add(line);
|
||||
OnPrint?.Invoke(text);
|
||||
foreach (var line in text.Split(new[] { '\n' }))
|
||||
{
|
||||
ConsoleLine lineEntry = new ConsoleLine(line);
|
||||
consoleLines.Add(lineEntry);
|
||||
OnPrint?.Invoke(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Opens the Console
|
||||
|
||||
@@ -9,13 +9,12 @@ namespace Game
|
||||
[Limit(0, 9000), Tooltip("Camera speed")]
|
||||
public float MoveSpeed { get; set; } = 400;
|
||||
|
||||
private float _pitch;
|
||||
private float _yaw;
|
||||
private float viewPitch;
|
||||
private float viewYaw;
|
||||
private float viewRoll;
|
||||
|
||||
private float xAxis;
|
||||
private float yAxis;
|
||||
private float inputH;
|
||||
private float inputV;
|
||||
|
||||
private InputEvent onExit = new InputEvent("Exit");
|
||||
|
||||
@@ -40,33 +39,45 @@ namespace Game
|
||||
public override void OnStart()
|
||||
{
|
||||
var initialEulerAngles = Actor.Orientation.EulerAngles;
|
||||
_pitch = initialEulerAngles.X;
|
||||
_yaw = initialEulerAngles.Y;
|
||||
viewPitch = initialEulerAngles.X;
|
||||
viewYaw = initialEulerAngles.Y;
|
||||
viewRoll = initialEulerAngles.Z;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
var camTrans = Actor.Transform;
|
||||
var rootActor = Actor.GetChild(0);
|
||||
var camera = rootActor.GetChild<Camera>();
|
||||
|
||||
xAxis = InputManager.GetAxis("Mouse X");
|
||||
yAxis = InputManager.GetAxis("Mouse Y");
|
||||
|
||||
float xAxis = InputManager.GetAxisRaw("Mouse X");
|
||||
float yAxis = InputManager.GetAxisRaw("Mouse Y");
|
||||
if (xAxis != 0.0f || yAxis != 0.0f)
|
||||
{
|
||||
_pitch += yAxis;
|
||||
_yaw += xAxis;
|
||||
|
||||
camTrans.Orientation = Quaternion.Euler(_pitch, _yaw, 0);
|
||||
|
||||
|
||||
viewPitch += yAxis;
|
||||
viewYaw += xAxis;
|
||||
|
||||
viewPitch = Mathf.Clamp(viewPitch, -90.0f, 90.0f);
|
||||
|
||||
|
||||
// root orientation must be set first
|
||||
rootActor.Orientation = Quaternion.Euler(0, viewYaw, 0);
|
||||
camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll);
|
||||
}
|
||||
|
||||
inputH = InputManager.GetAxis("Horizontal");
|
||||
inputV = InputManager.GetAxis("Vertical");
|
||||
|
||||
|
||||
float inputH = InputManager.GetAxis("Horizontal");
|
||||
float inputV = InputManager.GetAxis("Vertical");
|
||||
var move = new Vector3(inputH, 0.0f, inputV);
|
||||
|
||||
if (!move.IsZero)
|
||||
{
|
||||
move.Normalize();
|
||||
move = camTrans.TransformDirection(move) * MoveSpeed;
|
||||
move = camera.Transform.TransformDirection(move) * MoveSpeed;
|
||||
|
||||
{
|
||||
Vector3 delta = move * Time.UnscaledDeltaTime;
|
||||
|
||||
@@ -275,6 +275,13 @@ namespace Game
|
||||
}
|
||||
|
||||
Vector3 vector = ParseVector3(data, ref index);
|
||||
// rounding
|
||||
/*float temp = vector.Z;
|
||||
vector.Z = vector.Y;
|
||||
vector.Y = temp;*/
|
||||
/*vector.X = (float)Math.Round(vector.X, 1);
|
||||
vector.Y = (float)Math.Round(vector.Y, 1);
|
||||
vector.Z = (float)Math.Round(vector.Z, 1);*/
|
||||
|
||||
while (index < data.Length)
|
||||
{
|
||||
|
||||
@@ -167,26 +167,101 @@ namespace Game
|
||||
|
||||
public List<Vector3> Simplify(Vector3[] input)
|
||||
{
|
||||
triangles = new List<Triangle>(input.Length/3);
|
||||
vertices = new List<Vertex>(input.Length);
|
||||
triangles = new List<Triangle>(input.Length / 3);
|
||||
vertices = new List<Vertex>();
|
||||
|
||||
// TODO: no overlapping vertices, vertices must be unique
|
||||
|
||||
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var vec in input)
|
||||
|
||||
Dictionary<Vector3, int> verticeMap = new Dictionary<Vector3, int>();
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
if (!verticeMap.ContainsKey(input[i]))
|
||||
verticeMap[input[i]] = verticeMap.Count;
|
||||
}
|
||||
|
||||
for (int i = 0; i < input.Length; i += 3)
|
||||
{
|
||||
int i1 = i + 0;
|
||||
int i2 = i + 1;
|
||||
int i3 = i + 2;
|
||||
Vector3 v1 = input[i1];
|
||||
Vector3 v2 = input[i2];
|
||||
Vector3 v3 = input[i3];
|
||||
|
||||
if (verticeMap.ContainsKey(v1))
|
||||
i1 = verticeMap[v1];
|
||||
else
|
||||
verticeMap.Add(v1, i1);
|
||||
|
||||
if (verticeMap.ContainsKey(v2))
|
||||
i2 = verticeMap[v2];
|
||||
else
|
||||
verticeMap.Add(v2, i2);
|
||||
|
||||
if (verticeMap.ContainsKey(v3))
|
||||
i3 = verticeMap[v3];
|
||||
else
|
||||
verticeMap.Add(v3, i3);
|
||||
|
||||
triangles.Add(new Triangle()
|
||||
{
|
||||
v = new Int3(i1, i2, i3),
|
||||
});
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<Vector3,int> kvp in verticeMap)
|
||||
{
|
||||
vertices.Add(new Vertex()
|
||||
{
|
||||
p = kvp.Key,
|
||||
q = new SymetricMatrix(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*foreach (var vec in input)
|
||||
{
|
||||
vertices.Add(new Vertex()
|
||||
{
|
||||
p = vec,
|
||||
q = new SymetricMatrix(),
|
||||
});
|
||||
}*/
|
||||
}
|
||||
return Simplify();
|
||||
}
|
||||
|
||||
public List<Vector3> Simplify(Vector3[] verts, int[] indices)
|
||||
{
|
||||
triangles = new List<Triangle>(indices.Length / 3);
|
||||
vertices = new List<Vertex>(verts.Length);
|
||||
|
||||
{
|
||||
foreach (var vec in verts)
|
||||
{
|
||||
vertices.Add(new Vertex()
|
||||
{
|
||||
p = vec,
|
||||
q = new SymetricMatrix(),
|
||||
});
|
||||
i += 3;
|
||||
}
|
||||
for (i = 0; i<input.Length; i+=3)
|
||||
|
||||
for (int i = 0; i < indices.Length; i += 3)
|
||||
{
|
||||
triangles.Add(new Triangle()
|
||||
{
|
||||
v = new Int3(i, i+1, i+2),
|
||||
v = new Int3(indices[i]-1, indices[i+1]-1, indices[i+2]-1),
|
||||
});
|
||||
}
|
||||
}
|
||||
return Simplify();
|
||||
}
|
||||
|
||||
private List<Vector3> Simplify()
|
||||
{
|
||||
|
||||
// main iteration loop
|
||||
int deleted_triangles=0;
|
||||
@@ -198,12 +273,14 @@ namespace Game
|
||||
|
||||
//int iteration = 0;
|
||||
//loop(iteration,0,100)
|
||||
for (int iteration = 0; iteration < 9999; iteration ++)
|
||||
int iteration;
|
||||
for (iteration = 0; iteration < 9999; iteration++)
|
||||
{
|
||||
if (ratio < 1.0f && triangle_start_count-deleted_triangles<=target_count) break;
|
||||
if (ratio < 1.0f && triangle_start_count-deleted_triangles<=target_count)
|
||||
break;
|
||||
|
||||
// update mesh constantly
|
||||
update_mesh(iteration);
|
||||
if (ratio >= 1.0f || iteration % 5 == 0)
|
||||
update_mesh(iteration);
|
||||
// clear dirty flag
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
triangles[i].dirty=false;
|
||||
@@ -214,7 +291,7 @@ namespace Game
|
||||
// If it does not, try to adjust the 3 parameters
|
||||
//
|
||||
//double threshold = 0.001; //1.0E-3 EPS;
|
||||
double threshold = 1.0E-3;
|
||||
double threshold = 1.0E-3;//1.0E-9;
|
||||
if (ratio < 1.0f)
|
||||
threshold = 0.000000001 * Math.Pow((double)(iteration+3),agressiveness);
|
||||
//if (verbose) {
|
||||
@@ -225,15 +302,26 @@ namespace Game
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
Triangle t = triangles[i];
|
||||
if(t.err[3]>threshold) continue;
|
||||
if(t.deleted) continue;
|
||||
if(t.dirty) continue;
|
||||
if (t.err[3] > threshold)
|
||||
{
|
||||
t = t;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(t.deleted)
|
||||
continue;
|
||||
if(t.dirty)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
if(t.err[j]<threshold)
|
||||
{
|
||||
int i0=t.v[ j ]; Vertex v0 = vertices[i0];
|
||||
int i1=t.v[(j+1)%3]; Vertex v1 = vertices[i1];
|
||||
if (t.err[j] > threshold)
|
||||
continue;
|
||||
|
||||
int i0=t.v[ j ];
|
||||
Vertex v0 = vertices[i0];
|
||||
int i1=t.v[(j+1)%3];
|
||||
Vertex v1 = vertices[i1];
|
||||
|
||||
// Border check
|
||||
if(v0.border != v1.border)
|
||||
@@ -284,11 +372,16 @@ namespace Game
|
||||
v0.tcount=tcount;
|
||||
break;
|
||||
}
|
||||
if (ratio < 1.0f && triangle_start_count-deleted_triangles<=target_count) break;
|
||||
if (ratio < 1.0f && triangle_start_count-deleted_triangles<=target_count)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ratio >= 1.0f)
|
||||
{
|
||||
if (deleted_triangles <= 0)
|
||||
break;
|
||||
deleted_triangles = 0;
|
||||
}
|
||||
if(deleted_triangles<=0)
|
||||
break;
|
||||
deleted_triangles=0;
|
||||
} //for each iteration
|
||||
// clean up mesh
|
||||
compact_mesh();
|
||||
@@ -296,8 +389,15 @@ namespace Game
|
||||
if (triangles.Count == 0)
|
||||
return null;
|
||||
|
||||
List<Vector3> finalVerts = new List<Vector3>();
|
||||
foreach (var t in triangles)
|
||||
{
|
||||
finalVerts.Add(vertices[t.v[0]].p);
|
||||
finalVerts.Add(vertices[t.v[1]].p);
|
||||
finalVerts.Add(vertices[t.v[2]].p);
|
||||
}
|
||||
|
||||
return null;
|
||||
return finalVerts;
|
||||
}
|
||||
|
||||
// Check if a triangle flips when this edge is removed
|
||||
@@ -374,25 +474,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
/*private Matrix MatrixPlane(float a, float b, float c, float d)
|
||||
{
|
||||
Matrix m = new Matrix();
|
||||
m[0] = a*a; m[1] = a*b; m[2] = a*c; m[3] = a*d;
|
||||
m[4] = b*b; m[5] = b*c; m[6] = b*d;
|
||||
m[7 ] = c*c; m[8 ] = c*d;
|
||||
m[9 ] = d*d;
|
||||
return m;
|
||||
}
|
||||
|
||||
private double MatrixDet(Matrix m, int a11, int a12, int a13,
|
||||
int a21, int a22, int a23,
|
||||
int a31, int a32, int a33)
|
||||
{
|
||||
double det = m[a11]*m[a22]*m[a33] + m[a13]*m[a21]*m[a32] + m[a12]*m[a23]*m[a31]
|
||||
- m[a13]*m[a22]*m[a31] - m[a11]*m[a23]*m[a32]- m[a12]*m[a21]*m[a33];
|
||||
return det;
|
||||
}*/
|
||||
|
||||
// compact triangles, compute edge error and build reference list
|
||||
|
||||
private void update_mesh(int iteration)
|
||||
@@ -416,23 +497,22 @@ namespace Game
|
||||
//
|
||||
if( iteration == 0 )
|
||||
{
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
vertices[i].q=new SymetricMatrix();//vertices[i].q=Matrix(0.0);
|
||||
//for (int i = 0; i < vertices.Count; i++)
|
||||
// vertices[i].q=new SymetricMatrix();//vertices[i].q=Matrix(0.0);
|
||||
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
if (i == 18)
|
||||
Console.Print(i.ToString());
|
||||
Triangle t=triangles[i];
|
||||
Vector3 n = new Vector3();
|
||||
|
||||
Vector3[] p = new Vector3[3];
|
||||
for (int j = 0; j<3; j++)
|
||||
p[j]=vertices[t.v[j]].p;
|
||||
n = Vector3.Cross(p[1]-p[0],p[2]-p[0]);
|
||||
|
||||
Vector3 n = Vector3.Cross(p[1]-p[0],p[2]-p[0]);
|
||||
n.Normalize();
|
||||
t.n=n;
|
||||
for (int j = 0; j<3; j++)
|
||||
vertices[t.v[j]].q = vertices[t.v[j]].q + new SymetricMatrix(n.X,n.Y,n.Z,-Vector3.Dot(n, p[0]));
|
||||
vertices[t.v[j]].q = vertices[t.v[j]].q + new SymetricMatrix(n.X,n.Y,n.Z,Vector3.Dot(-n, p[0]));
|
||||
}
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
@@ -453,7 +533,8 @@ namespace Game
|
||||
for (int i = 0; i < triangles.Count; i++)
|
||||
{
|
||||
Triangle t=triangles[i];
|
||||
for (int j = 0; j<3; j++) vertices[t.v[j]].tcount++;
|
||||
for (int j = 0; j<3; j++)
|
||||
vertices[t.v[j]].tcount++;
|
||||
}
|
||||
int tstart=0;
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user