sandbox_plotmesh3d.py 1006 B

123456789101112131415161718192021222324252627282930313233343536
  1. from imgui_bundle import imgui, immapp, implot3d
  2. # Define cube vertices
  3. cube_vertices = [
  4. implot3d.Point(-1.0, -1.0, -1.0),
  5. implot3d.Point( 1.0, -1.0, -1.0),
  6. implot3d.Point( 1.0, 1.0, -1.0),
  7. implot3d.Point(-1.0, 1.0, -1.0),
  8. implot3d.Point(-1.0, -1.0, 1.0),
  9. implot3d.Point( 1.0, -1.0, 1.0),
  10. implot3d.Point( 1.0, 1.0, 1.0),
  11. implot3d.Point(-1.0, 1.0, 1.0),
  12. ]
  13. # Define cube indices
  14. cube_indices = [
  15. 0, 1, 2, 0, 2, 3, # back face
  16. 4, 5, 6, 4, 6, 7, # front face
  17. 0, 1, 5, 0, 5, 4, # bottom face
  18. 2, 3, 7, 2, 7, 6, # top face
  19. 1, 2, 6, 1, 6, 5, # right face
  20. 3, 0, 4, 3, 4, 7, # left face
  21. ]
  22. mesh = implot3d.Mesh(cube_vertices, cube_indices)
  23. def gui():
  24. imgui.text("Cube Mesh with ImPlot3D")
  25. if implot3d.begin_plot("Cube Plot", (600, 400)):
  26. # Calling plot_mesh
  27. implot3d.plot_mesh("Cube", mesh)
  28. implot3d.end_plot()
  29. if __name__ == "__main__":
  30. immapp.run(gui, with_implot3d=True, window_size=(800, 600))