forked from bit/DotRecastNetSim
add select object file
This commit is contained in:
parent
3ebee73112
commit
fb3a30d069
|
@ -507,40 +507,31 @@ public class RecastDemo
|
|||
|
||||
cameraPos[1] += (float)((_moveUp - _moveDown) * keySpeed * dt);
|
||||
|
||||
// long time = Stopwatch.GetTimestamp();
|
||||
// //float dt = (time - prevFrameTime) / TimeSpan.TicksPerMillisecond;
|
||||
// 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++;
|
||||
// }
|
||||
long time = Stopwatch.GetTimestamp();
|
||||
// float dt = (time - prevFrameTime) / TimeSpan.TicksPerMillisecond;
|
||||
prevFrameTime = time;
|
||||
|
||||
// if (settingsUI.isMeshInputTrigerred())
|
||||
// {
|
||||
// aFilterPatterns.put(stack.UTF8("*.obj"));
|
||||
// aFilterPatterns.flip();
|
||||
// string filename = TinyFileDialogs.tinyfd_openFileDialog("Open Mesh File", "", aFilterPatterns,
|
||||
// "Mesh File (*.obj)", false);
|
||||
// if (filename != null) {
|
||||
// try (InputStream stream = new FileInputStream(filename)) {
|
||||
// sample.update(loadInputMesh(stream), null, null);
|
||||
// } catch (IOException e) {
|
||||
// Console.WriteLine(e).printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 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())
|
||||
{
|
||||
var bytes = Loader.ToBytes(settingsUI.GetMeshInputFilePath());
|
||||
sample.update(loadInputMesh(bytes), null, null);
|
||||
}
|
||||
// else if (settingsUI.isNavMeshInputTrigerred())
|
||||
// {
|
||||
// try (MemoryStack stack = stackPush()) {
|
||||
|
|
|
@ -68,6 +68,8 @@ public class RcSettingsView : IRcView
|
|||
|
||||
private int drawModeIdx = DrawMode.DRAWMODE_NAVMESH.Idx;
|
||||
private DrawMode drawMode = DrawMode.DRAWMODE_NAVMESH;
|
||||
|
||||
private string meshInputFilePath;
|
||||
private bool meshInputTrigerred;
|
||||
private bool navMeshInputTrigerred;
|
||||
|
||||
|
@ -90,14 +92,19 @@ public class RcSettingsView : IRcView
|
|||
bool loadSourceGeomPopup = true;
|
||||
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())
|
||||
{
|
||||
Console.WriteLine(picker.SelectedFile);
|
||||
meshInputTrigerred = true;
|
||||
meshInputFilePath = picker.SelectedFile;
|
||||
ImFilePicker.RemoveFilePicker(strLoadSourceGeom);
|
||||
}
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
else
|
||||
{
|
||||
meshInputTrigerred = false;
|
||||
}
|
||||
|
||||
ImGui.Text($"Verts: {voxels[0]} Tris: {voxels[1]}");
|
||||
ImGui.NewLine();
|
||||
|
@ -349,6 +356,11 @@ public class RcSettingsView : IRcView
|
|||
return meshInputTrigerred;
|
||||
}
|
||||
|
||||
public string GetMeshInputFilePath()
|
||||
{
|
||||
return meshInputFilePath;
|
||||
}
|
||||
|
||||
public bool isNavMeshInputTrigerred()
|
||||
{
|
||||
return navMeshInputTrigerred;
|
||||
|
|
Loading…
Reference in New Issue