### Install and Run PyBullet Examples Source: https://github.com/bulletphysics/bullet3/blob/master/README.md Install the PyBullet library and run example environments for reinforcement learning and robotics simulations. ```bash pip3 install pybullet --upgrade --user python3 -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may python3 -m pybullet_envs.examples.enjoy_TF_HumanoidFlagrunHarderBulletEnv_v1_2017jul python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt ``` -------------------------------- ### Install Ruamel.YAML Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/gym/pybullet_envs/minitaur/envs/README.md Install the ruamel.yaml library, another dependency for the environments. ```bash pip install ruamel.yaml ``` -------------------------------- ### Install OpenAI Gym Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/gym/pybullet_envs/minitaur/envs/README.md Install the OpenAI Gym library, a dependency for these environments. ```bash pip install gym ``` -------------------------------- ### Installation Rules Source: https://github.com/bulletphysics/bullet3/blob/master/examples/OpenGLWindow/CMakeLists.txt Defines installation rules for the OpenGLWindow library, specifying runtime, library, and archive destinations. ```cmake INSTALL(TARGETS OpenGLWindow RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) ``` -------------------------------- ### Install LinearMath Library Source: https://github.com/bulletphysics/bullet3/blob/master/src/LinearMath/CMakeLists.txt Configures installation rules for the LinearMath library, including runtime, library, and archive destinations, and installs header files. This block is conditional on INSTALL_LIBS and not INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS LinearMath DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS LinearMath RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(LinearMath PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(LinearMath PROPERTIES PUBLIC_HEADER "${LinearMath_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Compile and Install Bullet3 on Linux Source: https://github.com/bulletphysics/bullet3/wiki/Home After configuring the build with CMake, use 'make' to compile the library and 'make install' to install it. 'ldconfig' updates the shared library cache. ```bash make -j4 ``` ```bash sudo make install ``` ```bash sudo ldconfig ``` -------------------------------- ### Include Directories Setup Source: https://github.com/bulletphysics/bullet3/blob/master/examples/OpenGLWindow/CMakeLists.txt Sets up include directories for the project, including relative paths and third-party libraries. ```cmake INCLUDE_DIRECTORIES( .. ../ThirdPartyLibs ../../src ../ThirdPartyLibs/glad ) ``` -------------------------------- ### Bullet Example Browser Source Files Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ExampleBrowser/CMakeLists.txt Lists the source files for the main Bullet Example Browser executable, including components for robotics, tiny renderer, shared memory plugins, and various simulation examples. ```cmake SET(BulletExampleBrowser_SRCS ../BulletRobotics/FixJointBoxes.cpp ../BulletRobotics/BoxStack.cpp ../BulletRobotics/JointLimit.cpp # ../BulletRobotics/GraspBox.cpp ../TinyRenderer/geometry.cpp ../TinyRenderer/model.cpp ../TinyRenderer/tgaimage.cpp ../TinyRenderer/our_gl.cpp ../TinyRenderer/TinyRenderer.cpp ../SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp ../SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.h ../SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp ../SharedMemory/plugins/pdControlPlugin/pdControlPlugin.h ../SharedMemory/plugins/tinyRendererPlugin/tinyRendererPlugin.cpp ../SharedMemory/plugins/tinyRendererPlugin/TinyRendererVisualShapeConverter.cpp ../SharedMemory/IKTrajectoryHelper.cpp ../SharedMemory/IKTrajectoryHelper.h ../SharedMemory/PhysicsServer.cpp ../SharedMemory/PhysicsClientSharedMemory.cpp ../SharedMemory/PhysicsClientSharedMemory_C_API.cpp ../SharedMemory/PhysicsClient.cpp ../SharedMemory/PhysicsClientC_API.cpp ../SharedMemory/GraphicsServerExample.cpp ../SharedMemory/GraphicsClientExample.cpp ../SharedMemory/RemoteGUIHelper.cpp ../SharedMemory/GraphicsServerExample.h ../SharedMemory/GraphicsClientExample.h ../SharedMemory/RemoteGUIHelper.h ../SharedMemory/GraphicsSharedMemoryCommands.h ../SharedMemory/GraphicsSharedMemoryPublic.h ../SharedMemory/PhysicsServerExample.cpp ../SharedMemory/PhysicsServerExampleBullet2.cpp ../SharedMemory/PhysicsClientExample.cpp ../SharedMemory/PosixSharedMemory.cpp ../SharedMemory/Win32SharedMemory.cpp ../SharedMemory/InProcessMemory.cpp ../SharedMemory/PhysicsServerSharedMemory.cpp ../SharedMemory/PhysicsDirect.cpp ../SharedMemory/PhysicsDirect.h ../SharedMemory/PhysicsDirectC_API.cpp ../SharedMemory/PhysicsDirectC_API.h ../SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp ../SharedMemory/PhysicsLoopBack.cpp ../SharedMemory/PhysicsLoopBack.h ../SharedMemory/PhysicsLoopBackC_API.cpp ../SharedMemory/PhysicsLoopBackC_API.h ../SharedMemory/PhysicsServerCommandProcessor.cpp ../SharedMemory/PhysicsServerCommandProcessor.h ../SharedMemory/SharedMemoryCommands.h ../SharedMemory/SharedMemoryPublic.h ../SharedMemory/b3PluginManager.cpp ../SharedMemory/b3RobotSimulatorClientAPI_NoGUI.cpp ../SharedMemory/b3RobotSimulatorClientAPI_NoGUI.h ../SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp ../SharedMemory/b3RobotSimulatorClientAPI_NoDirect.h ../RobotSimulator/b3RobotSimulatorClientAPI.cpp ../RobotSimulator/b3RobotSimulatorClientAPI.h ../BasicDemo/BasicExample.cpp ../BasicDemo/BasicExample.h ../InverseDynamics/InverseDynamicsExample.cpp ../InverseDynamics/InverseDynamicsExample.h ../InverseKinematics/InverseKinematicsExample.cpp ../InverseKinematics/InverseKinematicsExample.h ../ForkLift/ForkLiftDemo.cpp ../ForkLift/ForkLiftDemo.h ) ``` -------------------------------- ### Install GIMPACTUtils Libraries and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/GIMPACTUtils/CMakeLists.txt Configures installation rules for the GIMPACTUtils library and its headers, with platform-specific handling for macOS frameworks. ```cmake IF (INSTALL_EXTRA_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS GIMPACTUtils DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS GIMPACTUtils RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(GIMPACTUtils PROPERTIES PUBLIC_HEADER "btGImpactConvexDecompositionShape.h") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_EXTRA_LIBS) ``` -------------------------------- ### Basic CMake Setup and Policy Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/Serialize/makesdna/CMakeLists.txt Initializes CMake version and sets a policy for compatibility. This is standard practice for CMake scripts. ```cmake cmake_minimum_required(VERSION 2.4) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) ``` -------------------------------- ### Configure Basic Example GUI with OpenGL Source: https://github.com/bulletphysics/bullet3/blob/master/examples/BasicDemo/CMakeLists.txt Sets up include directories and source files for the AppBasicExampleGui, which uses OpenGL for rendering. It includes necessary GUI helper and utility files. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/btgui ${BULLET_PHYSICS_SOURCE_DIR}/examples ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) SET(AppBasicExampleGui_SRCS BasicExample.cpp ${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc ../StandaloneMain/main_opengl_single_example.cpp ../ExampleBrowser/OpenGLGuiHelper.cpp ../ExampleBrowser/GL_ShapeDrawer.cpp ../ExampleBrowser/CollisionShape2TriangleMesh.cpp ../Utils/b3Clock.cpp ) #this define maps StandaloneExampleCreateFunc to the right 'CreateFunc' ADD_DEFINITIONS(-DB3_USE_STANDALONE_EXAMPLE) ``` -------------------------------- ### Install Pkgconfig File Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Installs the generated bullet.pc file to the specified pkg-config directory. This is conditional on not being on MSVC. ```cmake INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc DESTINATION ${PKGCONFIG_INSTALL_PREFIX}) ENDIF(NOT MSVC) ``` -------------------------------- ### Install BulletCollision Library and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/src/BulletCollision/CMakeLists.txt Configures the installation of the BulletCollision library and its header files. It handles different installation paths based on whether it's a macOS framework build or a standard library build. ```cmake IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #INSTALL of other files requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletCollision DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletCollision RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) INSTALL(FILES ../btBulletCollisionCommon.h DESTINATION ${INCLUDE_INSTALL_DIR}/BulletCollision) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletCollision PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletCollision PROPERTIES PUBLIC_HEADER "${Root_HDRS}") # Have to list out sub-directories manually: SET_PROPERTY(SOURCE ${BroadphaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/BroadphaseCollision) SET_PROPERTY(SOURCE ${CollisionDispatch_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/CollisionDispatch) SET_PROPERTY(SOURCE ${CollisionShapes_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/CollisionShapes) SET_PROPERTY(SOURCE ${Gimpact_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Gimpact) SET_PROPERTY(SOURCE ${NarrowPhaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/NarrowPhaseCollision) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Run Galloping Gait Example Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/gym/pybullet_envs/minitaur/envs/README.md Execute a pre-trained PPO agent to demonstrate the galloping gait in the Minitaur environment. ```python python minitaur_reactive_env_example.py ``` -------------------------------- ### Install Convex Decomposition Library and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/ConvexDecomposition/CMakeLists.txt Configures installation rules for the ConvexDecomposition library and its header files when INSTALL_EXTRA_LIBS is enabled and certain conditions are met. This includes specifying destinations for runtime, library, and archive files, as well as installing header files while excluding version control and build artifacts. ```cmake IF (INSTALL_EXTRA_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS ConvexDecomposition DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS ConvexDecomposition RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(ConvexDecomposition PROPERTIES PUBLIC_HEADER "${ConvexDecomposition_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_EXTRA_LIBS) ``` -------------------------------- ### Install Library and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/src/Bullet3OpenCL/CMakeLists.txt Configures installation rules for the Bullet3OpenCL_clew library and its header files, with platform-specific handling for macOS frameworks. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3OpenCL_clew DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3OpenCL_clew RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(Bullet3OpenCL_clew PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(Bullet3OpenCL_clew PROPERTIES PUBLIC_HEADER "${Root_HDRS}") SET_PROPERTY(SOURCE ${BroadphaseCollision_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/BroadphaseCollision) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### HelloBulletRobotics Source Files and Includes Source: https://github.com/bulletphysics/bullet3/blob/master/examples/RobotSimulator/CMakeLists.txt Defines include directories and source files for the HelloBulletRobotics example. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/examples ${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/enet/include ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/clsocket/src ) SET(App_HelloBulletRobotics_SRCS HelloBulletRobotics.cpp ) ADD_EXECUTABLE(App_HelloBulletRobotics ${App_HelloBulletRobotics_SRCS}) ``` -------------------------------- ### Run Trotting Gait Example Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/gym/pybullet_envs/minitaur/envs/README.md Execute a pre-trained PPO agent to demonstrate the trotting gait in the Minitaur environment. ```python python minitaur_trotting_env_example.py ``` -------------------------------- ### Set Include Installation Directory Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Specifies the subdirectory for installing header files. This is a cache variable. ```cmake SET(INCLUDE_INSTALL_DIR "include/bullet/" CACHE PATH "The subdirectory to the header prefix") ``` -------------------------------- ### Install Bullet3Collision Library and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/src/Bullet3Collision/CMakeLists.txt Configures installation rules for the Bullet3Collision library and its headers, with special handling for macOS frameworks. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Collision DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Collision RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(Bullet3Collision PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(Bullet3Collision PROPERTIES PUBLIC_HEADER "${Bullet3Collision_HDRS}") # Have to list out sub-directories manually: #todo #SET_PROPERTY(SOURCE ${Bullet3CollisionBroadPhase_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/BroadPhaseCollision) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Install PyBullet Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/notebooks/HelloPyBullet.ipynb Installs the PyBullet module using pip. Run this command to set up the necessary library for PyBullet applications. ```python # Install the PyBullet module. !pip install -U pybullet ``` -------------------------------- ### Include Directories for SimpleOpenGL3 Source: https://github.com/bulletphysics/bullet3/blob/master/examples/SimpleOpenGL3/CMakeLists.txt Specifies the directories to include for the SimpleOpenGL3 example, pointing to Bullet Physics source and example subdirectories. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/btgui ${BULLET_PHYSICS_SOURCE_DIR}/examples ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/Glew ) ``` -------------------------------- ### Install Bullet3Geometry Library Source: https://github.com/bulletphysics/bullet3/blob/master/src/Bullet3Geometry/CMakeLists.txt This snippet configures the installation rules for the Bullet3Geometry library, including runtime, library, and archive destinations. It also handles header file installation, excluding version control and build-related directories. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Geometry DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Geometry runtime DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(Bullet3Geometry PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(Bullet3Geometry PROPERTIES PUBLIC_HEADER "${Bullet3Geometry_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### OpenGL and Glew Setup for Windows Source: https://github.com/bulletphysics/bullet3/blob/master/examples/TwoJoint/CMakeLists.txt Configures include directories and links necessary libraries for OpenGL and Glew on Windows systems. Defines GLEW_STATIC. ```cmake IF (WIN32) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows ) ADD_DEFINITIONS(-DGLEW_STATIC) LINK_LIBRARIES( ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) ELSE(WIN32) ``` -------------------------------- ### Define Basic Example Executable Source: https://github.com/bulletphysics/bullet3/blob/master/examples/BasicDemo/CMakeLists.txt Defines the App_BasicExample executable, linking necessary Bullet libraries and including source files. It handles platform-specific source files for Windows. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ) LINK_LIBRARIES( BulletDynamics BulletCollision LinearMath ) IF (WIN32) ADD_EXECUTABLE(App_BasicExample BasicExample.cpp main.cpp ${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc ) ELSE() ADD_EXECUTABLE(App_BasicExample BasicExample.cpp main.cpp ) ENDIF() ``` -------------------------------- ### Install HACD Library and Headers Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/HACD/CMakeLists.txt Configures the installation of the HACD library and its header files. This block is conditional on INSTALL_EXTRA_LIBS and avoids installation when generating MSVC project files internally. ```cmake IF (INSTALL_EXTRA_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS HACD DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS HACD RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.inl" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(HACD PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(HACD PROPERTIES PUBLIC_HEADER "${HACD_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_EXTRA_LIBS) ``` -------------------------------- ### Install BulletInverseDynamicsUtils Library Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/InverseDynamics/CMakeLists.txt Configures installation rules for the BulletInverseDynamicsUtils library, including runtime, library, and archive destinations. This block is active only if INSTALL_EXTRA_LIBS is enabled and specific conditions are met. ```cmake IF (INSTALL_EXTRA_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletInverseDynamicsUtils DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletInverseDynamicsUtils RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletInverseDynamicsUtils PROPERTIES PUBLIC_HEADER "BulletInverseDynamicsUtilsCommon.h" ) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_EXTRA_LIBS) ``` -------------------------------- ### Install CMake Configuration Files Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Installs the generated CMake configuration files (UseBullet.cmake and BulletConfig.cmake) to the specified destination directory. This option is enabled by default. ```cmake OPTION(INSTALL_CMAKE_FILES "Install generated CMake files" ON) IF (INSTALL_CMAKE_FILES) install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/UseBullet.cmake ${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake DESTINATION ${BULLET_CONFIG_CMAKE_PATH} ) ENDIF (INSTALL_CMAKE_FILES) ``` -------------------------------- ### Include Directories for Bullet Example Browser Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ExampleBrowser/CMakeLists.txt Specifies include directories for the Bullet Example Browser, including the current directory, Bullet Physics source directories, and third-party libraries. ```cmake INCLUDE_DIRECTORIES( . ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/examples/SharedMemory ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs ) ``` -------------------------------- ### Hello PyBullet World Source: https://github.com/bulletphysics/bullet3/blob/master/docs/pybullet_quickstart_guide/PyBulletQuickstartGuide.md.html A basic example demonstrating how to connect to the PyBullet simulation, load a plane and a URDF model, step the simulation, retrieve object information, and disconnect. ```Python import pybullet as p import pybullet_data physicsClient = p.connect(p.GUI)#or p.DIRECT for non-graphical version p.setAdditionalSearchPath(pybullet_data.getDataPath()) #used by loadURDF p.setGravity(0,0,-10) planeId = p.loadURDF("plane.urdf") cubeStartPos = [0,0,1] cubeStartOrientation = p.getQuaternionFromEuler([0,0,0]) boxId = p.loadURDF("r2d2.urdf",cubeStartPos, cubeStartOrientation) p.stepSimulation() cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId) print(cubePos,cubeOrn) p.disconnect() ``` -------------------------------- ### Conditional Installation Rules Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/Serialize/BulletFileLoader/CMakeLists.txt Defines installation rules for the BulletFileLoader library, including runtime, library, and archive destinations. This block handles platform-specific installation, especially for macOS frameworks. ```cmake IF (INSTALL_EXTRA_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletFileLoader DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletFileLoader RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletFileLoader PROPERTIES PUBLIC_HEADER "${BulletFileLoader_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_EXTRA_LIBS) ``` -------------------------------- ### Include Directories Setup Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/Serialize/makesdna/CMakeLists.txt Specifies directories to be searched for header files. Includes the main Bullet Physics source directory and specific header files. ```cmake INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/src ) #FILE(GLOB INC_FILES ../*.h) SET (INC_FILES DNA_rigidbody.h ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btVector3.h ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btMatrix3x3.h ${BULLET_PHYSICS_SOURCE_DIR}/src/LinearMath/btTransform.h ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletCollision/CollisionShapes/btCollisionShape.h ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletCollision/CollisionShapes/btConvexInternalShape.h ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletCollision/CollisionDispatch/btCollisionObject.h ) ``` -------------------------------- ### Run TwoJoint Example and Log Output Source: https://github.com/bulletphysics/bullet3/blob/master/examples/TwoJoint/README.md Execute the TwoJoint application and redirect its standard output to a file named output.txt. The process should run for approximately 6 seconds before stopping. ```bash > App_TwoJoint > output.txt ``` -------------------------------- ### Configure Extra Libraries Installation Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Enables the installation of extra libraries if INSTALL_LIBS is ON and the CMake version is greater than 2.5. ```cmake IF(INSTALL_LIBS) #INSTALL of other files requires CMake 2.6 IF(BUILD_EXTRAS) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" ON) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) ENDIF(BUILD_EXTRAS) SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) ENDIF() ``` -------------------------------- ### OpenGL and Glew Setup for Linux/Other Unix Source: https://github.com/bulletphysics/bullet3/blob/master/examples/TwoJoint/CMakeLists.txt Configures include directories and defines for OpenGL and Glew on non-Windows and non-macOS systems. Links pthread and DL libraries. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows ) ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") ADD_DEFINITIONS("-DGLEW_STATIC") ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") LINK_LIBRARIES( pthread ${DL} ) ENDIF(APPLE) ENDIF(WIN32) ``` -------------------------------- ### Conditional Installation Logic Source: https://github.com/bulletphysics/bullet3/blob/master/src/Bullet3Common/CMakeLists.txt Handles the installation of the Bullet3Common library and headers based on the INSTALL_LIBS flag and CMake version. It includes platform-specific logic for macOS frameworks. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #FILES_MATCHING requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Common DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS Bullet3Common RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(Bullet3Common PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(Bullet3Common PROPERTIES PUBLIC_HEADER "${Bullet3Common_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Unity Start Function Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/unity3d/readme.txt Initializes the connection to PyBullet, resets the simulation, and loads a URDF file when the Unity script starts. This function establishes the communication channel and sets up the initial scene. ```csharp void Start () { IntPtr pybullet = b3ConnectSharedMemory(12347); IntPtr cmd = b3InitResetSimulationCommand(pybullet); IntPtr status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd); cmd = b3LoadUrdfCommandInit(pybullet, "plane.urdf"); status = b3SubmitClientCommandAndWaitStatus(pybullet, cmd); } ``` -------------------------------- ### Build Bullet using vcpkg Source: https://github.com/bulletphysics/bullet3/blob/master/README.md Download and install the Bullet3 library using the vcpkg dependency manager on a Linux or macOS system. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install bullet3 ``` -------------------------------- ### Link Libraries for Bullet Example Browser Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ExampleBrowser/CMakeLists.txt Lists the libraries to be linked for the Bullet Example Browser, including core Bullet libraries, rendering libraries, and utility libraries. ```cmake LINK_LIBRARIES( BulletExampleBrowserLib Bullet3Common BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow gwen BussIK ) ``` -------------------------------- ### Link Libraries for Basic Example GUI Source: https://github.com/bulletphysics/bullet3/blob/master/examples/BasicDemo/CMakeLists.txt Links the required libraries for the AppBasicExampleGui, including Bullet modules, OpenGLWindow, and Bullet3Common. Platform-specific OpenGL and threading libraries are handled conditionally. ```cmake LINK_LIBRARIES( BulletDynamics BulletCollision LinearMath OpenGLWindow Bullet3Common ) #some code to support OpenGL and Glew cross platform IF (WIN32) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows ) ADD_DEFINITIONS(-DGLEW_STATIC) LINK_LIBRARIES( ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) ELSE(WIN32) IF(APPLE) find_library(COCOA NAMES Cocoa) MESSAGE(${COCOA}) link_libraries(${COCOA} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) ELSE(APPLE) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows ) ADD_DEFINITIONS("-DGLEW_INIT_OPENGL11_FUNCTIONS=1") ADD_DEFINITIONS("-DGLEW_STATIC") ADD_DEFINITIONS("-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1") FIND_PACKAGE(Threads) LINK_LIBRARIES( ${CMAKE_THREAD_LIBS_INIT} ${DL} ) ENDIF(APPLE) ENDIF(WIN32) ``` -------------------------------- ### Build Bullet using Premake on Linux Source: https://github.com/bulletphysics/bullet3/blob/master/README.md Generate Makefiles for Bullet using premake on Linux 32-bit and 64-bit systems. Ensure you have gcc and cmake installed. ```bash cd build3 ./premake4_linux --double gmake ./premake4_linux64 --double gmake ``` -------------------------------- ### Add Executable for Pendulum Example Source: https://github.com/bulletphysics/bullet3/blob/master/test/BulletDynamics/pendulum/CMakeLists.txt Defines the executable target 'Test_BulletDynamics' and specifies its source file. ```cmake ADD_EXECUTABLE(Test_BulletDynamics ../../../examples/MultiBody/Pendulum.cpp ) ``` -------------------------------- ### Configure Library Installation Option Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Sets the INSTALL_LIBS option based on the CMake generator. It's enabled by default for Unix Makefiles and conditionally for macOS frameworks, and disabled for Xcode and MSVC. ```cmake IF("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") OPTION(INSTALL_LIBS "Set when you want to install libraries" ON) ELSE() IF(APPLE AND FRAMEWORK) OPTION(INSTALL_LIBS "Set when you want to install libraries" ON) ELSE() #by default, don't enable the 'INSTALL' option for Xcode and MSVC projectfiles OPTION(INSTALL_LIBS "Set when you want to install libraries" OFF) ENDIF() ENDIF() ``` -------------------------------- ### Run App_ExampleBrowser with Options Source: https://github.com/bulletphysics/bullet3/blob/master/README.md Launch the App_ExampleBrowser executable with various command-line arguments to control demo startup, movie recording, mouse sensitivity, background color, and physics timestep. ```bash [--start_demo_name="Demo Name"] Start with a selected demo [--mp4=moviename.mp4] Create a mp4 movie of the window, requires ffmpeg installed [--mouse_move_multiplier=0.400000] Set the mouse move sensitivity [--mouse_wheel_multiplier=0.01] Set the mouse wheel sensitivity [--background_color_red= 0.9] Set the red component for background color. Same for green and blue [--fixed_timestep= 0.0] Use either a real-time delta time (0.0) or a fixed step size (0.016666) ``` -------------------------------- ### ImGui Window Creation with Menu Bar and Widgets Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ThirdPartyLibs/imgui/README.md Shows how to create a window with a menu bar, including file menu items, and use widgets like ColorEdit4, PlotLines, and BeginChild for displaying color pickers, plots, and scrolling text areas. ```cpp // Create a window called "My First Tool", with a menu bar. ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar); if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("File")) { if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ } if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ } if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; } ImGui::EndMenu(); } ImGui::EndMenuBar(); } // Edit a color (stored as ~4 floats) ImGui::ColorEdit4("Color", my_color); // Plot some values const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f }; ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values)); // Display contents in a scrolling region ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff"); ImGui::BeginChild("Scrolling"); for (int n = 0; n < 50; n++) ImGui::Text("%04d: Some text", n); ImGui::EndChild(); ImGui::End(); ``` -------------------------------- ### PyBullet Installation Path Configuration Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/CMakeLists.txt Sets the installation path for Python site-packages based on the operating system and Python version. This path is used to determine where the PyBullet library will be installed. ```cmake IF(WIN32) SET(PYTHON_SITE_PACKAGES Lib/site-packages CACHE PATH "Python install path") ELSE() SET(PYTHON_SITE_PACKAGES lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Python install path") ENDIF() INSTALL(TARGETS pybullet DESTINATION ${PYTHON_SITE_PACKAGES}) ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/bulletphysics/bullet3/blob/master/examples/SharedMemory/CMakeLists.txt Sets up include directories, defines, and libraries for the Bullet Physics project. ```cmake INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) ADD_DEFINITIONS(-DB3_USE_STANDALONE_EXAMPLE) LINK_LIBRARIES( BulletSoftBody Bullet3Common BulletWorldImporter BulletInverseDynamicsUtils BulletInverseDynamics BulletDynamics BulletCollision LinearMath BussIK OpenGLWindow ) ``` -------------------------------- ### Set Library Installation Directory Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Configures the destination directory for installed libraries. This is a cache variable that can be modified. ```cmake SET (LIB_DESTINATION "lib${LIB_SUFFIX}" CACHE STRING "Library directory name") ``` -------------------------------- ### Library Creation and Linking Source: https://github.com/bulletphysics/bullet3/blob/master/examples/OpenGLWindow/CMakeLists.txt Creates the OpenGLWindow library and links it with platform-specific and common libraries. ```cmake ADD_LIBRARY(OpenGLWindow ${OpenGLWindow_SRCS} ${OpenGLWindow_HDRS}) if (UNIX AND NOT APPLE) target_link_libraries(OpenGLWindow ${DL}) elseif (APPLE) target_link_libraries(OpenGLWindow ${COCOA_LIBRARY}) endif () if (BUILD_SHARED_LIBS) target_link_libraries(OpenGLWindow Bullet3Common) if (WIN32 OR APPLE) target_link_libraries(OpenGLWindow ${OPENGL_gl_LIBRARY}) else() set (CMAKE_THREAD_PREFER_PTHREAD TRUE) FIND_PACKAGE(Threads) target_link_libraries(OpenGLWindow ${CMAKE_THREAD_LIBS_INIT}) endif() endif() ``` -------------------------------- ### Basic ImGui Text, Button, Input, and Slider Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ThirdPartyLibs/imgui/README.md Demonstrates the use of ImGui::Text, ImGui::Button, ImGui::InputText, and ImGui::SliderFloat for displaying text, creating interactive buttons, input fields, and sliders. ```cpp ImGui::Text("Hello, world %d", 123); if (ImGui::Button("Save")) { // do stuff } ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ``` -------------------------------- ### Conditional Library Installation Source: https://github.com/bulletphysics/bullet3/blob/master/src/CMakeLists.txt Installs common header files if the INSTALL_LIBS option is enabled and the CMake version is sufficient. This ensures necessary headers are available for external projects. ```cmake IF(INSTALL_LIBS) #INSTALL of other files requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) # Don't actually need to install any common files, the frameworks include everything ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(FILES btBulletCollisionCommon.h btBulletDynamicsCommon.h DESTINATION ${INCLUDE_INSTALL_DIR}) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) ENDIF(INSTALL_LIBS) ``` -------------------------------- ### Add Test for Pendulum Example Source: https://github.com/bulletphysics/bullet3/blob/master/test/BulletDynamics/pendulum/CMakeLists.txt Registers 'Test_BulletDynamics' as a test case named 'Test_BulletDynamics_PASS'. ```cmake ADD_TEST(Test_BulletDynamics_PASS Test_BulletDynamics) ``` -------------------------------- ### Set Gravity Source: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/notebooks/HelloPyBullet.ipynb Sets the gravitational acceleration for the simulation. Earth's gravity is used as an example. ```python import pybullet as p p.setGravity(0, 0, -9.807) ``` -------------------------------- ### Display Japanese Text and Use ImGui Widgets Source: https://github.com/bulletphysics/bullet3/blob/master/examples/ThirdPartyLibs/imgui/README.md Demonstrates displaying Japanese text and using common ImGui widgets like buttons, input fields, and sliders. Ensure UTF-8 encoding is used for text literals. ```cpp ImGui::Text(u8"こんにちは!テスト %d", 123); if (ImGui::Button(u8"ロード")) { // do stuff } ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/bulletphysics/bullet3/blob/master/CMakeLists.txt Specifies the minimum version of CMake required for this project. Ensure your CMake installation meets this requirement. ```cmake cmake_minimum_required(VERSION 3.5) ``` -------------------------------- ### Define HACD Header Files Source: https://github.com/bulletphysics/bullet3/blob/master/Extras/HACD/CMakeLists.txt Lists the header files (.h and .inl) for the HACD library. These are used for compilation and potentially for installation. ```cmake SET(HACD_HDRS hacdCircularList.h hacdGraph.h hacdHACD.h hacdICHull.h hacdManifoldMesh.h hacdVector.h hacdVersion.h hacdCircularList.inl hacdVector.inl ) ``` -------------------------------- ### Windows Platform Configuration Source: https://github.com/bulletphysics/bullet3/blob/master/examples/OpenGLWindow/CMakeLists.txt Configures source files, include directories, and definitions for the Windows platform. ```cmake IF (WIN32) SET(OpenGLWindow_SRCS ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad/gl.c ${OpenGLWindowWin32_CPP} ${OpenGLWindowCommon_CPP}) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad ) ADD_DEFINITIONS(-DGLEW_STATIC) ENDIF(WIN32) ``` -------------------------------- ### Build Bullet using Premake on OSX Source: https://github.com/bulletphysics/bullet3/blob/master/README.md Generate Xcode project files for Bullet using premake on Mac OSX. Ensure you have cmake installed. ```bash ./premake4_osx --double --enable_pybullet gmake ``` -------------------------------- ### OpenGL and Glew Configuration for Windows Source: https://github.com/bulletphysics/bullet3/blob/master/examples/RobotSimulator/CMakeLists.txt Configures include directories and links necessary libraries for OpenGL and Glew on Windows systems. ```cmake IF (WIN32) INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/btgui/OpenGLWindow/GlewWindows ) ADD_DEFINITIONS(-DGLEW_STATIC) LINK_LIBRARIES( ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) ELSE(WIN32) ```