diff --git a/engine1.wav b/engine1.wav new file mode 100644 index 0000000..2e1fcd7 Binary files /dev/null and b/engine1.wav differ diff --git a/imgui.ini b/imgui.ini new file mode 100644 index 0000000..31dfccb --- /dev/null +++ b/imgui.ini @@ -0,0 +1,15 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][state] +Pos=37,31 +Size=307,184 +Collapsed=0 + +[Window][Dear ImGui Demo] +Pos=1344,167 +Size=550,680 +Collapsed=0 + diff --git a/karo.cpp b/karo.cpp index 519be82..045babe 100644 --- a/karo.cpp +++ b/karo.cpp @@ -20,6 +20,10 @@ #include //#include +#include +#include +#include + #include "camera.hpp" using namespace physx; @@ -892,7 +896,7 @@ PxVehicleDrive4W* createVehicle4W(const VehicleDesc& vehicle4WDesc, PxPhysics* p //Gears PxVehicleGearsData gears; - gears.mSwitchTime = 0.2f; + gears.mSwitchTime = 0.5f; driveSimData.setGearsData(gears); //Clutch @@ -1339,7 +1343,7 @@ int main() { prev_y = y; }); - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); + //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); auto KeyDown = [window](int key) { return glfwGetKey(window, key) == GLFW_PRESS; @@ -1347,9 +1351,29 @@ int main() { glfwSwapInterval(1); + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + + // Setup Dear ImGui style + ImGui::StyleColorsDark(); + //ImGui::StyleColorsLight(); + + // Setup Platform/Renderer backends + ImGui_ImplGlfw_InitForOpenGL(window, true); + ImGui_ImplOpenGL3_Init("#version 130"); + while (!glfwWindowShouldClose(window)) { glfwPollEvents(); + // Start the Dear ImGui frame + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + int width, height; glfwGetFramebufferSize(window, &width, &height); @@ -1403,11 +1427,31 @@ int main() { auto& dyndata = gVehicle4W->mDriveDynData; + /*gVehicle4W->computeForwardSpeed()*/ + + //printf("e: %9.2f g: %u\n", , dyndata.getCurrentGear()); + + auto speed = gVehicle4W->computeForwardSpeed() * 3.6f; + auto enginespeed = dyndata.getEngineRotationSpeed() / (PxPi * 2.0) * 60.0f; + auto gear = (int)dyndata.getCurrentGear(); + auto dist = glm::length(pos_glm); + + static const char* gearname[] = { + "R", "N", "1", "2", "3", "4", "5" + }; - printf("e: %9.2f g: %u\n", dyndata.getEngineRotationSpeed() / (PxPi * 2.0) * 60.0f, dyndata.getCurrentGear()); + ImGui::Begin("state"); + ImGui::Text("dist: %.1f m", dist); + ImGui::Text("speed: %.1f km/h", speed); + ImGui::Text("rpm: %.1f", enginespeed); + ImGui::ProgressBar(enginespeed / 6000.0f); + ImGui::SliderInt("gear", &gear, 0, 6, gearname[gear]); + ImGui::End(); + + ImGui::ShowDemoWindow(); glm::mat4 mvp = proj * view; @@ -1446,7 +1490,6 @@ int main() { DrawPhysxDebug(); - glBindVertexArray(vao); glBindBuffer(GL_ARRAY_BUFFER, vbo); @@ -1459,6 +1502,10 @@ int main() { s_draw_lines.clear(); s_draw_points.clear(); + ImGui::Render(); + + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + glfwSwapBuffers(window); } diff --git a/vcpkg.json b/vcpkg.json index e04599a..d7af624 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,7 +5,14 @@ "physx", "glew", "glfw3", - "glm" + "glm", + { + "name": "imgui", + "features": [ + "glfw-binding", + "opengl3-binding" + ] + } ], "overrides": [ {