add select object file

This commit is contained in:
ikpil 2023-03-25 12:17:09 +09:00
parent 3ebee73112
commit fb3a30d069
2 changed files with 38 additions and 35 deletions

View File

@ -507,40 +507,31 @@ public class RecastDemo
cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt); cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt);
// long time = Stopwatch.GetTimestamp(); long time = Stopwatch.GetTimestamp();
// //float dt = (time - prevFrameTime) / TimeSpan.TicksPerMillisecond; // float dt = (time - prevFrameTime) / TimeSpan.TicksPerMillisecond;
// prevFrameTime = time; prevFrameTime = time;
//
// // Update sample simulation.
// float SIM_RATE = 20;
// float DELTA_TIME = 1.0f / SIM_RATE;
// timeAcc = clamp((float)(timeAcc + dt), -1.0f, 1.0f);
// int simIter = 0;
// while (timeAcc > DELTA_TIME)
// {
// timeAcc -= DELTA_TIME;
// if (simIter < 5 && sample != null)
// {
// toolsUI.handleUpdate((float)dt);
// }
//
// simIter++;
// }
// if (settingsUI.isMeshInputTrigerred()) // Update sample simulation.
// { float SIM_RATE = 20;
// aFilterPatterns.put(stack.UTF8("*.obj")); float DELTA_TIME = 1.0f / SIM_RATE;
// aFilterPatterns.flip(); timeAcc = clamp((float)(timeAcc + dt), -1.0f, 1.0f);
// string filename = TinyFileDialogs.tinyfd_openFileDialog("Open Mesh File", "", aFilterPatterns, int simIter = 0;
// "Mesh File (*.obj)", false); while (timeAcc > DELTA_TIME)
// if (filename != null) { {
// try (InputStream stream = new FileInputStream(filename)) { timeAcc -= DELTA_TIME;
// sample.update(loadInputMesh(stream), null, null); if (simIter < 5 && sample != null)
// } catch (IOException e) { {
// Console.WriteLine(e).printStackTrace(); toolsUI.handleUpdate((float)dt);
// } }
// }
// } simIter++;
}
if (settingsUI.isMeshInputTrigerred())
{
var bytes = Loader.ToBytes(settingsUI.GetMeshInputFilePath());
sample.update(loadInputMesh(bytes), null, null);
}
// else if (settingsUI.isNavMeshInputTrigerred()) // else if (settingsUI.isNavMeshInputTrigerred())
// { // {
// try (MemoryStack stack = stackPush()) { // try (MemoryStack stack = stackPush()) {

View File

@ -68,6 +68,8 @@ public class RcSettingsView : IRcView
private int drawModeIdx = DrawMode.DRAWMODE_NAVMESH.Idx; private int drawModeIdx = DrawMode.DRAWMODE_NAVMESH.Idx;
private DrawMode drawMode = DrawMode.DRAWMODE_NAVMESH; private DrawMode drawMode = DrawMode.DRAWMODE_NAVMESH;
private string meshInputFilePath;
private bool meshInputTrigerred; private bool meshInputTrigerred;
private bool navMeshInputTrigerred; private bool navMeshInputTrigerred;
@ -90,14 +92,19 @@ public class RcSettingsView : IRcView
bool loadSourceGeomPopup = true; bool loadSourceGeomPopup = true;
if (ImGui.BeginPopupModal(strLoadSourceGeom, ref loadSourceGeomPopup, ImGuiWindowFlags.NoTitleBar)) if (ImGui.BeginPopupModal(strLoadSourceGeom, ref loadSourceGeomPopup, ImGuiWindowFlags.NoTitleBar))
{ {
var picker = ImFilePicker.GetFilePicker(strLoadSourceGeom, Path.Combine(Environment.CurrentDirectory)); var picker = ImFilePicker.GetFilePicker(strLoadSourceGeom, Path.Combine(Environment.CurrentDirectory), ".obj");
if (picker.Draw()) if (picker.Draw())
{ {
Console.WriteLine(picker.SelectedFile); meshInputTrigerred = true;
meshInputFilePath = picker.SelectedFile;
ImFilePicker.RemoveFilePicker(strLoadSourceGeom); ImFilePicker.RemoveFilePicker(strLoadSourceGeom);
} }
ImGui.EndPopup(); ImGui.EndPopup();
} }
else
{
meshInputTrigerred = false;
}
ImGui.Text($"Verts: {voxels[0]} Tris: {voxels[1]}"); ImGui.Text($"Verts: {voxels[0]} Tris: {voxels[1]}");
ImGui.NewLine(); ImGui.NewLine();
@ -349,6 +356,11 @@ public class RcSettingsView : IRcView
return meshInputTrigerred; return meshInputTrigerred;
} }
public string GetMeshInputFilePath()
{
return meshInputFilePath;
}
public bool isNavMeshInputTrigerred() public bool isNavMeshInputTrigerred()
{ {
return navMeshInputTrigerred; return navMeshInputTrigerred;