This commit is contained in:
det-fys 2025-07-29 13:34:29 +02:00
parent dd7d2360cd
commit d4df7fbc40
4 changed files with 74 additions and 5 deletions

BIN
engine1.wav Normal file

Binary file not shown.

15
imgui.ini Normal file
View File

@ -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

View File

@ -20,6 +20,10 @@
#include <vehicle/PxVehicleSDK.h> #include <vehicle/PxVehicleSDK.h>
//#include <physx/PxFiltering.h> //#include <physx/PxFiltering.h>
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include "camera.hpp" #include "camera.hpp"
using namespace physx; using namespace physx;
@ -892,7 +896,7 @@ PxVehicleDrive4W* createVehicle4W(const VehicleDesc& vehicle4WDesc, PxPhysics* p
//Gears //Gears
PxVehicleGearsData gears; PxVehicleGearsData gears;
gears.mSwitchTime = 0.2f; gears.mSwitchTime = 0.5f;
driveSimData.setGearsData(gears); driveSimData.setGearsData(gears);
//Clutch //Clutch
@ -1339,7 +1343,7 @@ int main() {
prev_y = y; prev_y = y;
}); });
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
auto KeyDown = [window](int key) { auto KeyDown = [window](int key) {
return glfwGetKey(window, key) == GLFW_PRESS; return glfwGetKey(window, key) == GLFW_PRESS;
@ -1347,9 +1351,29 @@ int main() {
glfwSwapInterval(1); 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)) { while (!glfwWindowShouldClose(window)) {
glfwPollEvents(); glfwPollEvents();
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
int width, height; int width, height;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
@ -1403,11 +1427,31 @@ int main() {
auto& dyndata = gVehicle4W->mDriveDynData; 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; glm::mat4 mvp = proj * view;
@ -1446,7 +1490,6 @@ int main() {
DrawPhysxDebug(); DrawPhysxDebug();
glBindVertexArray(vao); glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo);
@ -1459,6 +1502,10 @@ int main() {
s_draw_lines.clear(); s_draw_lines.clear();
s_draw_points.clear(); s_draw_points.clear();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }

View File

@ -5,7 +5,14 @@
"physx", "physx",
"glew", "glew",
"glfw3", "glfw3",
"glm" "glm",
{
"name": "imgui",
"features": [
"glfw-binding",
"opengl3-binding"
]
}
], ],
"overrides": [ "overrides": [
{ {