forked from mirror/DotRecast
completed DynamicUpdateTool Save/Load
This commit is contained in:
parent
57eaea29a1
commit
a034d61367
|
@ -21,6 +21,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DotRecast.Core;
|
using DotRecast.Core;
|
||||||
|
@ -638,6 +639,7 @@ public class DynamicUpdateTool : Tool
|
||||||
{
|
{
|
||||||
ImGui.Text($"Hit: {raycastHitPos[0]}, {raycastHitPos[1]}, {raycastHitPos[2]}");
|
ImGui.Text($"Hit: {raycastHitPos[0]}, {raycastHitPos[1]}, {raycastHitPos[2]}");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -661,21 +663,24 @@ public class DynamicUpdateTool : Tool
|
||||||
|
|
||||||
private void load(string filename)
|
private void load(string filename)
|
||||||
{
|
{
|
||||||
// File file = new File(filename);
|
try
|
||||||
// if (file.exists()) {
|
{
|
||||||
// VoxelFileReader reader = new VoxelFileReader();
|
using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||||
// try (FileInputStream fis = new FileInputStream(file)) {
|
using var br = new BinaryReader(fs);
|
||||||
// VoxelFile voxelFile = reader.read(fis);
|
VoxelFileReader reader = new VoxelFileReader();
|
||||||
// dynaMesh = new DynamicNavMesh(voxelFile);
|
VoxelFile voxelFile = reader.read(br);
|
||||||
// dynaMesh.config.keepIntermediateResults = true;
|
dynaMesh = new DynamicNavMesh(voxelFile);
|
||||||
// updateUI();
|
dynaMesh.config.keepIntermediateResults = true;
|
||||||
// buildDynaMesh();
|
updateUI();
|
||||||
// colliders.clear();
|
buildDynaMesh();
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine(e);
|
colliders.Clear();
|
||||||
// dynaMesh = null;
|
}
|
||||||
// }
|
catch (Exception e)
|
||||||
// }
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
dynaMesh = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save()
|
private void save()
|
||||||
|
@ -693,14 +698,11 @@ public class DynamicUpdateTool : Tool
|
||||||
|
|
||||||
private void save(string filename)
|
private void save(string filename)
|
||||||
{
|
{
|
||||||
// File file = new File(filename);
|
using var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write);
|
||||||
// try (FileOutputStream fos = new FileOutputStream(file)) {
|
using var bw = new BinaryWriter(fs);
|
||||||
// VoxelFile voxelFile = VoxelFile.from(dynaMesh);
|
VoxelFile voxelFile = VoxelFile.from(dynaMesh);
|
||||||
// VoxelFileWriter writer = new VoxelFileWriter();
|
VoxelFileWriter writer = new VoxelFileWriter();
|
||||||
// writer.write(fos, voxelFile, compression);
|
writer.write(bw, voxelFile, compression);
|
||||||
// } catch (Exception e) {
|
|
||||||
// Console.WriteLine(e);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildDynaMesh()
|
private void buildDynaMesh()
|
||||||
|
|
Loading…
Reference in New Issue