update ui, tests
This commit is contained in:
parent
3e75b1f650
commit
959ce6d92a
@ -1313,7 +1313,7 @@ void DebugDraw::DrawString(const b3Color& color, const char* text, ...)
|
||||
va_list args;
|
||||
va_start(args, text);
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f));
|
||||
ImGui::SetNextWindowSize(ImVec2(g_camera->m_width, g_camera->m_height));
|
||||
|
||||
ImGui::Begin(g_overlayName, NULL, ImVec2(0.0f, 0.0f), 0.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
|
||||
|
@ -1321,7 +1321,7 @@ void DebugDraw::DrawString(const b3Color& color, const char* text, ...)
|
||||
va_list args;
|
||||
va_start(args, text);
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
||||
ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f));
|
||||
ImGui::SetNextWindowSize(ImVec2(g_camera->m_width, g_camera->m_height));
|
||||
|
||||
ImGui::Begin(g_overlayName, NULL, ImVec2(0.0f, 0.0f), 0.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
|
||||
|
@ -110,7 +110,7 @@ static void Run()
|
||||
|
||||
g_view->Command_Draw();
|
||||
|
||||
g_debugDraw->DrawString(b3Color_yellow, "%.2f (ms)", 1000.0 * frameTime);
|
||||
g_debugDraw->DrawString(b3Color_yellow, "%.2f [ms]", 1000.0 * frameTime);
|
||||
|
||||
g_model->Command_Step();
|
||||
|
||||
@ -141,11 +141,7 @@ int main(int argc, char** args)
|
||||
}
|
||||
|
||||
// Create window
|
||||
extern b3Version b3_version;
|
||||
char title[256];
|
||||
sprintf(title, "Bounce Testbed Version %d.%d.%d", b3_version.major, b3_version.minor, b3_version.revision);
|
||||
|
||||
g_window = glfwCreateWindow(1024, 768, title, NULL, NULL);
|
||||
g_window = glfwCreateWindow(1024, 768, "Bounce Testbed", NULL, NULL);
|
||||
if (g_window == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to create GLFW window\n");
|
||||
|
@ -39,9 +39,7 @@ Model::Model()
|
||||
glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
|
||||
glClearDepth(1.0f);
|
||||
|
||||
m_camera.m_q = b3QuatRotationX(-0.125f * B3_PI);
|
||||
m_camera.m_center.SetZero();
|
||||
m_camera.m_zoom = 20.0f;
|
||||
Action_DefaultCamera();
|
||||
}
|
||||
|
||||
Model::~Model()
|
||||
@ -64,6 +62,8 @@ void Model::Command_Step()
|
||||
m_settings.lastTestID = m_settings.testID;
|
||||
m_test = g_tests[m_settings.testID].create();
|
||||
m_settings.pause = true;
|
||||
|
||||
Action_DefaultCamera();
|
||||
}
|
||||
|
||||
glViewport(0, 0, GLsizei(m_camera.m_width), GLsizei(m_camera.m_height));
|
||||
|
@ -30,13 +30,15 @@ public:
|
||||
|
||||
~Model();
|
||||
|
||||
void Action_SaveTest();
|
||||
|
||||
void Action_SelectTest(int selection);
|
||||
void Action_RestartTest();
|
||||
void Action_PreviousTest();
|
||||
void Action_NextTest();
|
||||
void Action_DumpTest();
|
||||
void Action_PlayPause();
|
||||
void Action_SingleStep();
|
||||
void Action_DefaultCamera();
|
||||
void Action_LeftCamera();
|
||||
void Action_RightCamera();
|
||||
void Action_BottomCamera();
|
||||
@ -92,9 +94,9 @@ inline void Model::Action_NextTest()
|
||||
m_settings.lastTestID = -1;
|
||||
}
|
||||
|
||||
inline void Model::Action_DumpTest()
|
||||
inline void Model::Action_SaveTest()
|
||||
{
|
||||
m_test->Dump();
|
||||
m_test->Save();
|
||||
}
|
||||
|
||||
inline void Model::Action_PlayPause()
|
||||
@ -108,6 +110,13 @@ inline void Model::Action_SingleStep()
|
||||
m_settings.singleStep = true;
|
||||
}
|
||||
|
||||
inline void Model::Action_DefaultCamera()
|
||||
{
|
||||
m_camera.m_q = b3QuatRotationX(-0.125f * B3_PI);
|
||||
m_camera.m_center.SetZero();
|
||||
m_camera.m_zoom = 20.0f;
|
||||
}
|
||||
|
||||
inline void Model::Action_LeftCamera()
|
||||
{
|
||||
m_camera.m_q.Set(b3Vec3(0.0f, 1.0f, 0.0f), 0.5f * B3_PI);
|
||||
|
@ -116,14 +116,10 @@ public:
|
||||
Test();
|
||||
virtual ~Test();
|
||||
|
||||
virtual void BeginContact(b3Contact* contact) { }
|
||||
virtual void EndContact(b3Contact* contact) { }
|
||||
virtual void PreSolve(b3Contact* contact) { }
|
||||
virtual void Save() { }
|
||||
|
||||
virtual void Step();
|
||||
|
||||
virtual void Dump() { }
|
||||
|
||||
virtual void RayHit();
|
||||
|
||||
virtual void MouseMove(const Ray3& pw);
|
||||
@ -132,6 +128,10 @@ public:
|
||||
virtual void KeyDown(int button) { }
|
||||
virtual void KeyUp(int button) { }
|
||||
|
||||
virtual void BeginContact(b3Contact* contact) { }
|
||||
virtual void EndContact(b3Contact* contact) { }
|
||||
virtual void PreSolve(b3Contact* contact) { }
|
||||
|
||||
b3World m_world;
|
||||
b3RayCastSingleOutput m_rayHit;
|
||||
b3MouseJoint* m_mouseJoint;
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include <testbed/framework/model.h>
|
||||
|
||||
#if defined (U_OPENGL_2)
|
||||
#include <imgui/imgui_impl_glfw_gl2.h>
|
||||
#include <imgui/imgui_impl_glfw_gl2.h>
|
||||
#elif defined (U_OPENGL_4)
|
||||
#include <imgui/imgui_impl_glfw_gl3.h>
|
||||
#include <imgui/imgui_impl_glfw_gl3.h>
|
||||
#else
|
||||
|
||||
#endif
|
||||
@ -119,11 +119,13 @@ View::View(GLFWwindow* window, Model* model)
|
||||
ImGui::CreateContext();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
io.IniFilename = NULL;
|
||||
io.Fonts[0].AddFontDefault();
|
||||
|
||||
ImGui_GLFW_GL_Init(m_window, false);
|
||||
|
||||
ImGui::StyleColorsLight();
|
||||
ImGui::StyleColorsDark();
|
||||
}
|
||||
|
||||
View::~View()
|
||||
@ -143,33 +145,116 @@ void View::Command_Draw()
|
||||
{
|
||||
Camera& camera = m_model->m_camera;
|
||||
Settings& settings = m_model->m_settings;
|
||||
|
||||
|
||||
ImVec2 buttonSize(-1.0f, 0.0f);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
|
||||
bool openAbout = false;
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
if (ImGui::MenuItem("Save"))
|
||||
{
|
||||
m_model->Action_SaveTest();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("Exit", "Alt+F4"))
|
||||
{
|
||||
glfwSetWindowShouldClose(m_window, true);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("View"))
|
||||
{
|
||||
ImGui::MenuItem("Reference Grid", "", &settings.drawGrid);
|
||||
ImGui::MenuItem("Vertices and Edges", "", &settings.drawVerticesEdges);
|
||||
ImGui::MenuItem("Faces", "", &settings.drawFaces);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::MenuItem("Center of Masses", "", &settings.drawCenterOfMasses);
|
||||
ImGui::MenuItem("Bounding Boxes", "", &settings.drawBounds);
|
||||
ImGui::MenuItem("Joints", "", &settings.drawJoints);
|
||||
ImGui::MenuItem("Contact Points", "", &settings.drawContactPoints);
|
||||
ImGui::MenuItem("Contact Normals", "", &settings.drawContactNormals);
|
||||
ImGui::MenuItem("Contact Tangents", "", &settings.drawContactTangents);
|
||||
ImGui::MenuItem("Contact Polygons", "", &settings.drawContactPolygons);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::MenuItem("Statistics", "", &settings.drawStats);
|
||||
ImGui::MenuItem("Profile", "", &settings.drawProfile);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Tools"))
|
||||
{
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Help"))
|
||||
{
|
||||
if (ImGui::MenuItem("About"))
|
||||
{
|
||||
openAbout = true;
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
if (openAbout)
|
||||
{
|
||||
ImGui::OpenPopup("About Bounce Testbed");
|
||||
openAbout = false;
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("About Bounce Testbed", NULL, ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
extern b3Version b3_version;
|
||||
|
||||
ImGui::Text("Bounce Testbed");
|
||||
ImGui::Text("Version %d.%d.%d", b3_version.major, b3_version.minor, b3_version.revision);
|
||||
ImGui::Text("Copyright (c) Irlan Robson");
|
||||
ImGui::Text("https://github.com/irlanrobson/bounce");
|
||||
|
||||
if (ImGui::Button("OK", buttonSize))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(camera.m_width - 250.0f, 0.0f));
|
||||
ImGui::SetNextWindowSize(ImVec2(250.0f, camera.m_height));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
|
||||
ImGui::Begin("Controller", NULL, ImVec2(0.0f, 0.0f), 0.25f, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
|
||||
ImGui::Begin("Test", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
|
||||
|
||||
ImGui::PushItemWidth(-1.0f);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Test");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Combo("##Test", &settings.testID, GetTestName, NULL, g_testCount, g_testCount))
|
||||
{
|
||||
m_model->Action_SelectTest(settings.testID);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Restart", buttonSize))
|
||||
{
|
||||
m_model->Action_RestartTest();
|
||||
}
|
||||
|
||||
|
||||
if (ImGui::Button("Previous", buttonSize))
|
||||
{
|
||||
m_model->Action_PreviousTest();
|
||||
@ -179,23 +264,36 @@ void View::Command_Draw()
|
||||
{
|
||||
m_model->Action_NextTest();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Dump", buttonSize))
|
||||
if (ImGui::Button("Play/Pause", buttonSize))
|
||||
{
|
||||
m_model->Action_DumpTest();
|
||||
m_model->Action_PlayPause();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Exit", buttonSize))
|
||||
if (ImGui::Button("Single Step", buttonSize))
|
||||
{
|
||||
glfwSetWindowShouldClose(m_window, true);
|
||||
m_model->Action_SingleStep();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Step");
|
||||
ImGui::Text("Camera");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Restart##Camera", buttonSize))
|
||||
{
|
||||
m_model->Action_DefaultCamera();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Settings");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Hertz");
|
||||
ImGui::SliderFloat("##Hertz", &settings.hertz, 0.0f, 240.0f, "%.1f");
|
||||
ImGui::Text("Velocity Iterations");
|
||||
@ -206,74 +304,16 @@ void View::Command_Draw()
|
||||
ImGui::Checkbox("Convex Cache", &settings.convexCache);
|
||||
ImGui::Checkbox("Warm Start", &settings.warmStart);
|
||||
|
||||
if (ImGui::Button("Play/Pause", buttonSize))
|
||||
{
|
||||
m_model->Action_PlayPause();
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
if (ImGui::Button("Single Step", buttonSize))
|
||||
{
|
||||
m_model->Action_SingleStep();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("View");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Checkbox("Reference Grid", &settings.drawGrid);
|
||||
ImGui::Checkbox("Vertices and Edges", &settings.drawVerticesEdges);
|
||||
ImGui::Checkbox("Faces", &settings.drawFaces);
|
||||
ImGui::Checkbox("Center of Masses", &settings.drawCenterOfMasses);
|
||||
ImGui::Checkbox("Bounding Boxes", &settings.drawBounds);
|
||||
ImGui::Checkbox("Joints", &settings.drawJoints);
|
||||
ImGui::Checkbox("Contact Points", &settings.drawContactPoints);
|
||||
ImGui::Checkbox("Contact Normals", &settings.drawContactNormals);
|
||||
ImGui::Checkbox("Contact Tangents", &settings.drawContactTangents);
|
||||
ImGui::Checkbox("Contact Polygons", &settings.drawContactPolygons);
|
||||
ImGui::Checkbox("Statistics", &settings.drawStats);
|
||||
ImGui::Checkbox("Profile", &settings.drawProfile);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Left", buttonSize))
|
||||
{
|
||||
m_model->Action_LeftCamera();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Right", buttonSize))
|
||||
{
|
||||
m_model->Action_RightCamera();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Bottom", buttonSize))
|
||||
{
|
||||
m_model->Action_BottomCamera();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Top", buttonSize))
|
||||
{
|
||||
m_model->Action_TopCamera();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Back", buttonSize))
|
||||
{
|
||||
m_model->Action_BackCamera();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Front", buttonSize))
|
||||
{
|
||||
m_model->Action_FrontCamera();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void View::Command_PostDraw()
|
||||
{
|
||||
ImGui::Render();
|
||||
|
||||
|
||||
ImGui_GLFW_GL_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
@ -43,13 +43,7 @@ public:
|
||||
|
||||
b3Body* body = m_world.CreateBody(bd);
|
||||
|
||||
static b3BoxHull boxHull;
|
||||
{
|
||||
b3Transform xf;
|
||||
xf.position.SetZero();
|
||||
xf.rotation = b3Diagonal(2.0f, 4.0f, 0.5f);
|
||||
boxHull.SetTransform(xf);
|
||||
}
|
||||
static b3BoxHull boxHull(2.0f, 4.0f, 0.5f);
|
||||
|
||||
b3HullShape hs;
|
||||
hs.m_hull = &boxHull;
|
||||
@ -64,7 +58,7 @@ public:
|
||||
b3BodyDef bd;
|
||||
bd.type = b3BodyType::e_dynamicBody;
|
||||
bd.position.Set(0.0f, 4.0f, 10.0f);
|
||||
bd.linearVelocity.Set(0.0f, 0.0f, -5.0f);
|
||||
bd.linearVelocity.Set(0.0f, 0.0f, -20.0f);
|
||||
|
||||
m_character = m_world.CreateBody(bd);
|
||||
|
||||
|
2
external/imgui/imgui_demo.cpp
vendored
2
external/imgui/imgui_demo.cpp
vendored
@ -2280,7 +2280,7 @@ static void ShowExampleAppMainMenuBar()
|
||||
{
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
ShowExampleMenuFile();
|
||||
ImGui::EndMenu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user