remove most clutter (todo)

This commit is contained in:
Erwin Coumans 2013-12-06 15:29:13 -07:00
parent 9e9b172b23
commit f06312c632
1417 changed files with 0 additions and 661038 deletions

22
AUTHORS
View File

@ -1,22 +0,0 @@
Bullet Physics Library is an open source project with help from the community at the Physics Forum
See the forum at http://bulletphysics.com
The project was started by Erwin Coumans
Following people contributed to Bullet
(random order, please let us know on the forum if your name should be in this list)
Gino van den Bergen: LinearMath classes
Christer Ericson: parts of the voronoi simplex solver
Simon Hobbs: 3d axis sweep and prune, Extras/SATCollision, separating axis theorem + SIMD code
Dirk Gregorius: generic D6 constraint
Erin Catto: accumulated impulse in sequential impulse
Nathanael Presson: EPA penetration depth calculation
Francisco Leon: GIMPACT Concave Concave collision
Joerg Henrichs: make buildsystem (work in progress)
Eric Sunshine: jam + msvcgen buildsystem
Steve Baker: GPU physics and general implementation improvements
Jay Lee: Double precision support
KleMiX, aka Vsevolod Klementjev, managed version, rewritten in C# for XNA
Erwin Coumans: most other source code

Binary file not shown.

View File

@ -1,25 +0,0 @@
# -*- cmake -*-
#
# BulletConfig.cmake(.in)
#
# Use the following variables to compile and link against Bullet:
# BULLET_FOUND - True if Bullet was found on your system
# BULLET_USE_FILE - The file making Bullet usable
# BULLET_DEFINITIONS - Definitions needed to build with Bullet
# BULLET_INCLUDE_DIR - Directory where Bullet-C-Api.h can be found
# BULLET_INCLUDE_DIRS - List of directories of Bullet and it's dependencies
# BULLET_LIBRARIES - List of libraries to link against Bullet library
# BULLET_LIBRARY_DIRS - List of directories containing Bullet' libraries
# BULLET_ROOT_DIR - The base directory of Bullet
# BULLET_VERSION_STRING - A human-readable string containing the version
set ( BULLET_FOUND 1 )
set ( BULLET_USE_FILE "@BULLET_USE_FILE@" )
set ( BULLET_DEFINITIONS "@BULLET_DEFINITIONS@" )
set ( BULLET_INCLUDE_DIR "@INCLUDE_INSTALL_DIR@" )
set ( BULLET_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@" )
set ( BULLET_LIBRARIES "@BULLET_LIBRARIES@" )
set ( BULLET_LIBRARY_DIRS "@LIB_DESTINATION@" )
set ( BULLET_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" )
set ( BULLET_VERSION_STRING "@BULLET_VERSION@" )

View File

@ -1,18 +0,0 @@
/*
Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
Free for commercial use, please report projects in the forum at http://www.bulletphysics.org
In case you want to display a Bullet logo in your software: you can download the Bullet logo in various vector formats and high resolution at the download section in http://bullet.googlecode.com

Binary file not shown.

View File

@ -1,439 +0,0 @@
cmake_minimum_required(VERSION 2.4.3)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
SET(MSVC_INCREMENTAL_DEFAULT ON)
PROJECT(BULLET_PHYSICS)
SET(BULLET_VERSION 2.82)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
IF (NOT CMAKE_BUILD_TYPE)
# SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_BUILD_TYPE "Release")
ENDIF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG})
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" OFF)
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
OPTION(USE_CUSTOM_VECTOR_MATH "Use custom vectormath library" OFF)
IF (USE_CUSTOM_VECTOR_MATH)
ADD_DEFINITIONS(-DUSE_SYSTEM_VECTORMATH)
IF(WIN32)
SET (VECTOR_MATH_INCLUDE ${BULLET_PHYSICS_SOURCE_DIR}/src/vectormath/sse CACHE PATH "Vector Math library include path.")
ELSE(WIN32)
SET (VECTOR_MATH_INCLUDE ${BULLET_PHYSICS_SOURCE_DIR}/src/vectormath/scalar CACHE PATH "Vector Math library include path.")
ENDIF(WIN32)
ENDIF(USE_CUSTOM_VECTOR_MATH)
IF (APPLE OR MSVC)
OPTION(BUILD_MULTITHREADING "Use BulletMultiThreading" ON)
ELSE()
OPTION(BUILD_MULTITHREADING "Use BulletMultiThreading" OFF)
ENDIF()
IF (BUILD_MULTITHREADING)
OPTION(USE_MULTITHREADED_BENCHMARK "Use Multithreaded Benchmark" OFF)
IF (USE_MULTITHREADED_BENCHMARK)
ADD_DEFINITIONS(-DUSE_PARALLEL_SOLVER_BENCHMARK -DUSE_PARALLEL_DISPATCHER_BENCHMARK)
ENDIF(USE_MULTITHREADED_BENCHMARK)
IF (MSVC OR APPLE)
OPTION(BUILD_MINICL_OPENCL_DEMOS "Build OpenCL demos for MiniCL (Generic CPU)" ON)
ELSE()
OPTION(BUILD_MINICL_OPENCL_DEMOS "Build OpenCL demos for MiniCL (Generic CPU)" OFF)
ENDIF(MSVC OR APPLE)
IF(MSVC)
FIND_PATH(DIRECTX_SDK_BASE_DIR Include/D3D11.h PATH $ENV{DXSDK_DIR} )
IF(DIRECTX_SDK_BASE_DIR)
OPTION(USE_DX11 "Use DirectX 11" ON)
ELSE()
OPTION(USE_DX11 "Use DirectX 11" OFF)
ENDIF()
FIND_PATH(AMD_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{ATISTREAMSDKROOT} $ENV{AMDAPPSDKROOT} )
IF(AMD_OPENCL_BASE_DIR)
#AMD adds an extras slash at the end of the ATISTREAMSDKROOT variable
SET(AMD_OPENCL_INCLUDES ${AMD_OPENCL_BASE_DIR}/include )
MESSAGE("AMD OPENCL SDK FOUND")
IF (CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86_64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86 )
ENDIF(CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBRARY ${CMAKE_ATISTREAMSDK_LIBPATH}/OpenCL.lib )
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" ON)
IF (CMAKE_CL_64)
SET(CMAK_GLEW_LIBRARY
${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew64s.lib )
ELSE(CMAKE_CL_64)
SET(CMAK_GLEW_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew32s.lib )
ENDIF(CMAKE_CL_64)
ELSE()
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" OFF)
ENDIF()
FIND_PATH(INTEL_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{INTELOCLSDKROOT} )
IF(INTEL_OPENCL_BASE_DIR)
SET(INTEL_OPENCL_INCLUDES ${INTEL_OPENCL_BASE_DIR}/include )
MESSAGE("INTEL OPENCL SDK FOUND")
MESSAGE(${INTEL_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_INTELOCLSDK_LIBPATH ${INTEL_OPENCL_BASE_DIR}/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_INTELOCLSDK_LIBPATH ${INTEL_OPENCL_BASE_DIR}/lib/x86 )
ENDIF(CMAKE_CL_64)
SET(INTEL_OPENCL_LIBRARIES ${CMAKE_INTELOCLSDK_LIBPATH}/OpenCL.lib)
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" ON)
ELSE()
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" OFF)
ENDIF()
FIND_PATH(NVIDIA_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{CUDA_PATH} )
IF(NVIDIA_OPENCL_BASE_DIR)
SET(NVIDIA_OPENCL_INCLUDES ${NVIDIA_OPENCL_BASE_DIR}/include )
MESSAGE("NVIDIA OPENCL SDK FOUND")
MESSAGE(${NVIDIA_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH ${NVIDIA_OPENCL_BASE_DIR}/lib/x64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_NVSDKCOMPUTE_LIBPATH ${NVIDIA_OPENCL_BASE_DIR}/lib/Win32 )
ENDIF(CMAKE_CL_64)
SET(NVIDIA_OPENCL_LIBRARIES ${CMAKE_NVSDKCOMPUTE_LIBPATH}/OpenCL.lib)
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" ON)
ELSE()
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" OFF)
ENDIF()
ELSE(MSVC)
FIND_PATH(AMD_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{ATISTREAMSDKROOT} $ENV{AMDAPPSDKROOT} )
IF(AMD_OPENCL_BASE_DIR)
#AMD adds an extras slash at the end of the ATISTREAMSDKROOT variable
SET(AMD_OPENCL_INCLUDES ${AMD_OPENCL_BASE_DIR}/include )
MESSAGE("AMD OPENCL SDK FOUND")
MESSAGE(${AMD_OPENCL_INCLUDES})
IF (CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86_64 )
ELSE(CMAKE_CL_64)
SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86 )
ENDIF(CMAKE_CL_64)
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" ON)
SET(CMAKE_ATISTREAMSDK_LIBRARY OpenCL )
ELSE()
OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" OFF)
ENDIF(AMD_OPENCL_BASE_DIR)
FIND_PATH(INTEL_OPENCL_INCLUDES CL/cl.h)
FIND_PATH(INTEL_OPENCL_ICD_CFG intelocl64.icd /etc/OpenCL/vendors)
FIND_LIBRARY(INTEL_OPENCL_LIBRARIES OpenCL PATH /usr/lib64)
IF (INTEL_OPENCL_INCLUDES AND INTEL_OPENCL_LIBRARIES AND INTEL_OPENCL_ICD_CFG)
MESSAGE("INTEL OPENCL SDK FOUND")
MESSAGE(${INTEL_OPENCL_LIBRARIES})
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" ON)
ELSE ()
MESSAGE("INTEL OPENCL NOT FOUND")
OPTION(BUILD_INTEL_OPENCL_DEMOS "Build OpenCL demos for Intel (CPU)" OFF)
ENDIF ()
FIND_PATH(NVIDIA_OPENCL_INCLUDES CL/cl.h)
FIND_PATH(NVIDIA_OPENCL_ICD_CFG nvidia.icd /etc/OpenCL/vendors)
FIND_LIBRARY(NVIDIA_OPENCL_LIBRARIES OpenCL PATH /usr/lib64 /usr/local/lib)
IF (NVIDIA_OPENCL_INCLUDES AND NVIDIA_OPENCL_LIBRARIES AND NVIDIA_OPENCL_ICD_CFG)
MESSAGE("NVidia OPENCL FOUND")
MESSAGE(${NVIDIA_OPENCL_LIBRARIES})
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" ON)
ELSE ()
MESSAGE("NVidia OPENCL NOT FOUND")
OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" OFF)
ENDIF ()
ENDIF(MSVC)
ELSE(BUILD_MULTITHREADING)
# SET(BUILD_NVIDIA_OPENCL_DEMOS OFF CACHE BOOL "Build OpenCL demos for NVidia" FORCE)
# SET(BUILD_AMD_OPENCL_DEMOS OFF CACHE BOOL "Build OpenCL demos for AMD" FORCE)
# SET(BUILD_INTEL_OPENCL_DEMOS OFF CACHE BOOL "Build OpenCL demos for Intel (CPU)" FORCE)
# SET(BUILD_MINICL_OPENCL_DEMOS OFF CACHE BOOL "Build OpenCL demos for MiniCL (Generic CPU)" FORCE)
# SET(USE_DX11 OFF CACHE BOOL "Use DirectX 11" FORCE)
# SET(USE_MULTITHREADED_BENCHMARK OFF CACHE BOOL "Use Multithreaded Benchmark" FORCE)
ENDIF(BUILD_MULTITHREADING)
#SET(CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:NO")
#SET(CMAKE_EXE_LINKER_FLAGS "/STACK:10000000 /INCREMENTAL:NO")
#MESSAGE("MSVC_INCREMENTAL_YES_FLAG"+${MSVC_INCREMENTAL_YES_FLAG})
IF(MSVC)
IF (NOT USE_MSVC_INCREMENTAL_LINKING)
#MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT})
SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO")
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" )
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
# STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS})
# SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2})
# STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS})
# SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3})
STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacementFlags3})
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags3}" )
ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING)
IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
#We statically link to reduce dependancies
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
IF(${flag_var} MATCHES "/MDd")
STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MDd")
ENDFOREACH(flag_var)
ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
IF (CMAKE_CL_64)
ADD_DEFINITIONS(-D_WIN64)
ELSE()
OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" ON)
IF (USE_MSVC_SSE)
ADD_DEFINITIONS(/arch:SSE)
ENDIF()
ENDIF()
OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF (USE_MSVC_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast)
ENDIF()
ENDIF(MSVC)
IF (WIN32)
OPTION(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES "Create MSVC projectfiles that can be distributed" OFF)
IF (INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
SET (LIBRARY_OUTPUT_PATH ${BULLET_PHYSICS_SOURCE_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BULLET_PHYSICS_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BULLET_PHYSICS_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BULLET_PHYSICS_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BULLET_PHYSICS_SOURCE_DIR})
ELSE()
SET (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for building all libraries.")
ENDIF()
OPTION(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES "Create MSVC projectfiles with relative paths" OFF)
OPTION(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES "Add MSVC postfix for executable names (_Debug)" OFF)
SET(CMAKE_DEBUG_POSTFIX "_Debug" CACHE STRING "Adds a postfix for debug-built libraries.")
SET(CMAKE_MINSIZEREL_POSTFIX "_MinsizeRel" CACHE STRING "Adds a postfix for MinsizeRelease-built libraries.")
SET(CMAKE_RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo" CACHE STRING "Adds a postfix for ReleaseWithDebug-built libraries.")
IF (INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
SET(CMAKE_SUPPRESS_REGENERATION 1)
SET(CMAKE_USE_RELATIVE_PATHS 1)
ENDIF(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
ENDIF (WIN32)
OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU demos" ON)
OPTION(INTERNAL_UPDATE_SERIALIZATION_STRUCTURES "Internal update serialization structures" OFF)
IF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
IF (USE_DOUBLE_PRECISION)
ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
SET( BULLET_DOUBLE_DEF "-DBT_USE_DOUBLE_PRECISION")
ENDIF (USE_DOUBLE_PRECISION)
IF(USE_GRAPHICAL_BENCHMARK)
ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
ENDIF (USE_GRAPHICAL_BENCHMARK)
IF (WIN32)
OPTION(USE_GLUT "Use Glut" ON)
ADD_DEFINITIONS( -D_IRR_STATIC_LIB_ )
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
ADD_DEFINITIONS( -D_CRT_SECURE_NO_DEPRECATE )
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
IF (USE_GLUT AND MSVC)
string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
remove_definitions(-D_WINDOWS )
ENDIF()
ELSE(WIN32)
OPTION(USE_GLUT "Use Glut" ON)
ENDIF(WIN32)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
# This should be the case.
FIND_PACKAGE(OpenGL)
IF (OPENGL_FOUND)
MESSAGE("OPENGL FOUND")
MESSAGE(${OPENGL_LIBRARIES})
ELSE (OPENGL_FOUND)
MESSAGE("OPENGL NOT FOUND")
SET(OPENGL_gl_LIBRARY opengl32)
SET(OPENGL_glu_LIBRARY glu32)
ENDIF (OPENGL_FOUND)
# ADD_DEFINITIONS(-DBT_USE_FREEGLUT)
FIND_PACKAGE(GLU)
IF (USE_GLUT)
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
MESSAGE("GLUT FOUND")
MESSAGE(${GLUT_glut_LIBRARY})
ELSE (GLUT_FOUND)
IF (MINGW)
MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32")
SET(GLUT_glut_LIBRARY glut32)
#TODO add better GLUT detection for MinGW
SET(GLUT_FOUND TRUE)
ENDIF (MINGW)
IF (MSVC)
SET(GLUT_FOUND TRUE)
IF (CMAKE_CL_64)
message("Win64 using Glut/glut64.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut64.lib)
ELSE(CMAKE_CL_64)
message("Win32 using Glut/glut32.lib")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib)
ENDIF (CMAKE_CL_64)
INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/Glut)
ELSE()
MESSAGE("GLUT NOT FOUND")
ENDIF (MSVC)
ENDIF (GLUT_FOUND)
IF(NOT WIN32)
# This is added for linux. This should always work if everything is installed and working fine.
INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
ENDIF()
ENDIF(USE_GLUT)
OPTION(BUILD_DEMOS "Set when you want to build the demos" ON)
IF(BUILD_DEMOS)
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos)
SUBDIRS(Demos)
ENDIF()
ENDIF(BUILD_DEMOS)
# "Demos_ps3")
IF (MSVC)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos_ps3 AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos_ps3)
MESSAGE("Demos_ps3 found")
SUBDIRS(Demos_ps3)
ENDIF()
ENDIF()
ENDIF(MSVC)
OPTION(BUILD_EXTRAS "Set when you want to build the extras" ON)
IF(BUILD_EXTRAS)
SUBDIRS(Extras)
ENDIF(BUILD_EXTRAS)
#Maya Dynamica plugin is moved to http://dynamica.googlecode.com
SUBDIRS(src)
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()
IF(INSTALL_LIBS)
SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
SET (LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name")
## the following are directories where stuff will be installed to
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/bullet/" CACHE PATH "The subdirectory to the header prefix")
SET(PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
IF(NOT WIN32)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc @ONLY)
INSTALL(
FILES
${CMAKE_CURRENT_BINARY_DIR}/bullet.pc
DESTINATION
${PKGCONFIG_INSTALL_PREFIX})
ENDIF(NOT WIN32)
ENDIF(INSTALL_LIBS)
#INSTALL of other files requires CMake 2.6
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF)
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
OPTION(BUILD_UNIT_TESTS "Build Unit Tests" OFF)
IF (BUILD_UNIT_TESTS)
SUBDIRS(UnitTests)
ENDIF()
set (BULLET_CONFIG_CMAKE_PATH lib${LIB_SUFFIX}/cmake/bullet )
list (APPEND BULLET_LIBRARIES LinearMath)
list (APPEND BULLET_LIBRARIES BulletCollisions)
list (APPEND BULLET_LIBRARIES BulletDynamics)
list (APPEND BULLET_LIBRARIES BulletSoftBody)
set (BULLET_USE_FILE ${CMAKE_INSTALL_PREFIX}/${BULLET_CONFIG_CMAKE_PATH}/UseBullet.cmake)
configure_file ( ${CMAKE_SOURCE_DIR}/BulletConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
@ONLY ESCAPE_QUOTES
)
install ( FILES ${CMAKE_SOURCE_DIR}/UseBullet.cmake
${CMAKE_CURRENT_BINARY_DIR}/BulletConfig.cmake
DESTINATION ${BULLET_CONFIG_CMAKE_PATH}
)

17
COPYING
View File

@ -1,17 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2011 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
All files in the Bullet/src folder are under this Zlib license.
Files in the Extras and Demos folder may have a different license, see the respective files.

795
ChangeLog
View File

@ -1,795 +0,0 @@
Bullet Continuous Collision Detection and Physics Library
Primary author and maintainer: Erwin Coumans
This ChangeLog is incomplete, for an up-to-date list of all fixed issues see http://bullet.googlecode.com
using http://tinyurl.com/yabmjjj
2013 October 23
- Bullet 2.82 release
- See docs/BulletQuickstart.pdf or issue tracked for details.
2012 September 10
- Bullet 2.81 release preparation
2011 September 15
- Bullet 2.79 release, revision 2433 (mainly a bugfix release)
- Revert a change in 2.78 related to speculative contacts (it has undesired side effects)
- Use HACD Hierachical Approximate Convex Decomposition (thanks to Khaled Mammou and Sujeon Kim)
- Add Intel cmake-build support for OpenCL accelerated cloth/particle
- add premake4 build system support to autogenerate visual studio project files that can be shipped (see msvc folder)
- preliminary build support for Google NativeClient, using premake4 (see msvc folder)
2011 April 8
- Bullet 2.78 release 2383
- Added FractureDemo
- Added Separatinx Axis Test and Polyhedral Clipping support (See InternalEdgeDemo)
- Added speculative contacts as CCD response method (See CcdPhysicsDemo)
- OpenCL and DirectCompute cloth as basic support for capsule collision
2010 September 7
- autotools now uses CamelCase naming for libraries just like cmake:
libbulletdynamics -> libBulletDynamics, libbulletmath -> libLinearMath
2010 July 21
- Preparing for Bullet 2.77 release, around revision r2135
- Added an OpenCL particle demo, running on NVidia, AMD and MiniCL
Thanks to NVidia for the original particle demo from their OpenCL SDK
- Added GPU deformable object solvers for OpenCL and DirectCompute, and a DirectX 11 cloth demo
Thanks to AMD
- Create a separate library for MiniCL,
MiniCL is a rudimentary OpenCL wrapper that allows to compile OpenCL kernels for multi-core CPU, using Win32 Threads or Posix
- Moved vectormath into Bullet/src, and added a SSE implementation
- Added a btParallelConstraintSolver, mainly for PlayStation 3 Cell SPUs (although it runs fine on CPU too)
2010 March 6
- Dynamica Maya plugin (and COLLADA support) is moved to http://dynamica.googlecode.com
2010 February
- Bullet 2.76 release, revision 2010
- support for the .bullet binary file format
- btInternalEdgeUtility to adjust unwanted collisions against internal triangle edges
- Improved Maya Dynamica plugin with better constraint authoring and .bullet file export
2009 September 17
- Minor update to Bullet 2.75 release, revision 1776
- Support for btConvex2dShape, check out Bullet/Demos/Box2dDemo
- Fixes in build systems
- Minor fix in btGjkPairDetector
- Initialize world transform for btCollisionShape in constructor
2009 September 6
- Bullet 2.75 release
- Added SPH fluid simulation in Extras, not integrated with rigid body / soft body yet
Thanks to Rama Hoetzlein to make this contribution available under the ZLib license
- add special capsule-capsule collider code in btConvexConvexCollisionAlgorithm, to speed up capsule-ragdolls
- soft body improvement: faster building of bending constraints
- soft body improvement: allow to disable/enable cluster self-collision
- soft body fix: 'exploding' soft bodies when using cluster collision
- fix some degenerate cases in continuous convex cast, could impact ray cast/convex cast
Thanks to Jacob Langford for the report and reproduction cases, see http://code.google.com/p/bullet/issues/detail?id=250&can=1&start=200
- re-enabled split impulse
- added btHinge2Constraint, btUniversalConstraint, btGeneric6DofSpringConstraint
- demonstrate 2D physics with 2D/3D object interaction
2008 December 2
- Fix contact refresh issues with btCompoundShape, introduced with btDbvt acceleration structure in btCompoundCollisionAlgorithm
- Made btSequentialImpulseConstraintSolver 100% compatible with ODE quickstep
constraints can use 'solveConstraint' method or 'getInfo/getInfo2'
2008 November 30
- Add highly optimized SIMD branchless PGS/SI solver innerloop
2008 November 12
- Add compound shape export to BulletColladaConverter
Thanks to JamesH for the report: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=12&t=2840
- Fix compiler build for Visual Studio 6
Thanks to JoF for the report: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2841
2008 November 11
- Add CProfileManager::dumpAll() to dump performance statistics to console using printf.
- Add support for interaction between btSoftBody and btCollisionObject/btGhostObject
2008 November 8
- Fix PosixThreadSupport
- Add improved btHeightfieldTerrainShape support and new Demos/TerrainDemo
Thanks to tomva, http://code.google.com/p/bullet/issues/detail?id=63&can=1
- Moved kinematic character controller from Demos/CharacterDemo into src/BulletDynamics/Character/btKinematicCharacterController.cpp
2008 November 6
- reduced default memory pool allocation from 40Mb to 3Mb. This should be more suitable for all platforms, including iPhone
- improved CUDA broadphase
- IBM Cell SDK 3.x support, fix ibmsdk Makefiles
- improved CMake support with 'install' and 'framework option
2008 November 4
- add btAxisSweep::resetPool to avoid non-determinism due to shuffled linked list
Thanks to Ole for the contribution,
2008 October 30
- disabled btTriangleMesh duplicate search by default, it is extremely slow
- added Extras/IFF binary chunk serialization library as preparation for in-game native platform serialization (planned COLLADA DOM -> IFF converter)
2008 October 20
- added SCE Physics Effects box-box collision detection for SPU/BulletMultiThreaded version
See Bullet/src/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/boxBoxDistance.cpp
Thanks to Sony Computer Entertainment Japan, SCEI for the contribution
2008 October 17
- Added btGhostObject support, this helps character controller, explosions, triggers and other local spatial queries
2008 October 10
- Moved aabb to btBroadphaseProxy, improves rayTest dramatically. Further raytest improvements using the broadphase acceleration structures are planned
- Moved BulletMultiThreaded from Extras to /src/BulletMultiThreaded for better integration
2008 October 3
- Add support for autoconf automake
./autogen.sh and ./configure will create both Makefile and Jamfile. CMake and autogenerated Visual Studio projectfiles remain supported too.
- Improved ColladaConverter: plane shape export, and callback for shape construction to allow deletion of memory
2008 Sept 30
- Improved Soft Body support, fixed issues related to soft body colliding against concave triangle meshes
- Shared more code between regular version and SPU/BulletMultiThreaded, in particular GJK/EPA
2008 Sept 28
- Fixed rotation issues in Dynamic Maya Plugin
2008 Sept 11
- Enable CCD motion clamping for btDiscreteDynamicsWorld, to avoid tunneling. A more advanced solution will be implemented in btContinuousDynamicsWorld.
2008 Sept 7
- Add btScaledBvhTriangleMeshShape, to allow re-use of btBvhTriangleMeshShape of different sizes, without copying of the BVH data.
2008 Sept 5
- Enabled Demos/ForkLiftDemo
Thanks Roman Ponomarev.
2008 Sept 4
- Added btCudaBroadphase in Extras/CUDA: some research into accelerating Bullet using CUDA.
Thanks to the particle demo from the NVidia CUDA SDK.
2008 Sept 3
- Several bug fixes and contributions related to inertia tensor, memory leaks etc.
Thanks to Ole K.
2008 Sept 1
- Updated CDTestFramework, with latest version of OPCODE Array SAP. See Extras/CDTestFramework
Thanks to Pierre Terdiman for the update
2008 August 25
- Walt Disney Studios contributes their in-house Maya Plugin for simulating Bullet physics, with options for other engines such as PhysBam or PhysX.
Thanks to Nicola Candussi and Arthur Shek
2008 August 14
- Improved performance for btDbvtBroadphase, based on dual dynamic AABB trees (one for static, one for dynamic objects, where objects can move from one to the other tree)
Thanks to Nathanael Presson again, for all his work.
2008 July 31
- Added Havok .hkx to COLLADA Physics .dae converter patch+information
- Fix btSubsimplexConvexCast
Thanks to Nacho, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2422)
- Fix in rendering, GL_STENCIL
- btTriangleIndexVertexArray indices should be unsigned int/unsigned short int,
- Made InternalProcessAllTriangles virtual, thanks to
Both thank to Fullmetalcoder, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2401
- clamp impulse for btPoint2PointConstraint
Thanks to Martijn Reuvers, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2418
- Free memory of bvh, pass in scaling factor (optional)
Thanks to Roy Eltham, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2375
2008 July 27
btDbvtBroadphase:
- Fixed a performance issues reported by 'reltham'
- Added btDbvtBroadphase::optimize() for people who want good performances right
away or don't do dynamics.
- fixed compilation issues when DBVT_BP_PROFILE was set.
btSoftBody:
- Fixed singular matrix issues related to polar decomposition (flat meshes).
DemoApplication:
- Shadows (enable/disable through 'g' or DemoApplication::setShadows(bool)).
- Texture can be enable/disable through 'u'
CDFramework:
- fixed compilation issues.
All thanks to Nathanael Presson
2008 July 10
- Added btMultimaterialTriangleMeshShape and MultiMaterialDemo
Thanks to Alex Silverman for the contribution
2008 June 30
- Added initial support for kinematic character controller
Thanks to John McCutchan
2008 April 14
- Added ray cast support for Soft Bodies
Thanks to Nathanael Presson for the contribution
2008 April 9
- Cleanup of Stan Melax ConvexHull, removed Extras/ConvexHull, moved sources into LinearMath/BulletCollision
2008 April 4
- Added btSliderConstraint and demo
Thanks Roman Ponomarev
2008 April 3
- Fixed btMinkowskiSumShape, and added hitpoint to btSubsimplexConvexCast
2008 April 2
- Added Extras/CdTestFrameWork
Thanks Pierre Terdiman
2008 April 1
- Added posix thread (pthread) support
Thanks Enrico
2008 March 30
- Added Soft Body, cloth, rope and deformable volumes, including demos and interaction
Thanks Nathanael Presson for this great contribution
2008 March 17
- Improved BulletColladaConverter
Thanks John McCutchan
2008 March 15
- btMultiSapBroadphase in a working state. Needs more optimizations to be fully useable.
- Allow btOptimizedBvh to be used for arbitrary objects, not just triangles
- added quicksort to btAlignedObjectArray
- removed btTypedUserInfo, added btHashMap
2008 March 30
- Moved quickstep solver and boxbox into Bullet/src folder
Thanks Russell L. Smith for permission to redistribute Open Dynamics Engine quickstep and box-box under the ZLib license
2008 Feb 27
- Added initial version for Character Control Demo
- Applied fixes to IBM Cell SDK 3.0 build makefiles
Thanks Jochen and mojo for reporting/providing patch: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1922
2008 Feb 8
- Bugfixes in ConvexCast support against the world.
Thanks to Isgmasa for reporting/providing fix: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1823
2008 Feb 6
- Added btCapsuleShapeX and btCapsuleShapeZ for capsules around X and Z axis (default capsule is around Y)
2008 Feb 3
- Added btTypedUserInfo, useful for serialization
2008 Jan 31
- Add support for 16 and 32-bit indices for SPU / BulletMultiThreaded version.
2008 Jan 29
- Added COLLADA Physics export/serialization/snapshot from any Bullet btDynamicsWorld. Saving the physics world into a text .xml file is useful for debugging etc.
2008 Jan 23
- Added Stan Melax Convex Hull utility library in Extras/ConvexHull. This is useful to render non-polyhedral convex objects, and to simplify convex polyhedra.
2008 Jan 14
- Add support for batch raycasting on SPU / BulletMultiThreaded
2007 Dec 16
- Added btRigidBodyConstructionInfo, to make it easier to set individual setting (and leave other untouched) during rigid body construction.
Thanks Vangelis Kokkevis for pointing this out.
- Fixed memoryleak in the ConstraintDemo and Raytracer demo.
- Fixed issue with clearing forces/gravity at the end of the stepSimulation, instead of during internalSingleStepSimulation.
Thanks chunky for pointing this out: http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1780
- Disabled additional damping in rigid body by default, but enable it in most demos. Set btRigidBodyConstructionInfo m_additionalDamping to true to enable this.
- Removed obsolete QUICKPROF BEGIN/END_PROFILE, and enabled BT_PROFILE. Profiling is enabled by default (see Bullet/Demos/OpenGL/DemoApplication.cpp how to use this).
User can switch off profiling by enabling define BT_NO_PROFILE in Bullet/src/btQuickprof.h.
2007 Dec 14
- Added Hello World and BulletMultiThreaded demos
- Add portable version of BulletMultiThreaded, through SequentialThreadSupport (non-parallel but sharing the same code-path)
- Add Cmake support for AllBulletDemos
2007 Dec 11
- Moved the 'btRigidBody::clearForce' to the end of the stepSimulation, instead of in each substep.
See discussion http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1601
- Added btConvexPlaneCollisionAlgorithm, makes planes perform better, and prevents tunneling
Thanks Andy O'Neil for reporting the performance/functionality issue
- Fixes for IBM Cell SDK 3.0
Thanks to Jochen Roth for the patch.
2007 Dec 10
- Fixes in btHeightfieldTerrainShape
Thanks to Jay Lee for the patch.
2007 Dec 9
- Only update aabb of active objects
Thanks Peter Tchernev for reporting (http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1764 )
- Added workaround to compile libxml under Visual Studio 2008 Beta 2
- Make glui compile under MSVC 9.0 beta (vsnprintf is already defined)
2007 Dec 6
- Added DynamicControlDemo, showing dynamic control through constraint motors
Thanks to Eddy Boxerman
- Add support for generic concave shapes for convex cast.
- Added convex cast query to collision world.
- Added workaround for OpenGL bug in Mac OS X 10.5.0 (Leopard)
- Added concave raycast demo
All above thanks to John McCutchan (JMC)
- Fixed issues that prevent Linux version to compile.
Thanks to Enrico for reporting and patch, see
- Fixed misleading name 'numTriangleIndices' into 'numTriangles'
Thanks Sean Tasker for reporting:
2007 Nov 28:
- Added raycast against trianglemesh. Will be extended to object cast soon.
Thanks John McCutchan (JMC)
- make getNumPoints const correct, add const getPoints().
Thanks Dirk Gregorius
- Bugfix: allow btCollisionObjects (non-btRigidBody) to interact properly with btRigidBody for cache-friendly btSequentialImpulseConstraintSolver.
Thanks Andy O'Neil for pointing this out.
- Bugfix: don't fail if spheres have identical center, use arbitrary separating normal (1,0,0)
Thanks Sean Tasker for reporting! http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1681
2007, November 20
- Added hierarchical profiling
- Fixed memory leak in btMultiSapBroadphase,
- Fixed hash function (typo, should use 2 proxies)
Thanks to Stephen (shatcher) for reporting and fixes! http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1696
2007 Nov 11
- Fixed parallel solver (BulletMultiThreaded) friction issue
- Terminate Win32 Threads when closing the CcdPhysicsDemo (when USE_PARALLEL_SOLVER/USE_PARALLEL_DISPATCHER is defined)
2007 Nov 6
- Added support for 16-bit indices for triangle meshes
- Added support for multiple mesh parts using btBvhTriangleMeshShape.
Thanks to Tim Johansson
2007 Oct 22
- All memory allocations go through btAlignedAlloc/btAlignedFree. User can override this to verify memory leaks
- added a few more demos to AllBulletDemos
- fix for one of the constructors of btHingeConstraint
Thanks Marcus Hennix
2007 Oct 20
- included glui, a GLUT/OpenGL based toolkit for some graphical user elements
Removed dynamic_cast from glui, to allow linkage without rtti
- added Box2D framework using glui, allowing all demos to run within one executable
Thanks Erin Catto for the FrameWork skeleton (http://www.box2d.org)
2007 Ocy 17
- Allow user to pass in their own memory (stack and pool) allocators, through collisionConfiguration. See demos how to use this
2007 Oct 14
- Included working version of Cell SPU parallel optimized version for Libspe2 SPU task scheduler.
This version compiles and runs on Playstation 3 Linux and IBM CellBlade, see BulletSpuOptimized.pdf for build instructions
(Official Playstation 3 developers can request a SPURS version through Sony PS3 Devnet.)
Thanks to IBM 'Extreme Blue' project for the contribution
http://www-913.ibm.com/employment/us/extremeblue/
Thanks Minh Cuong Tran, Benjamin Hoeferlin, Frederick Roth and Martina Huellmann
for various contributions to get this initial Libspe2 parallel version up and running.
2007 Oct 13
- made 'btCollisionShape::calculateLocalInertia' const
Thanks to cgripeos, see http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1514
- applied a large patch to remove warnings
Thanks to Enrico, see http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1568
- removed SSE includes, added #incude <string.h> for memset in Extras/quickstep, thanks Eternl Knight
2007 Oct 11
- added Hashed Overlapping Pair Cache, recommended by Pierre Terdiman. It works like a charm, thanks Pierre and Erin Catto (code from Box2D)
- modified some margins inside btBoxShape, btCylinderShape and btSphereShape
- added cone debug rendering (for cones with x, y and z up-axis)
- added improvements for optional Extra/quickstep, thanks to Remotion
- some performance improvements for Bullet constraint solver
2007 Sept 28
- upgraded GIMPACT to version 0.3
Thanks to Francisco Leon
2007 Sept 27
- added contribution from IBM Extreme Blue project for Libspe2 support. This allow to execute BulletMultiThreaded on Cell SPU under PS3 Linux and Cell Blade. See http://www-913.ibm.com/employment/us/extremeblue
Thanks to Minh Cuong Tran, Frederick Roth, Martina Heullmann and Benjamin Hoeferlin.
2007 Sept 13
- Improved btGenericD6Constraint. It can be used to create ragdolls (similar to the new btConeTwistConstraint). See GenericJointDemo
- Added support for Bullet constraints in the optional Extras/quickstep ODE solver. See CcdPhysicsDemo, enable #COMPARE_WITH_QUICKSTEP and add libquickstep to the dependencies.
For both patches/improvements thanks Francisco Leon/projectileman
2007 Sept 10
- removed union from btQuadWordStorage, it caused issues under certain version of gcc/Linux
2007 Sept 10
- Reverted constraint solver, due to some issues. Need to review the recent memory allocation changes.
- Fixed issue with kinematic objects rotating at low speed: quaternion was de-normalized, passing value > 1 into acosf returns #IND00 invalid values
- 16 byte memory alignment for BVH serialization
- memory cleanup for btPoolAllocator
2007 Sept 9
- Added serialization for BVH/btBvhTriangleMeshShape, including endian swapping. See ConcaveDemo for an example.
Thanks to Phil Knight for the contribution.
- Fixed issues related to stack allocator/compound collision algorithm
Thanks Proctoid, http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=18&t=1460
- Increase some default memory pool settings, and added a fallback for the constraints solver to use heap memory
- Removed accidential testing code in btScalar.h related to operator new.
- Enable btAxis3Sweep and bt32BitAxis3Sweep to be linked in at the same time, using template
2007 Sept 7
- Replaced several dynamic memory allocations by stack allocation and pool allocations
- Added branch-free quantized aabb bounding box overlap check, works better on Playstation 3 and XBox 360
Thanks to Phil Knight. Also see www.cellperformance.com for related articles
- Collision algorithms and settings for the memory/stack allocator can be done using btDefaultCollisionConfiguration
This is an API change. See demos how to modify existing implementations with a one-liner.
- Register several collision algorithms by default (sphere-sphere, sphere-box, sphere-triangle)
- Use other traveral method for BVH by default, this improves triangle mesh collision performance.
2007 Aug 31
- fixed MSVC 6 build
Thanks Proctoid, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1375
- fixed double precision build issues
Thanks Alex Silverman, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1434
2007 Aug 24
- fixed bug in btMatrix3x3::transposeTimes(const btMatrix3x3& m) const. Luckily it wasn't used in core parts of the library (yet).
Thanks to Jay Lee
2007 Aug 15
- fixed bug in Extras/GIMPACT 0.2 related to moving triangle meshes
Thanks Thomas, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1368
2007 Aug 14
- added parallel constraint solver. Works on Playstation 3 Cell SPU and multi core (Win Threads on PC and XBox 360).
See Extras/BulletMultiThreaded for SpuSolverTask subfolder and SpuParallelSolver.cpp
Thanks Marten Svanfeldt (Starbreeze Studios)
- fixed some bugs related to parallel collision detection (Extras/BulletMultiThreaded)
Thanks Marten Svanfeldt (Starbreeze Studios)
2007 Aug 2
- added compound and concave-convex (swapped) case for BulletMultiThreaded collision detection, thanks to Marten Svanfeldt
- refactored broadphase and overlapping pair cache. This allows performance improvement by combining multiple broadphases. This helps add/remove of large batches of objects and large worlds. See also Pierre Terdiman forum topic:
http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
2007 July 27
- added Ragdoll Demo
Thanks to Marten Svanfeldt (Starbreeze Studios)
- added Vector Math library for SIMD 3D graphics linear algebra (vector, matrix, quaternion)
See Bullet/Extras/vectormathlibrary
Supports SIMD SSE, PowerPC PPU and Cell SPU (including PS3 Linux and CellBlade), as well as generic portable scalar version
Will be used to improve BulletMultiThreaded performance
Open Sourced by Sony Computer Entertainment Inc. under the new BSD license
- added SIMD math library
4-way SIMD for common math functions like atan2f4, cosf4, floorf4, fabsf4, rsqrtf4 etc. Used by Vector Math library under PPU and SPU.
Supports PowerPC (PPU) and Cell SPU, including PS3 Linux and CellBlade.
See Bullet/Extras/simdmathlibrary
Open sourced by Sony Computer Entertainment Inc. under the new BSD license
2007 July 25
- added several patches: per-rigidbody sleeping threshold. added Assert to prevent deletion of rigidbody while constraints are still pointing at it
Thanks to Marten Svanfeldt (Starbreeze Studios)
2007 July 13
- fixed relative #include paths again. We can't use "../" relative paths: some compilers choke on it (it causes extreme long paths)
Within the libraries, we always need to start with "BulletCollision/" or "BulletDynamics/ or "LinearMath/"
2007 July 10
- Updated Bullet User Manual
2007 July 5
- added btConeTwistConstraint, especially useful for ragdolls. See Demos/RagdollDemo
Thanks to Marten Svanfeldt (Starbreeze Studios)
2007 June 29
- btHeightfieldTerrainShape: Added heightfield support, with customizations
- Upgraded to GIMPACT 0.2, see Extras/GIMPACT and MovingConcaveDemo
- Several patches from Marten Svanfeldt (Starbreeze Studios)
Improved collision filtering (in broadphase and rigidbody)
Improved debug rendering
Allow to set collision filter group/mask in addRigidBody
2007 June 15
- Changed btAlignedObjectArray to call copy constructor/replacement new for duplication, rather then assignment operator (operator=).
2007 June 11
- Added multi-threading. Originally for Playstation 3 Cell SPU, but the same code can run using Win32 Threads using fake DMA transfers (memcpy)
Libspe2 support for Cell Blade / PS3 Linux is upcoming
See Extras/BulletMultiThreaded. Usage: replace btCollisionDispatcher by btSpuGatheringCollisionDispatcher
- Added managed Bullet library, entirely rewritten in C# for Windows and XBox 360 XNA
See Extras/BulletX
Thanks to KleMiX, aka Vsevolod Klementjev
2007 May 31
- sign-bit went wrong in case of 32-bit broadphase, causing quantization problems.
Thanks DevO for reporting.
2007 May 23
- Fixed quantization problem for planar triangle meshes in btOptimizedBvh
Thanks Phil Knight for reporting and helping to fix this bug.
2007 May 20
- btAxisSweep3: Fixed a bug in btAxisSweep3 (sweep and prune) related to object removal. Only showed up when at least one btStaticPlaneShape was inserted.
Thanks tbp for more details on reproducing case.
- btAxisSweep3: Fixed issue with full 32bit precision btAxisSweep3 (define BP_USE_FIXEDPOINT_INT_32), it used only 0xffff/65536 for quantization instead of full integer space (0xffffffff)
- btRaycastVehicle: Added 'getForwardVector' and getCurrentSpeedKmHour utility functions
- Fixed local scaling issues (btConvexTriangleMeshShape, btBvhTriangleMeshShape, removed scaling from btMatrix3x3).
Thanks Volker for reporting!
- Added second filename search, so that starting BspDemo and ConvexDecompositionDemo from within Visual Studio (without setting the starting path) still works
2007 April 22
- Added braking functionality to btRaycastVehicle
- Removed tons of warnings, under MSVC 2005 compilation in -W4
2007 March 21
- Fixed issues: comma at end of enum causes errors for some compilers
- Fixed initialization bug in LocalRayResult ( m_localShapeInfo(localShapeInfo) )
2007 March 20
- Added refit tree to quantized stackless tree, and updated ConcaveDemo as example.
2007 March 17
- Added constraint solver optimizations, avoiding cross products during iterations, and gather rigidbody/constraint info in contiguous memory (btSolverBody/btSolverConstraint)
- These optimizations don't give large benefit yet, but it has good potential. Turned on by default. Can be switched off using solver->setSolverMode(SOLVER_RANDMIZE_ORDER).
- Enabled anti-jitter for rigid bodies. This is experimental, and can be switched off by setting a global (it is experimental so no proper interface) gJitterVelocityDampingFactor = 1.0;
- Fixed bug in islandmanifold.heapSort(btPersistentManifoldSortPredicate()); , thanks Noehrgel for reporting this (affected Sun Solaris)
2007 March 12
- Added compile-time toggle between on 16-bit and 32-bit fixed-point SAP broadphase.
This allows the number of bodies to exceed 32767
- Enable useQuantizedAabbCompression on btTriangleMesh, see ColladaDemo
2007 March 8
- Fixed bug in constraint/island sorting (caused by replacing STL by dedicated btAlignedObjectArray with heapSort)
Thanks Clemens Unterkofler for pointing this out!
2007 March 6
- removed STL from the Bullet library: replace std::vector by btAlignedObjectArray. Also removed the std::set for overlapping pair set, and turned it into an overlapping pair array. The SAP only adds objects, never removed. Removal is postponed for during traversal of overlapping pairs (duplicates and non-overlapping pairs are removed during that traversal).
- added heap sort and binary search/linear search to btAlignedObjectArray
- fixed wrong cast, thanks Hamstray, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1015
2007 Feb 25
- Improved performance of convex collision shapes, cache local AABB instead of recomputation. This fixes issue with very slow performance in larger .bsp levels
2007 Feb 24
- Added compressed/quantized AABB tree, 16 bytes per node, while supporting 32-bit (triangle) indices.
Should be faster and smaller then original version (quantized aabb check is done in integer space)
Original aabb tree nodes are still supported. They are 44 bytes, with full floating point precision and additional subPart index.
- added meter-unit scaling support in ColladaConverter.cpp
2007 Feb 21
- Build system: updated bullet.pc.in library names
- Updated EPA comparison integration (missing parameter)
2007 Jan 04
- fixed optimized AABB tree building: in some cases the tree building fails due to unbalanced trees, which generated stack overflow
2006 Dec 15
- added contribution to allow double precision collision detection/dynamics. Define BT_USE_DOUBLE_PRECISION in your project and libraries that include Bullet
2006 Dec 14
- merged contact and non-contact constraint solving into one loop, will improve stability of jointed bodies during collisions
- added first draft for hingeConstraint motor
2006 Dec 8, Erwin Coumans
- preparation for SIMD: added btAlignedAllocator and btAlignedObjectArray, to replace stl std::vector, same interface, but compatible with 16 byte alignment
- cleaned up dependencies in autogenerated msvc projectfiles
- aligned btVector3 on 16 bytes boundary, under win32. see if developers will come up with problems
2006 Dec 04, Erwin Coumans
Added btNearCallback. This is similar to Open Dynamics Engine (ODE) dNearCallback, but important differences:
- contact points are persistent (lifetime more then one frame, for warmstarting/incremental contact point management)
- continuous collision detection, time of impact
Added btRigidBody::isInWorld(), returns true if btRigidBody is inside a btCollisionWorld/btDynamicsWorld derived class
Added angularFactor to btRigidbody, this helps some character control (no angular impulse applied)
2006 Nov 28
Moved StackAlloc from EPA into LinearMath/btStackAlloc
renamed internal class ConcaveShape into btConcaveShape
added btHeightfieldTerrainShape (not completed yet)
2006 Nov 15 Nathanael Presson
Added EPA penetration depth algorithm, Expanding Polytope Algorithm
Added Pierre Terdiman penetration depth comparison/test DEMO
Fixed Bullet's Minkowski sampling penetration depth solver
Contributed by Nathanael Presson
2006 Nov 11 Francisco León Nájera
Added GIMPACT trimesh collision detection: concave versus concave,
Contributed by Francisco León Nájera
2006 Nov 2
Minor refactoring: btCollisionObject changes from struct into class, added accessor methods
Force use of btMotionState to synchronize graphics transform, disabled old btRigidBody constructor that accepts btTransform
Renamed treshold into threshold throughout the code
2006 Oct 30
Enable decoupling of physics and graphics framerate using interpolation and internal fixed timestep, based on btMotionState
Enabled raycast vehicle demo (still needs tuning)
Refresh contact points, even when they are already persistent.
Fixed debugDraw colors (thanks pc0de for reporting)
Use Dispatcher in ConcaveConvexCollisionAlgorithm (so it uses the registered collision algorithm, not hardcoded convexconcave)
Improved performance of constraint solver by precalculating the cross product/impulse arm
Added collision comparison code: ODE box-box, also sphere-triangle
Added safety check into GJK, and an assert for AABB's that are very large
Fixed kinematic support (deriving velocities for animated objects)
Updated comparison/optional quickstep solver in Extras
UserCollisionAlgorithm demonstrates btTriangleMesh usage (easier trimesh compared to index array version)
Removed scaling from btTransform (we only want to deal with rigid transforms)
2006 Oct 4
Fixed minor leak in btOptimizeBVH
Cleanup of btRigidBody construction
added getW() in btQuaternion
assert when setLinearVelocity is called on btRigidBody
renamed projectfile library from collada-dom to colladadom (to make VC6 happy)
2006 Sept 27
Big Refactoring: renamed and moved files, create a replacement for CcdPhysicsEnvironment/CcdPhysicsController.
All Bullet classes in LinearMath, BulletCollision and BulletDynamics start with bt, and methods start with lowercase.
Moved classes into src folder, which is the only include folder needed.
Added 2 headerfiles in src: btBulletCollisionCommon.h and btBulletDynamicsCommon.h
2006 Sept 23
Fixed 2 bugs, causing crashes when removing objects. Should do better unit-testing. UnionFind and 3D SAP were involved.
2006 Sept 19
Allow programmable friction and contact solver model. User can register their own functions for several interaction types.
Improved performance, and removed hardcoded maximum overlaps (switched from C-array to stl::set)
2006 Sept 16
Added Bullet 2.0 User Manual
Allow registration of custom user collision algorithms
2006 Sept 10
Started cleaning up demos
2006 Sept 4
Fixed concave collision bug (caused instability/missing collisions in meshes/compounds)
Fixed memoryleak in OptimizedBvh, added RayTestSingle to CollisionWorld
Prepared for VehicleDemo
Increased Performance (island generation for sleeping objects took too much time)
Better COLLADA 1.4.1 physics conformance in ColladaDemo
2006 August 11
Added Quake BspDemo
Improved CCD for compound and non-convex objects
2006 August 10
Added per-triangle material (friction/restitution) support for non-convex meshes. See ConcaveDemo for usage.
2006 August 9
Added CMake support (see http://cmake.org)
This can autogenerate makefiles, projectfiles cross platform (including MacOS X Xcode )
Just run cmake . in the root folder and it will autogenerate build files
2006 July 26 Erwin Coumans
Upgraded to COLLADA-DOM 1.4.1, latest SVN version
ColladaDemo can export snapshots to .dae
2006 July 24 Erwin Coumans
Added Compound CollisionShape support
(this is still low performance -> requires stackless tree-versus-tree traversal for better performance)
2006 July 15 Erwin Coumans
Added initial support for Parallel execution (collision detection, constraint solving)
See ParallelPhysicsEnvironment in Extras\PhysicsInterface\CcdPhysics
2006 July 10 Erwin Coumans
Added MacOS X support (some build issues mainly)
2006 July 5 Erwin Coumans
Improved COLLADA 1.4 physics import, both COLLADA-DOM and FCollada
2006 June 29 Erwin Coumans
Refactoring of the broadphase
Moved some optional files to Extras: Algebraic ccd and EPA, quickstep
Moved the limits on bodies/overlap to 32k and 65k
2006 June 25 Erwin Coumans
Added basic Collision Filtering, during broadphase
Allow adding meshes to the TriangleIndexVertexArray,
(input for TriangleMeshShape)
Preparation for CompoundShape
2006 June 19 Erwin Coumans
Added support for COLLADA Physics Import.
Both jam and Visual Studio can compile ColladaDemo
2006 June 18 Dirk Gregorius <dirk@dirkgregorius.de>
Started implementing Generic6DOF joint and setup basic interface
2006 June 17 Frank Richter <resqu@gmx.ch>
Bumped version in configure.ac to 1.5.6 (assuming that "1.5f" is
the next version released).
Updated files in mk/autoconf and mk/jam with copies from CS; fixes a
GLU detection issue on MinGW.
Set msvc/bullet_ico.ico as the default application icon.
Disabled exceptions for gcc builds.
Applied a patch from Michael D. Adams to fix a warning with gcc.
2006 jUNE 16 Erwin Coumans
Constraints now merge simulation islands.
2006 May 24
Improved GJK accuracy, fixed GjkConvexCast issue, thanks to ~MyXa~ for reporting
2006 May 19
Added restitution support
Moved out Friction and Dynamics info from ManifoldPoint (removed logical dependency)
Added a void* m_userPersistentData in ManifoldPoint.
Added a ContactDestroyedCallback, to allow user to handle destruction of m_userPersistentData
2006 May 13
Fixed some bugs in friction / jacobian calculations. Reported by Dirk Gregorius. Thanks!
2006 May 9
Fixed raycasting filtering
Moved repository to SVN at https://svn.sourceforge.net/svnroot/bullet
2006 April 27
Moved raycasting to CollisionWorld, to make it more generic
Added basic CCD option in the CcdCollisionDemo
Fixed 'noResponse' mode, for triggering rigidbodies (useful for Artificial Intelligence queries)
Improved Bullet/ODE sample (in Extras)
2006 April 10
Separating Axis Test (SAT) convex hull collision detector, contribution by Simon Hobbs
Added SIMD SSE Math classes (for above SAT)
Added Mouse picking in CcdPhysicsDemo
Improved penetration depth estimation in MinkowskiPenetrationDepthSolver, both accuracy and performance
Added Hinge constraint
Added quickprof profiling (see http://sourceforge.net/projects/quickprof )
2006 March 21 Frank Richter <resqu@gmx.ch>
Removed VC manifest files.
Removed superfluous "grpplugins" projects.
2006 March 20 Erwin Coumans
Clamped the acculumated impulse rather then intermediate impulse (within the iteration)
Use the persistent contacts for reusing the impulse
Separated friction and normal solving for better stability
Decreased the default number of iterations of the constraint solver from 10 to 4
2006 March 19 Frank Richter <resqu@gmx.ch>
Removed a couple of CSisms from the VC projects.
Fixed VC include & lib paths to go to the Addtional* options
instead the command line arguments.
Added pkgconfig support.
2006 March 14 Frank Richter <resqu@gmx.ch>
Added support for shipped GLUT on MinGW.
Fixed GLUT support on MinGW.
2006 March 13 Frank Richter <resqu@gmx.ch>
Bolted on Jam-based build system.
Generated VC project files.
Fixed GCC warnings.
Fixed Linux build issues.
2006 March 13
Added 3D Sweep and Prune Broadphase Collision Detection, Contribution from Simon Hobbs.
2006 March 2
Minor change in license to ZLib/LibPNG
This makes it legally a bit easier to deploy on Playstation 3
Prepared for more generic constraints, added ConstraintsDemo
2006 Feb 23
Rearranged files and dependencies to allow for easier standalone Collision Detection without Bullet Dynamics.
See Demos/CollisionInterfaceDemo and Extras/ode/ode/test/test_BulletGjk.cpp for examples how to use.
2005 August 6
Bullet 0.2 release with demos, sources, doxygen, draft manual
2005 June 1
First public release of Bullet
... todo: add history
2003 Initial version (continuous collision detection)

View File

@ -1,104 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/Extras
${BULLET_PHYSICS_SOURCE_DIR}/Extras/GIMPACTUtils
${BULLET_PHYSICS_SOURCE_DIR}/Extras/HACD
${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition
${BULLET_PHYSICS_SOURCE_DIR}/Extras/LibXML
${BULLET_PHYSICS_SOURCE_DIR}/Extras/LibXML/include
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
${VECTOR_MATH_INCLUDE}
)
LINK_LIBRARIES(
GLUI GIMPACTUtils HACD ConvexDecomposition OpenGLSupport BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletFileLoader LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
SET(AllBulletDemos_SRCS
Main.cpp
DemoEntries.cpp
../CcdPhysicsDemo/CcdPhysicsDemo.cpp
../BasicDemo/BasicDemo.cpp
../BspDemo/BspDemo.cpp
../BspDemo/BspConverter.cpp
../BspDemo/BspLoader.cpp
../DynamicControlDemo/MotorDemo.cpp
../ConcaveDemo/ConcavePhysicsDemo.cpp
../ConcaveRaycastDemo/ConcaveRaycastDemo.cpp
../ConcaveConvexcastDemo/ConcaveConvexcastDemo.cpp
../ConvexDecompositionDemo/ConvexDecompositionDemo.cpp
../SliderConstraintDemo/SliderConstraintDemo.cpp
../RagdollDemo/RagdollDemo.cpp
../GimpactTestDemo/GimpactTestDemo.cpp
../Raytracer/Raytracer.cpp
../GjkConvexCastDemo/LinearConvexCastDemo.cpp
../ForkLiftDemo/ForkLiftDemo.cpp
../SoftDemo/SoftDemo.cpp
../ConstraintDemo/ConstraintDemo.cpp
../Benchmarks/BenchmarkDemo.cpp
../Box2dDemo/Box2dDemo.cpp
)
IF (WIN32)
ADD_EXECUTABLE(AppAllBulletDemos
${AllBulletDemos_SRCS}
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppAllBulletDemos
${AllBulletDemos_SRCS}
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppAllBulletDemos
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppAllBulletDemos
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
ENDIF(WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppAllBulletDemos
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFile.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/file.obj ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppAllBulletDemos PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppAllBulletDemos PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppAllBulletDemos PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,178 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "DemoEntries.h"
#include "../CcdPhysicsDemo/CcdPhysicsDemo.h"
#include "../BspDemo/BspDemo.h"
#include "../BasicDemo/BasicDemo.h"
#include "../ConcaveDemo/ConcaveDemo.h"
#include "../ConcaveRaycastDemo/ConcaveRaycastDemo.h"
#include "../ConcaveConvexcastDemo/ConcaveConvexcastDemo.h"
#include "../ConvexDecompositionDemo/ConvexDecompositionDemo.h"
#include "../DynamicControlDemo/MotorDemo.h"
#include "../SliderConstraintDemo/SliderConstraintDemo.h"
#include "../RagdollDemo/RagdollDemo.h"
#include "../GimpactTestDemo/GimpactTestDemo.h"
#include "../Raytracer/Raytracer.h"
#include "../GjkConvexCastDemo/LinearConvexCastDemo.h"
#include "../ForkLiftDemo/ForkLiftDemo.h"
#include "../ConstraintDemo/ConstraintDemo.h"
//#include "../Benchmarks/BenchmarkDemo.h"
#include "../SoftDemo/SoftDemo.h"
//#include "../Box2dDemo/Box2dDemo.h"
#include "GLDebugFont.h"
#include "GlutStuff.h"//OpenGL stuff
extern int gNumAlignedAllocs;
extern int gNumAlignedFree;
extern int gTotalBytesAlignedAllocs;
class btEmptyDebugDemo : public GlutDemoApplication
{
public:
btEmptyDebugDemo()
{
}
virtual void clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float xOffset = 10.f;
float yStart = 20.f;
float yIncr = 20.f;
char buf[124];
glColor3f(0, 0, 0);
setOrthographicProjection();
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"gNumAlignedAllocs= %d",gNumAlignedAllocs);
GLDebugDrawString(xOffset,yStart,buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree);
GLDebugDrawString(xOffset,yStart,buf);
yStart += yIncr;
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree);
GLDebugDrawString(xOffset,yStart,buf);
yStart += yIncr;
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
glRasterPos3f(xOffset,yStart,0);
sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs);
GLDebugDrawString(xOffset,yStart,buf);
yStart += yIncr;
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
glFlush();
glutSwapBuffers();
}
virtual void initPhysics() {}
static DemoApplication* Create()
{
btEmptyDebugDemo* demo = new btEmptyDebugDemo();
demo->myinit();
return demo;
}
};
btDemoEntry g_demoEntries[] =
{
// {"Box2dDemo",Box2dDemo::Create},
{"ForkLift Demo",ForkLiftDemo::Create},
{"Dynamic Control Demo",MotorDemo::Create},
{"ConstraintDemo",ConstraintDemo::Create},
{"Ragdoll Demo",RagdollDemo::Create},
{"Basic Demo", BasicDemo::Create},
{"CcdPhysicsDemo", CcdPhysicsDemo::Create},
{"Convex Decomposition",ConvexDecompositionDemo::Create},
{"Concave Moving", GimpactConcaveDemo::Create},
{"ConcaveDemo",ConcaveDemo::Create},
{"Concave Convexcast Demo",ConcaveConvexcastDemo::Create},
{"SoftBody Cluster Collide1",SoftDemo19::Create},
{"SoftBody Ropes Attach",SoftDemo4::Create},
{"SoftBody Cloth Attach",SoftDemo5::Create},
{"SoftBody Cloth",SoftDemo0::Create},
// {"SoftBody Volume",SoftDemo2::Create},
{"SoftBody Pressure",SoftDemo1::Create},
{"SoftBody Cluster Car",SoftDemo24::Create},
{"SoftBody Cluster Robot",SoftDemo25::Create},
// {"SoftBody Ropes",SoftDemo3::Create},
{"SoftBody Sticks",SoftDemo6::Create},
{"SoftBody Collide",SoftDemo7::Create},
{"SoftBody Collide2",SoftDemo8::Create},
// {"SoftBody Collide3",SoftDemo9::Create},
// {"SoftBody Impact",SoftDemo10::Create},
{"SoftBody Aero",SoftDemo11::Create},
{"SoftBody Friction",SoftDemo12::Create},
// {"SoftBody Torus",SoftDemo13::Create},
// {"SoftBody Torus Match",SoftDemo14::Create},
// {"SoftBody Bunny",SoftDemo15::Create},
// {"SoftBody Bunny Match",SoftDemo16::Create},
{"SoftBody Init Cutting",SoftDemo17::Create},
// {"SoftBody Cluster Deform",SoftDemo18::Create},
// {"SoftBody Cluster Collide2",SoftDemo20::Create},
// {"SoftBody Cluster Socket",SoftDemo21::Create},
{"SoftBody Cluster Hinge",SoftDemo22::Create},
{"SoftBody Cluster Combine",SoftDemo23::Create},
// {"SoftBody Cluster Stack Soft",SoftDemo26::Create},
{"SoftBody Cluster Stack Mixed",SoftDemo27::Create},
{"SoftBody TetGen Tetrahedral Cube",SoftDemo28::Create},
{"SoftBody TetGen Tetrahedral Bunny",SoftDemo29::Create},
// {"SliderConstraint",SliderConstraintDemo::Create},
// {"ConcaveRaycastDemo",ConcaveRaycastDemo::Create},
//{"BspDemo", BspDemo::Create},
// {"Raytracer Test",Raytracer::Create},
// {"GjkConvexCast",LinearConvexCastDemo::Create},
// {"Benchmark 3000 FALL",BenchmarkDemo1::Create},
// {"Benchmark 1000 STACK",BenchmarkDemo2::Create},
// {"Benchmark 136 RAGDOLLS",BenchmarkDemo3::Create},
// {"Benchmark 1000 CONVEX",BenchmarkDemo4::Create},
// {"Benchmark Mesh-Prim",BenchmarkDemo5::Create},
// {"Benchmark Mesh-Convex",BenchmarkDemo6::Create},
// {"Benchmark Raycast",BenchmarkDemo7::Create},
{"MemoryLeak Checker",btEmptyDebugDemo::Create},
{0, 0}
};

View File

@ -1,34 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_DEMO_ENTRIES_H
#define BT_DEMO_ENTRIES_H
class DemoApplication;
typedef DemoApplication* DemoCreateFcn();
struct btDemoEntry
{
const char *name;
DemoCreateFcn *createFcn;
};
extern btDemoEntry g_demoEntries[];
#endif //BT_DEMO_ENTRIES_H

View File

@ -1,574 +0,0 @@
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
#include "glui/GL/glui.h"
#include "LinearMath/btScalar.h"
#include "LinearMath/btMinMax.h"
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
#include "DemoApplication.h"
#include "DemoEntries.h"
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
#include "BulletSoftBody/btSoftBodyHelpers.h"
#include "GLDebugDrawer.h"
static GLDebugDrawer dDebugDraw2;
#include "LinearMath/btQuickprof.h"
namespace
{
int testIndex=1;
int testSelection=0;
btDemoEntry* entry;
DemoApplication* demo;
int iterationCount;
int width;
int height;
int framePeriod;//todo: test if this value should be 0
int mainWindow;
GLUI *glui;
//float hz;
float viewZoom=20.f;
float viewX;
float viewY;
int tx, ty, tw, th;
int gDrawAabb;
int gWireFrame;
int gDrawNormals;
int gHelpText;
int gDebugConstraints;
int gDebugContacts;
int gDrawTextures=1;
int gDrawShadows=0;
int gDrawClusters=0;
int gDebugNoDeactivation;
int gUseWarmstarting;
int gRandomizeConstraints;
int gUseSplitImpulse;
float gErp;
float gSlop;
float gErp2;
float gWarmStartingParameter;
}
void setDefaultSettings()
{
viewX = 0.0f;
viewY = 0.0f;
framePeriod = 6;//16;//16;//todo: test if this value should be 0
width = 1280;
height = 768;//480;
iterationCount = 10;
gDrawAabb=0;
gDrawNormals=0;
gWireFrame=0;
gDebugContacts=0;
//enable constraint debug visualization for first demo, only if user hasn't overridden the setting
if (testSelection>1)
{
gDebugConstraints=0;
} else
{
gDebugConstraints=1;
}
gHelpText = 0;
gDrawTextures=1;
gDrawShadows=0;
gDrawClusters=0;
gDebugNoDeactivation = 0;
gUseSplitImpulse = 1;
gUseWarmstarting = 1;
gRandomizeConstraints = 0;
gErp = 0.2f;
gSlop=0.0f;
gErp2 = 0.81f;
gWarmStartingParameter = 0.85f;
}
void setDefaultSettingsAndSync()
{
setDefaultSettings();
glui->sync_live();
}
void TogglePause()
{
if (demo)
demo->toggleIdle();
}
void ResetScene()
{
if (demo)
demo->clientResetScene();
}
void NextScene()
{
testSelection++;
if (testSelection>1)
{
gDebugConstraints=0;
} else
{
gDebugConstraints=1;
}
if(testSelection>28)
testSelection=0;
if (glui)
glui->sync_live();
}
void SingleSimulationStep()
{
if (demo)
demo->clientMoveAndDisplay();
}
void Resize(int w, int h)
{
width = w;
height = h;
GLUI_Master.get_viewport_area( &tx, &ty, &tw, &th );
glViewport( tx, ty, tw, th );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (demo)
demo->reshape(tw, th);
}
DemoApplication* CreatDemo(btDemoEntry* entry)
{
DemoApplication* demo = entry->createFcn();
btAssert(demo);
if (demo->getDynamicsWorld())
{
demo->getDynamicsWorld()->setDebugDrawer(&dDebugDraw2);
gDrawTextures = demo->getTexturing();
gDrawShadows = demo->getShadows();
if (glui)
glui->sync_live();
}
#ifndef BT_NO_PROFILE
CProfileManager::Reset();
#endif //BT_NO_PROFILE
return demo;
}
/*b2Vec2 ConvertScreenToWorld(int x, int y)
{
b2Vec2 p;
float ratio = float(tw) / float(th);
float u = x / float(tw);
float v = (th - y) / float(th);
p.x = viewZoom * (viewX - ratio) * (1.0f - u) + viewZoom * (ratio + viewX) * u;
p.y = viewZoom * (viewY - 0.1f) * (1.0f - v) + viewZoom * (viewY + 1.9f) * v;
return p;
}
*/
// This is used to control the frame rate (60Hz).
void Timer(int)
{
glutSetWindow(mainWindow);
glutPostRedisplay();
glutTimerFunc(framePeriod, Timer, 0);
}
void SimulationLoop()
{
Resize(width, height);
if (gDrawAabb)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawAabb);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawAabb));
}
if (gWireFrame)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawWireframe);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawWireframe));
}
if (gDrawNormals)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawNormals);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawNormals));
}
if (gHelpText)
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoHelpText));
} else
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_NoHelpText);
}
if (gDebugConstraints)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawConstraints+btIDebugDraw::DBG_DrawConstraintLimits);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawConstraints+btIDebugDraw::DBG_DrawConstraintLimits));
}
if (gDebugContacts)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawContactPoints);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints));
}
demo->setTexturing(0!=gDrawTextures);
demo->setShadows(0!=gDrawShadows);
demo->setDrawClusters(0!=gDrawClusters);
if (gDebugNoDeactivation)
{
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_NoDeactivation);
} else
{
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoDeactivation));
}
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getWorldType() == BT_DISCRETE_DYNAMICS_WORLD)
{
btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld();
discreteWorld->getSolverInfo().m_numIterations = iterationCount;
discreteWorld->getSolverInfo().m_erp = gErp;
discreteWorld->getSolverInfo().m_erp2 = gErp2;
discreteWorld->getSolverInfo().m_linearSlop = gSlop;
discreteWorld->getSolverInfo().m_warmstartingFactor = gWarmStartingParameter;
discreteWorld->getSolverInfo().m_splitImpulse = gUseSplitImpulse;
// btSequentialImpulseConstraintSolver* solver = ((btSequentialImpulseConstraintSolver*) discreteWorld->getConstraintSolver());
if (gUseWarmstarting)
{
discreteWorld->getSolverInfo().m_solverMode |= SOLVER_USE_WARMSTARTING;
} else
{
discreteWorld->getSolverInfo().m_solverMode &= (~SOLVER_USE_WARMSTARTING);
}
if (gRandomizeConstraints)
{
discreteWorld->getSolverInfo().m_solverMode |= SOLVER_RANDMIZE_ORDER;
} else
{
discreteWorld->getSolverInfo().m_solverMode &= (~SOLVER_RANDMIZE_ORDER);
}
}
if (!demo->isIdle())
{
demo->clientMoveAndDisplay();
}
else
{
demo->displayCallback();
}
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getWorldType()==BT_SOFT_RIGID_DYNAMICS_WORLD)
{
btSoftRigidDynamicsWorld* softWorld = (btSoftRigidDynamicsWorld*)demo->getDynamicsWorld();
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
{
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
{
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
}
}
}
if (testSelection != testIndex)
{
if (testSelection>1)
{
gDebugConstraints=0;
} else
{
gDebugConstraints=1;
}
testIndex = testSelection;
delete demo;
entry = g_demoEntries + testIndex;
demo = CreatDemo(entry);
viewZoom = 20.0f;
viewX = 0.0f;
viewY = 0.0f;
Resize(width, height);
}
}
void RestartScene()
{
delete demo;
entry = g_demoEntries + testIndex;
demo = CreatDemo(entry);
viewZoom = 20.0f;
viewX = 0.0f;
viewY = 0.0f;
Resize(width, height);
}
void Keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit(0);
break;
// Press 'r' to reset.
case 'r':
delete demo;
demo = CreatDemo(entry);
Resize(width,height);
break;
default:
if (demo)
{
demo->keyboardCallback(key,x,y);
}
}
}
void KeyboardSpecialUp(int key, int x, int y)
{
if (demo)
{
demo->specialKeyboardUp(key,x,y);
}
}
void GlutIdleFunc()
{
int current_window, new_window=-1;
current_window = glutGetWindow();
if (GLUI_Master.gluis.first_child() != NULL )
{
new_window = ((GLUI_Main*)GLUI_Master.gluis.first_child())->getMainWindowId();
}
if ( (new_window > 0) && (new_window != current_window ))
{
//--- Window is changed only if its not already the current window ---
glutSetWindow( new_window );
}
if (demo)
demo->moveAndDisplay();
glutSetWindow( current_window );
}
void KeyboardSpecial(int key, int x, int y)
{
if (demo)
{
demo->specialKeyboard(key,x,y);
}
}
void Mouse(int button, int state, int x, int y)
{
if (demo)
demo->mouseFunc(button,state,x,y);
}
void MouseMotion(int x, int y)
{
demo->mouseMotionFunc(x,y);
}
#ifdef BT_USE_FREEGLUT
#include "GL/freeglut_ext.h"
#endif
int main(int argc, char** argv)
{
//#define CHECK_FPU_EXCEPTIONS 1
#ifdef CHECK_FPU_EXCEPTIONS
int cw = _control87(0, 0);
// Set the exception masks off, turn exceptions on
cw &= ~(EM_ZERODIVIDE | EM_INVALID);
printf("control87 = %#x\n", cw);
// Set the control word
_control87(cw, MCW_EM);
#endif //CHECK_FPU_EXCEPTIONS
setDefaultSettings();
int bulletVersion = btGetVersion();
printf("Bullet version %d\n",bulletVersion);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(width, height);
mainWindow = glutCreateWindow("http://bulletphysics.com");
#ifdef BT_USE_FREEGLUT
glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif
entry = g_demoEntries + testIndex;
demo = CreatDemo(entry);
glutDisplayFunc(SimulationLoop);
GLUI_Master.set_glutReshapeFunc(Resize);
GLUI_Master.set_glutKeyboardFunc(Keyboard);
GLUI_Master.set_glutSpecialFunc(KeyboardSpecial);
GLUI_Master.set_glutIdleFunc(GlutIdleFunc);
GLUI_Master.set_glutSpecialUpFunc(KeyboardSpecialUp);
GLUI_Master.set_glutMouseFunc(Mouse);
glutMotionFunc(MouseMotion);
glui = GLUI_Master.create_glui_subwindow( mainWindow,
GLUI_SUBWINDOW_RIGHT );
glui->add_statictext("Tests");
GLUI_Listbox* testList =
glui->add_listbox("", &testSelection);
glui->add_button("Next Scene", 0,(GLUI_Update_CB)NextScene);
glui->add_separator();
GLUI_Spinner* iterationSpinner =
glui->add_spinner("Iterations", GLUI_SPINNER_INT, &iterationCount);
iterationSpinner->set_int_limits(1, 250);
/* GLUI_Spinner* hertzSpinner =
glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &hz);
hertzSpinner->set_float_limits(5.0f, 200.0f);
*/
glui->add_checkbox("DisableDeactivation", &gDebugNoDeactivation);
glui->add_checkbox("Split Impulse", &gUseSplitImpulse);
GLUI_Spinner* spinner = 0;
spinner = glui->add_spinner("ERP", GLUI_SPINNER_FLOAT, &gErp);
// spinner->set_float_limits(0.f,1.f);
// spinner = glui->add_spinner("ERP2", GLUI_SPINNER_FLOAT, &gErp2);
spinner->set_float_limits(0.f,1.f);
spinner = glui->add_spinner("Slop", GLUI_SPINNER_FLOAT, &gSlop);
spinner->set_float_limits(0.f,1.f);
// spinner = glui->add_spinner("WSP", GLUI_SPINNER_FLOAT,&gWarmStartingParameter);
// spinner->set_float_limits (0.f,1.0);
glui->add_checkbox("Warmstarting", &gUseWarmstarting);
glui->add_checkbox("Randomize Constraints", &gRandomizeConstraints);
glui->add_button("Reset Defaults", 0,(GLUI_Update_CB)setDefaultSettingsAndSync);
glui->add_separator();
GLUI_Panel* drawPanel = glui->add_panel("Debug Draw");
glui->add_checkbox_to_panel(drawPanel, "Help", &gHelpText);
glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb);
glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame);
glui->add_checkbox_to_panel(drawPanel, "Normals", &gDrawNormals);
glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts);
glui->add_checkbox_to_panel(drawPanel, "Constraints", &gDebugConstraints);
glui->add_checkbox_to_panel(drawPanel, "Textures", &gDrawTextures);
glui->add_checkbox_to_panel(drawPanel, "Shadows", &gDrawShadows);
glui->add_checkbox_to_panel(drawPanel, "Clusters", &gDrawClusters);
int testCount = 0;
btDemoEntry* e = g_demoEntries;
while (e->createFcn)
{
testList->add_item(testCount, e->name);
++testCount;
++e;
}
glui->add_separator();
glui->add_button("Toggle Pause", 0,(GLUI_Update_CB)TogglePause);
glui->add_button("Single Step", 0,(GLUI_Update_CB)SingleSimulationStep);
glui->add_button("Reset Scene", 0,(GLUI_Update_CB)ResetScene);
glui->add_button("Restart Scene", 0,(GLUI_Update_CB)RestartScene);
glui->add_separator();
// glui->add_button("Exit", 0,(GLUI_Update_CB)exit);
glui->set_main_gfx_window( mainWindow );
// Use a timer to control the frame rate.
glutTimerFunc(framePeriod, Timer, 0);
glutMainLoop();
return 0;
}

View File

@ -1,34 +0,0 @@
noinst_PROGRAMS=AllBulletDemo
AllBulletDemo_SOURCES=\
../SoftDemo/SoftDemo.cpp \
../ConstraintDemo/ConstraintDemo.cpp \
../ForkLiftDemo/ForkLiftDemo.cpp \
../RagdollDemo/RagdollDemo.cpp \
../BasicDemo/BasicDemo.cpp \
../CcdPhysicsDemo/CcdPhysicsDemo.cpp \
../SliderConstraintDemo/SliderConstraintDemo.cpp \
../ConcaveRaycastDemo/ConcaveRaycastDemo.cpp \
../Raytracer/Raytracer.cpp \
../BspDemo/BspDemo.cpp \
../BspDemo/BspLoader.cpp \
../BspDemo/BspConverter.cpp \
../ConcaveConvexcastDemo/ConcaveConvexcastDemo.cpp \
../ConvexDecompositionDemo/ConvexDecompositionDemo.cpp \
../GimpactTestDemo/GimpactTestDemo.cpp \
../GjkConvexCastDemo/LinearConvexCastDemo.cpp \
../ConcaveDemo/ConcavePhysicsDemo.cpp \
../DynamicControlDemo/MotorDemo.cpp \
DemoEntries.cpp \
DemoEntries.h\
Main.cpp
AllBulletDemo_CXXFLAGS=\
-I@top_builddir@/src \
-I@top_builddir@/Extras/GIMPACTUtils \
-I@top_builddir@/Extras/ConvexDecomposition \
-I@top_builddir@/Extras/HACD \
-I@top_builddir@/Extras \
-I@top_builddir@/Demos/OpenGL \
-I@top_builddir@/Demos/SoftDemo \
$(CXXFLAGS)
AllBulletDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -L../../Extras -lgimpactutils -lconvexdecomposition -lHACD -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lglui @opengl_LIBS@

View File

@ -1,273 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
///create 125 (5x5x5) dynamic object
#define ARRAY_SIZE_X 5
#define ARRAY_SIZE_Y 5
#define ARRAY_SIZE_Z 5
//maximum number of objects (and allow user to shoot additional boxes)
#define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
///scaling of the objects (0.1 = 20 centimeter boxes )
#define SCALING 1.
#define START_POS_X -5
#define START_POS_Y -5
#define START_POS_Z -3
#include "BasicDemo.h"
#include "GlutStuff.h"
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include <stdio.h> //printf debugging
#include "GLDebugDrawer.h"
#include "LinearMath/btAabbUtil2.h"
static GLDebugDrawer gDebugDraw;
///The MyOverlapCallback is used to show how to collect object that overlap with a given bounding box defined by aabbMin and aabbMax.
///See m_dynamicsWorld->getBroadphase()->aabbTest.
struct MyOverlapCallback : public btBroadphaseAabbCallback
{
btVector3 m_queryAabbMin;
btVector3 m_queryAabbMax;
int m_numOverlap;
MyOverlapCallback(const btVector3& aabbMin, const btVector3& aabbMax ) : m_queryAabbMin(aabbMin),m_queryAabbMax(aabbMax),m_numOverlap(0) {}
virtual bool process(const btBroadphaseProxy* proxy)
{
btVector3 proxyAabbMin,proxyAabbMax;
btCollisionObject* colObj0 = (btCollisionObject*)proxy->m_clientObject;
colObj0->getCollisionShape()->getAabb(colObj0->getWorldTransform(),proxyAabbMin,proxyAabbMax);
if (TestAabbAgainstAabb2(proxyAabbMin,proxyAabbMax,m_queryAabbMin,m_queryAabbMax))
{
m_numOverlap++;
}
return true;
}
};
void BasicDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//simple dynamics world doesn't handle fixed-time-stepping
float ms = getDeltaTimeMicroseconds();
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
btVector3 aabbMin(1,1,1);
btVector3 aabbMax(2,2,2);
MyOverlapCallback aabbOverlap(aabbMin,aabbMax);
m_dynamicsWorld->getBroadphase()->aabbTest(aabbMin,aabbMax,aabbOverlap);
if (aabbOverlap.m_numOverlap)
printf("#aabb overlap = %d\n", aabbOverlap.m_numOverlap);
}
renderme();
glFlush();
swapBuffers();
}
void BasicDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing to detect problems
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
glFlush();
swapBuffers();
}
void BasicDemo::initPhysics()
{
setTexturing(true);
setShadows(true);
setCameraDistance(btScalar(SCALING*50.));
///collision configuration contains default setup for memory, collision setup
m_collisionConfiguration = new btDefaultCollisionConfiguration();
//m_collisionConfiguration->setConvexConvexMultipointIterations();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld->setDebugDrawer(&gDebugDraw);
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
///create a few basic rigid bodies
btBoxShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
//groundShape->initializePolyhedralFeatures();
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
{
btScalar mass(0.);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
//add the body to the dynamics world
m_dynamicsWorld->addRigidBody(body);
}
{
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance
btBoxShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);
/// Create Dynamic Objects
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(1.f);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);
float start_x = START_POS_X - ARRAY_SIZE_X/2;
float start_y = START_POS_Y;
float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
for (int k=0;k<ARRAY_SIZE_Y;k++)
{
for (int i=0;i<ARRAY_SIZE_X;i++)
{
for(int j = 0;j<ARRAY_SIZE_Z;j++)
{
startTransform.setOrigin(SCALING*btVector3(
btScalar(2.0*i + start_x),
btScalar(20+2.0*k + start_y),
btScalar(2.0*j + start_z)));
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);
}
}
}
}
}
void BasicDemo::clientResetScene()
{
exitPhysics();
initPhysics();
}
void BasicDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,82 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BASIC_DEMO_H
#define BASIC_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///BasicDemo is good starting point for learning the code base and porting.
class BasicDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
public:
BasicDemo()
{
}
virtual ~BasicDemo()
{
exitPhysics();
}
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
virtual void clientResetScene();
static DemoApplication* Create()
{
BasicDemo* demo = new BasicDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
};
#endif //BASIC_DEMO_H

View File

@ -1,87 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppBasicDemo
main.cpp
BasicDemo.cpp
BasicDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBasicDemo
main.cpp
BasicDemo.cpp
BasicDemo.h
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBasicDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBasicDemo
POST_BUILD
# COMMAND copy /Y ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBasicDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32BasicDemo.cpp
BasicDemo.cpp
BasicDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBasicDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBasicDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBasicDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,5 +0,0 @@
noinst_PROGRAMS=BasicDemo
BasicDemo_SOURCES=BasicDemo.cpp BasicDemo.h main.cpp
BasicDemo_CXXFLAGS=-I@top_builddir@/src -I@top_builddir@/Demos/OpenGL $(CXXFLAGS)
BasicDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -lBulletDynamics -lBulletCollision -lLinearMath @opengl_LIBS@

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BasicDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new BasicDemo();
}
#endif

View File

@ -1,39 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BasicDemo.h"
#include "GlutStuff.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btHashMap.h"
int main(int argc,char** argv)
{
BasicDemo ccdDemo;
ccdDemo.initPhysics();
#ifdef CHECK_MEMORY_LEAKS
ccdDemo.exitPhysics();
#else
return glutmain(argc, argv,1024,600,"Bullet Physics Demo. http://bulletphysics.org",&ccdDemo);
#endif
//default glut doesn't return from mainloop
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,265 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BENCHMARK_DEMO_H
#define BENCHMARK_DEMO_H
#include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btTransform.h"
class btDynamicsWorld;
#define NUMRAYS 500
class btRigidBody;
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
#ifndef USE_GRAPHICAL_BENCHMARK
///empty placeholder
class DemoApplication
{
protected:
btDynamicsWorld* m_dynamicsWorld;
btScalar m_defaultContactProcessingThreshold;
public:
DemoApplication()
:m_defaultContactProcessingThreshold(BT_LARGE_FLOAT)
{
}
virtual void myinit() {}
virtual btDynamicsWorld* getDynamicsWorld()
{
return m_dynamicsWorld;
}
btScalar getDeltaTimeMicroseconds()
{
return 1.f;
}
void renderme() {}
void setCameraDistance(btScalar dist){}
void clientResetScene(){}
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
};
///BenchmarkDemo is provides several performance tests
#define PlatformDemoApplication DemoApplication
#else //USE_GRAPHICAL_BENCHMARK
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#endif //USE_GRAPHICAL_BENCHMARK
class BenchmarkDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btAlignedObjectArray<class RagDoll*> m_ragdolls;
btBroadphaseInterface* m_overlappingPairCache;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
int m_benchmark;
void createTest1();
void createTest2();
void createTest3();
void createTest4();
void createTest5();
void createTest6();
void createTest7();
void createWall(const btVector3& offsetPosition,int stackSize,const btVector3& boxSize);
void createPyramid(const btVector3& offsetPosition,int stackSize,const btVector3& boxSize);
void createTowerCircle(const btVector3& offsetPosition,int stackSize,int rotSize,const btVector3& boxSize);
void createLargeMeshBody();
class SpuBatchRaycaster* m_batchRaycaster;
class btThreadSupportInterface* m_batchRaycasterThreadSupport;
void castRays();
void initRays();
public:
BenchmarkDemo(int benchmark)
:m_benchmark(benchmark)
{
}
virtual ~BenchmarkDemo()
{
exitPhysics();
}
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
};
class BenchmarkDemo1 : public BenchmarkDemo
{
public:
BenchmarkDemo1()
:BenchmarkDemo(1)
{
}
static DemoApplication* Create()
{
BenchmarkDemo1* demo = new BenchmarkDemo1;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo2 : public BenchmarkDemo
{
public:
BenchmarkDemo2()
:BenchmarkDemo(2)
{
}
static DemoApplication* Create()
{
BenchmarkDemo2* demo = new BenchmarkDemo2;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo3 : public BenchmarkDemo
{
public:
BenchmarkDemo3()
:BenchmarkDemo(3)
{
}
static DemoApplication* Create()
{
BenchmarkDemo3* demo = new BenchmarkDemo3;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo4 : public BenchmarkDemo
{
public:
BenchmarkDemo4()
:BenchmarkDemo(4)
{
}
static DemoApplication* Create()
{
BenchmarkDemo4* demo = new BenchmarkDemo4;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo5 : public BenchmarkDemo
{
public:
BenchmarkDemo5()
:BenchmarkDemo(5)
{
}
static DemoApplication* Create()
{
BenchmarkDemo5* demo = new BenchmarkDemo5;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo6 : public BenchmarkDemo
{
public:
BenchmarkDemo6()
:BenchmarkDemo(6)
{
}
static DemoApplication* Create()
{
BenchmarkDemo6* demo = new BenchmarkDemo6;
demo->myinit();
demo->initPhysics();
return demo;
}
};
class BenchmarkDemo7 : public BenchmarkDemo
{
public:
BenchmarkDemo7()
:BenchmarkDemo(7)
{
}
static DemoApplication* Create()
{
BenchmarkDemo7* demo = new BenchmarkDemo7;
demo->myinit();
demo->initPhysics();
return demo;
}
};
#endif //BENCHMARK_DEMO_H

View File

@ -1,107 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
IF (USE_GRAPHICAL_BENCHMARK)
IF (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_MULTITHREADED_BENCHMARK)
INCLUDE_DIRECTORIES( ${VECTOR_MATH_INCLUDE} )
LINK_LIBRARIES( OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
ELSE()
LINK_LIBRARIES( OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
ENDIF(USE_MULTITHREADED_BENCHMARK)
IF (WIN32)
ADD_EXECUTABLE(AppBenchmarks
main.cpp
BenchmarkDemo.cpp
BenchmarkDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBenchmarks
main.cpp
BenchmarkDemo.cpp
BenchmarkDemo.h
)
ENDIF ()
IF (WIN32)
IF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBenchmarks
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBenchmarks
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBenchmarks PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBenchmarks PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBenchmarks PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
ENDIF(WIN32)
ELSE (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_MULTITHREADED_BENCHMARK)
INCLUDE_DIRECTORIES( ${VECTOR_MATH_INCLUDE} )
LINK_LIBRARIES(
OpenGLSupport BulletMultiThreaded BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ELSE()
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ENDIF()
ADD_EXECUTABLE(AppBenchmarks
WIN32
../OpenGL/Win32AppMain.cpp
BenchmarkDemo.cpp
BenchmarkDemo.h
Win32BenchmarkDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
ELSE (USE_GRAPHICAL_BENCHMARK)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_MULTITHREADED_BENCHMARK)
LINK_LIBRARIES( BulletMultiThreaded BulletDynamics BulletCollision LinearMath )
ELSE()
LINK_LIBRARIES( BulletDynamics BulletCollision LinearMath )
ENDIF()
ADD_EXECUTABLE(AppBenchmarks
main.cpp
BenchmarkDemo.cpp
)
ENDIF (USE_GRAPHICAL_BENCHMARK)

View File

@ -1,49 +0,0 @@
#define TaruVtxCount 43
#define TaruIdxCount 132
static float TaruVtx[] = {
1.08664f,-1.99237f,0.0f,
0.768369f,-1.99237f,-0.768369f,
1.28852f,1.34412e-007f,-1.28852f,
1.82224f,1.90735e-007f,0.0f,
0.0f,-1.99237f,-1.08664f,
0.0f,0.0f,-1.82224f,
0.0f,-1.99237f,-1.08664f,
-0.768369f,-1.99237f,-0.768369f,
-1.28852f,1.34412e-007f,-1.28852f,
0.0f,0.0f,-1.82224f,
-1.08664f,-1.99237f,1.82086e-007f,
-1.82224f,1.90735e-007f,1.59305e-007f,
-0.768369f,-1.99237f,0.76837f,
-1.28852f,2.47058e-007f,1.28852f,
1.42495e-007f,-1.99237f,1.08664f,
2.38958e-007f,2.70388e-007f,1.82224f,
0.768369f,-1.99237f,0.768369f,
1.28852f,2.47058e-007f,1.28852f,
0.768369f,1.99237f,-0.768369f,
1.08664f,1.99237f,0.0f,
0.0f,1.99237f,-1.08664f,
-0.768369f,1.99237f,-0.768369f,
0.0f,1.99237f,-1.08664f,
-1.08664f,1.99237f,0.0f,
-0.768369f,1.99237f,0.768369f,
1.42495e-007f,1.99237f,1.08664f,
0.768369f,1.99237f,0.768369f,
1.42495e-007f,-1.99237f,1.08664f,
-0.768369f,-1.99237f,0.76837f,
-1.08664f,-1.99237f,1.82086e-007f,
-0.768369f,-1.99237f,-0.768369f,
0.0f,-1.99237f,-1.08664f,
0.768369f,-1.99237f,-0.768369f,
1.08664f,-1.99237f,0.0f,
0.768369f,-1.99237f,0.768369f,
0.768369f,1.99237f,-0.768369f,
0.0f,1.99237f,-1.08664f,
-0.768369f,1.99237f,-0.768369f,
-1.08664f,1.99237f,0.0f,
-0.768369f,1.99237f,0.768369f,
1.42495e-007f,1.99237f,1.08664f,
0.768369f,1.99237f,0.768369f,
1.08664f,1.99237f,0.0f,
};

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BenchmarkDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new BenchmarkDemo(1);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,89 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BenchmarkDemo.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btHashMap.h"
#include <stdio.h>
#ifdef USE_GRAPHICAL_BENCHMARK
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
#define benchmarkDemo benchmarkDemo2
#endif //USE_GRAPHICAL_BENCHMARK
#define NUM_DEMOS 7
#define NUM_TESTS 200
extern bool gDisableDeactivation;
int main(int argc,char** argv)
{
gDisableDeactivation = true;
BenchmarkDemo1 benchmarkDemo1;
BenchmarkDemo2 benchmarkDemo2;
BenchmarkDemo3 benchmarkDemo3;
BenchmarkDemo4 benchmarkDemo4;
BenchmarkDemo5 benchmarkDemo5;
BenchmarkDemo6 benchmarkDemo6;
BenchmarkDemo7 benchmarkDemo7;
BenchmarkDemo* demoArray[NUM_DEMOS] = {&benchmarkDemo1,&benchmarkDemo2,&benchmarkDemo3,&benchmarkDemo4,&benchmarkDemo5,&benchmarkDemo6,&benchmarkDemo7};
const char* demoNames[NUM_DEMOS] = {"3000 fall", "1000 stack", "136 ragdolls","1000 convex", "prim-trimesh", "convex-trimesh","raytests"};
float totalTime[NUM_DEMOS] = {0.f,0.f,0.f,0.f,0.f,0.f,0.f};
#ifdef USE_GRAPHICAL_BENCHMARK
benchmarkDemo.initPhysics();
benchmarkDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
benchmarkDemo.setDebugMode(benchmarkDemo.getDebugMode() | btIDebugDraw::DBG_NoDeactivation);
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.com",&benchmarkDemo);
#else //USE_GRAPHICAL_BENCHMARK
int d;
for (d=0;d<NUM_DEMOS;d++)
{
demoArray[d]->initPhysics();
for (int i=0;i<NUM_TESTS;i++)
{
demoArray[d]->clientMoveAndDisplay();
float frameTime = CProfileManager::Get_Time_Since_Reset();
if ((i % 25)==0)
{
printf("BenchmarkDemo: %s, Frame %d, Duration (ms): %f\n",demoNames[d],i,frameTime);
}
totalTime[d] += frameTime;
if (i==NUM_TESTS-1)
CProfileManager::dumpAll();
}
demoArray[d]->exitPhysics();
}
for (d=0;d<NUM_DEMOS;d++)
{
printf("\nResults for %s: %f",demoNames[d],totalTime[d]*(1.f/NUM_TESTS));
}
#endif //USE_GRAPHICAL_BENCHMARK
return 0;
}

View File

@ -1,22 +0,0 @@
project "AppBenchmarks"
if _OPTIONS["ios"] then
kind "WindowedApp"
else
kind "ConsoleApp"
end
includedirs {"../../src"}
links {
"BulletDynamics","BulletCollision", "LinearMath"
}
language "C++"
files {
"**.cpp",
"**.h",
}

View File

@ -1,370 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BulletCollision/CollisionShapes/btBox2dShape.h"
#include "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h"
#include "GL_DialogDynamicsWorld.h"
#include "GL_DialogWindow.h"
#include "BulletCollision/CollisionShapes/btBox2dShape.h"
#include "BulletCollision/CollisionShapes/btConvex2dShape.h"
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
///create 125 (5x5x5) dynamic object
#define ARRAY_SIZE_X 5
#define ARRAY_SIZE_Y 5
#define ARRAY_SIZE_Z 1
//maximum number of objects (and allow user to shoot additional boxes)
#define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
///scaling of the objects (0.1 = 20 centimeter boxes )
#define SCALING 1
#define START_POS_X -5
#define START_POS_Y -5
#define START_POS_Z -3
#include "Box2dDemo.h"
#include "GlutStuff.h"
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include <stdio.h> //printf debugging
void Box2dDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//simple dynamics world doesn't handle fixed-time-stepping
float ms = getDeltaTimeMicroseconds();
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
}
renderme();
if (m_dialogDynamicsWorld)
m_dialogDynamicsWorld->draw(ms / 1000000.f);
glFlush();
swapBuffers();
}
void Box2dDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing to detect problems
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
if (m_dialogDynamicsWorld)
m_dialogDynamicsWorld->draw(0.f);
glFlush();
swapBuffers();
}
void Box2dDemo::reshape(int w, int h)
{
if (m_dialogDynamicsWorld)
m_dialogDynamicsWorld->setScreenSize(w,h);
PlatformDemoApplication::reshape(w,h);
}
void Box2dDemo::initPhysics()
{
m_dialogDynamicsWorld = new GL_DialogDynamicsWorld();
//m_dialogDynamicsWorld->createDialog(100,110,200,50);
//m_dialogDynamicsWorld->createDialog(100,00,100,100);
//m_dialogDynamicsWorld->createDialog(0,0,100,100);
GL_DialogWindow* settings = m_dialogDynamicsWorld->createDialog(50,0,200,120,"Settings");
GL_ToggleControl* toggle = m_dialogDynamicsWorld->createToggle(settings,"Toggle 1");
toggle = m_dialogDynamicsWorld->createToggle(settings,"Toggle 2");
toggle ->m_active = true;
toggle = m_dialogDynamicsWorld->createToggle(settings,"Toggle 3");
//GL_SliderControl* slider = m_dialogDynamicsWorld->createSlider(settings,"Slider");
GL_DialogWindow* dialog = m_dialogDynamicsWorld->createDialog(0,200,420,300,"Help");
GL_TextControl* txt = new GL_TextControl;
dialog->addControl(txt);
txt->m_textLines.push_back("Mouse to move");
txt->m_textLines.push_back("Test 2");
txt->m_textLines.push_back("mouse to interact");
txt->m_textLines.push_back("ALT + mouse to move camera");
txt->m_textLines.push_back("space to reset");
txt->m_textLines.push_back("cursor keys and z,x to navigate");
txt->m_textLines.push_back("i to toggle simulation, s single step");
txt->m_textLines.push_back("q to quit");
txt->m_textLines.push_back(". to shoot box");
txt->m_textLines.push_back("d to toggle deactivation");
txt->m_textLines.push_back("g to toggle mesh animation (ConcaveDemo)");
txt->m_textLines.push_back("h to toggle help text");
txt->m_textLines.push_back("o to toggle orthogonal/perspective view");
//txt->m_textLines.push_back("+- shooting speed = %10.2f",m_ShootBoxInitialSpeed);
setTexturing(true);
setShadows(true);
setCameraDistance(btScalar(SCALING*50.));
m_cameraTargetPosition.setValue(0,0,0);//0, ARRAY_SIZE_Y, 0);
///collision configuration contains default setup for memory, collision setup
m_collisionConfiguration = new btDefaultCollisionConfiguration();
//m_collisionConfiguration->setConvexConvexMultipointIterations();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVoronoiSimplexSolver* simplex = new btVoronoiSimplexSolver();
btMinkowskiPenetrationDepthSolver* pdSolver = new btMinkowskiPenetrationDepthSolver();
btConvex2dConvex2dAlgorithm::CreateFunc* convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc(simplex,pdSolver);
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(CONVEX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,convexAlgo2d);
m_dispatcher->registerCollisionCreateFunc(BOX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,new btBox2dBox2dCollisionAlgorithm::CreateFunc());
m_broadphase = new btDbvtBroadphase();
//m_broadphase = new btSimpleBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
//m_dynamicsWorld->getSolverInfo().m_erp = 1.f;
//m_dynamicsWorld->getSolverInfo().m_numIterations = 4;
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
///create a few basic rigid bodies
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(150.),btScalar(50.),btScalar(150.)));
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-43,0));
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
{
btScalar mass(0.);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
//add the body to the dynamics world
m_dynamicsWorld->addRigidBody(body);
}
{
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance
btScalar u= btScalar(1*SCALING-0.04);
btVector3 points[3] = {btVector3(0,u,0),btVector3(-u,-u,0),btVector3(u,-u,0)};
btConvexShape* childShape0 = new btBoxShape(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04)));
btConvexShape* colShape= new btConvex2dShape(childShape0);
//btCollisionShape* colShape = new btBox2dShape(btVector3(SCALING*1,SCALING*1,0.04));
btConvexShape* childShape1 = new btConvexHullShape(&points[0].getX(),3);
btConvexShape* colShape2= new btConvex2dShape(childShape1);
btConvexShape* childShape2 = new btCylinderShapeZ(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04)));
btConvexShape* colShape3= new btConvex2dShape(childShape2);
m_collisionShapes.push_back(colShape);
m_collisionShapes.push_back(colShape2);
m_collisionShapes.push_back(colShape3);
m_collisionShapes.push_back(childShape0);
m_collisionShapes.push_back(childShape1);
m_collisionShapes.push_back(childShape2);
//btUniformScalingShape* colShape = new btUniformScalingShape(convexColShape,1.f);
colShape->setMargin(btScalar(0.03));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
/// Create Dynamic Objects
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(1.f);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);
// float start_x = START_POS_X - ARRAY_SIZE_X/2;
// float start_y = START_POS_Y;
// float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
btVector3 x(-ARRAY_SIZE_X, 8.0f,-20.f);
btVector3 y;
btVector3 deltaX(SCALING*1, SCALING*2,0.f);
btVector3 deltaY(SCALING*2, 0.0f,0.f);
for (int i = 0; i < ARRAY_SIZE_X; ++i)
{
y = x;
for (int j = i; j < ARRAY_SIZE_Y; ++j)
{
startTransform.setOrigin(y-btVector3(-10,0,0));
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(0,0,0);
switch (j%3)
{
#if 1
case 0:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape,localInertia);
break;
case 1:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape3,localInertia);
break;
#endif
default:
rbInfo = btRigidBody::btRigidBodyConstructionInfo(mass,myMotionState,colShape2,localInertia);
}
btRigidBody* body = new btRigidBody(rbInfo);
//body->setContactProcessingThreshold(colShape->getContactBreakingThreshold());
body->setActivationState(ISLAND_SLEEPING);
body->setLinearFactor(btVector3(1,1,0));
body->setAngularFactor(btVector3(0,0,1));
m_dynamicsWorld->addRigidBody(body);
body->setActivationState(ISLAND_SLEEPING);
// y += -0.8*deltaY;
y += deltaY;
}
x += deltaX;
}
}
clientResetScene();
}
void Box2dDemo::exitPhysics()
{
delete m_dialogDynamicsWorld;
m_dialogDynamicsWorld = 0;
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
if (m_dynamicsWorld)
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
m_dynamicsWorld = 0;
m_solver = 0;
m_broadphase = 0;
m_dispatcher = 0;
m_collisionConfiguration = 0;
}
void Box2dDemo::mouseFunc(int button, int state, int x, int y)
{
if (!m_dialogDynamicsWorld->mouseFunc(button,state,x,y))
{
DemoApplication::mouseFunc(button,state,x,y);
}
}
void Box2dDemo::mouseMotionFunc(int x,int y)
{
m_dialogDynamicsWorld->mouseMotionFunc(x,y);
DemoApplication::mouseMotionFunc(x,y);
}

View File

@ -1,89 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BOX2D_DEMO_H
#define BOX2D_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class GL_DialogDynamicsWorld;
///Box2dDemo is good starting point for learning the code base and porting.
class Box2dDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
GL_DialogDynamicsWorld* m_dialogDynamicsWorld;
public:
Box2dDemo() : m_dialogDynamicsWorld(0)
{
}
virtual ~Box2dDemo()
{
exitPhysics();
}
virtual void reshape(int w, int h);
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
static DemoApplication* Create()
{
Box2dDemo* demo = new Box2dDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
virtual void mouseFunc(int button, int state, int x, int y);
virtual void mouseMotionFunc(int x,int y);
};
#endif //BOX2D_DEMO_H

View File

@ -1,75 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBox2dDemo
main.cpp
Box2dDemo.cpp
Box2dDemo.h
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBox2dDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBox2dDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32Box2dDemo.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBox2dDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "Box2dDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new Box2dDemo();
}
#endif

View File

@ -1,61 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "Box2dDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btHashMap.h"
class OurValue
{
int m_uid;
public:
OurValue(const btVector3& initialPos)
:m_position(initialPos)
{
static int gUid=0;
m_uid=gUid;
gUid++;
}
btVector3 m_position;
int getUid() const
{
return m_uid;
}
};
int main(int argc,char** argv)
{
GLDebugDrawer gDebugDrawer;
Box2dDemo ccdDemo;
ccdDemo.initPhysics();
ccdDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
#ifdef CHECK_MEMORY_LEAKS
ccdDemo.exitPhysics();
#else
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.com",&ccdDemo);
#endif
//default glut doesn't return from mainloop
return 0;
}

View File

@ -1,207 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BspConverter.h"
#include "BspLoader.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btGeometryUtil.h"
#include <stdio.h>
#include <string.h>
void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
{
{
float playstartf[3] = {0,0,100};
if (bspLoader.findVectorByName(&playstartf[0],"info_player_start"))
{
printf("found playerstart\n");
}
else
{
if (bspLoader.findVectorByName(&playstartf[0],"info_player_deathmatch"))
{
printf("found deatchmatch start\n");
}
}
btVector3 playerStart (playstartf[0],playstartf[1],playstartf[2]);
playerStart[2] += 20.f; //start a bit higher
playerStart *= scaling;
//progressBegin("Loading bsp");
for (int i=0;i<bspLoader.m_numleafs;i++)
{
printf("Reading bspLeaf %i from total %i (%f procent)\n",i, bspLoader.m_numleafs,(100.f*(float)i/float(bspLoader.m_numleafs)) );
bool isValidBrush = false;
BSPLeaf& leaf = bspLoader.m_dleafs[i];
for (int b=0;b<leaf.numLeafBrushes;b++)
{
btAlignedObjectArray<btVector3> planeEquations;
int brushid = bspLoader.m_dleafbrushes[leaf.firstLeafBrush+b];
BSPBrush& brush = bspLoader.m_dbrushes[brushid];
if (brush.shaderNum!=-1)
{
if (bspLoader.m_dshaders[ brush.shaderNum ].contentFlags & BSPCONTENTS_SOLID)
{
brush.shaderNum = -1;
for (int p=0;p<brush.numSides;p++)
{
int sideid = brush.firstSide+p;
BSPBrushSide& brushside = bspLoader.m_dbrushsides[sideid];
int planeid = brushside.planeNum;
BSPPlane& plane = bspLoader.m_dplanes[planeid];
btVector3 planeEq;
planeEq.setValue(
plane.normal[0],
plane.normal[1],
plane.normal[2]);
planeEq[3] = scaling*-plane.dist;
planeEquations.push_back(planeEq);
isValidBrush=true;
}
if (isValidBrush)
{
btAlignedObjectArray<btVector3> vertices;
btGeometryUtil::getVerticesFromPlaneEquations(planeEquations,vertices);
bool isEntity = false;
btVector3 entityTarget(0.f,0.f,0.f);
addConvexVerticesCollider(vertices,isEntity,entityTarget);
}
}
}
}
}
#define USE_ENTITIES
#ifdef USE_ENTITIES
{
int i;
for (i=0;i<bspLoader.m_num_entities;i++)
{
const BSPEntity& entity = bspLoader.m_entities[i];
const char* cl = bspLoader.getValueForKey(&entity,"classname");
if ( !strcmp( cl, "trigger_push" ) ) {
btVector3 targetLocation(0.f,0.f,0.f);
cl = bspLoader.getValueForKey(&entity,"target");
if ( strcmp( cl, "" ) ) {
//its not empty so ...
/*
//lookup the target position for the jumppad:
const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl );
if (targetentity)
{
if (bspLoader.getVectorForKey( targetentity , "origin",&targetLocation[0]))
{
}
}
*/
cl = bspLoader.getValueForKey(&entity,"model");
if ( strcmp( cl, "" ) ) {
// add the model as a brush
if (cl[0] == '*')
{
int modelnr = atoi(&cl[1]);
if ((modelnr >=0) && (modelnr < bspLoader.m_nummodels))
{
const BSPModel& model = bspLoader.m_dmodels[modelnr];
for (int n=0;n<model.numBrushes;n++)
{
btAlignedObjectArray<btVector3> planeEquations;
bool isValidBrush = false;
//convert brush
const BSPBrush& brush = bspLoader.m_dbrushes[model.firstBrush+n];
{
for (int p=0;p<brush.numSides;p++)
{
int sideid = brush.firstSide+p;
BSPBrushSide& brushside = bspLoader.m_dbrushsides[sideid];
int planeid = brushside.planeNum;
BSPPlane& plane = bspLoader.m_dplanes[planeid];
btVector3 planeEq;
planeEq.setValue(
plane.normal[0],
plane.normal[1],
plane.normal[2]);
planeEq[3] = scaling*-plane.dist;
planeEquations.push_back(planeEq);
isValidBrush=true;
}
if (isValidBrush)
{
btAlignedObjectArray<btVector3> vertices;
btGeometryUtil::getVerticesFromPlaneEquations(planeEquations,vertices);
bool isEntity=true;
addConvexVerticesCollider(vertices,isEntity,targetLocation);
}
}
}
}
}
else
{
printf("unsupported trigger_push model, md3 ?\n");
}
}
}
}
}
}
#endif //USE_ENTITIES
//progressEnd();
}
}

View File

@ -1,39 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BSP_CONVERTER_H
#define BSP_CONVERTER_H
class BspLoader;
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
///BspConverter turns a loaded bsp level into convex parts (vertices)
class BspConverter
{
public:
void convertBsp(BspLoader& bspLoader,float scaling);
virtual ~BspConverter()
{
}
///this callback is called for each brush that succesfully converted into vertices
virtual void addConvexVerticesCollider(btAlignedObjectArray<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
};
#endif //BSP_CONVERTER_H

View File

@ -1,321 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btIDebugDraw.h"
#include "GLDebugDrawer.h"
#define QUAKE_BSP_IMPORTING 1
#ifdef QUAKE_BSP_IMPORTING
#include "BspLoader.h"
#include "BspConverter.h"
#endif //QUAKE_BSP_IMPORTING
#include <stdio.h> //printf debugging
#include "BspDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#define CUBE_HALF_EXTENTS 1
#define EXTRA_HEIGHT -20.f
///BspToBulletConverter extends the BspConverter to convert to Bullet datastructures
class BspToBulletConverter : public BspConverter
{
BspDemo* m_demoApp;
public:
BspToBulletConverter(BspDemo* demoApp)
:m_demoApp(demoApp)
{
}
virtual void addConvexVerticesCollider(btAlignedObjectArray<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
{
///perhaps we can do something special with entities (isEntity)
///like adding a collision Triggering (as example)
if (vertices.size() > 0)
{
float mass = 0.f;
btTransform startTransform;
//can use a shift
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,0,-10.f));
//this create an internal copy of the vertices
btCollisionShape* shape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
m_demoApp->m_collisionShapes.push_back(shape);
//btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
m_demoApp->localCreateRigidBody(mass, startTransform,shape);
}
}
};
////////////////////////////////////
BspDemo::~BspDemo()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
//delete dynamics world
delete m_dynamicsWorld;
//delete solver
delete m_solver;
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}
void BspDemo::initPhysics()
{
const char* bspfilename = "BspDemo.bsp";
initPhysics(bspfilename);
}
void BspDemo::initPhysics(const char* bspfilename)
{
setTexturing(true);
setShadows(false);
m_cameraUp = btVector3(0,0,1);
m_forwardAxis = 1;
setCameraDistance(22.f);
///Setup a Physics Simulation Environment
m_collisionConfiguration = new btDefaultCollisionConfiguration();
// btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
m_broadphase = new btDbvtBroadphase();
//m_broadphase = new btAxisSweep3(worldMin,worldMax);
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
m_solver = new btSequentialImpulseConstraintSolver();
//ConstraintSolver* solver = new OdeConstraintSolver;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
#ifdef QUAKE_BSP_IMPORTING
void* memoryBuffer = 0;
FILE* file = fopen(bspfilename,"r");
if (!file)
{
//try again other path,
//sight... visual studio leaves the current working directory in the projectfiles folder
//instead of executable folder. who wants this default behaviour?!?
bspfilename = "../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//try again other path, cmake needs 4 levels deep back...
bspfilename = "../../../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//try again other path,
//sight... visual studio leaves the current working directory in the projectfiles folder
//instead of executable folder. who wants this default behaviour?!?
bspfilename = "BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (file)
{
BspLoader bspLoader;
int size=0;
if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */
printf("Error: cannot get filesize from %s\n", bspfilename);
} else
{
//how to detect file size?
memoryBuffer = malloc(size+1);
fread(memoryBuffer,1,size,file);
bspLoader.loadBSPFile( memoryBuffer);
BspToBulletConverter bsp2bullet(this);
float bspScaling = 0.1f;
bsp2bullet.convertBsp(bspLoader,bspScaling);
}
fclose(file);
}
#endif
clientResetScene();
}
void BspDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
m_dynamicsWorld->stepSimulation(dt);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
renderme();
glFlush();
glutSwapBuffers();
}
void BspDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
glFlush();
glutSwapBuffers();
}
//some code that de-mangles the windows filename passed in as argument
char cleaned_filename[512];
char* getLastFileName()
{
return cleaned_filename;
}
char* makeExeToBspFilename(const char* lpCmdLine)
{
// We might get a windows-style path on the command line, this can mess up the DOM which expects
// all paths to be URI's. This block of code does some conversion to try and make the input
// compliant without breaking the ability to accept a properly formatted URI. Right now this only
// displays the first filename
const char *in = lpCmdLine;
char* out = cleaned_filename;
*out = '\0';
// If the first character is a ", skip it (filenames with spaces in them are quoted)
if(*in == '\"')
{
in++;
}
int i;
for(i =0; i<512; i++)
{
//if we get '.' we stop as well, unless it's the first character. Then we add .bsp as extension
// If we hit a null or a quote, stop copying. This will get just the first filename.
if(i && (in[0] == '.') && (in[1] == 'e') && (in[2] == 'x') && (in[3] == 'e'))
break;
// If we hit a null or a quote, stop copying. This will get just the first filename.
if(*in == '\0' || *in == '\"')
break;
// Copy while swapping backslashes for forward ones
if(*in == '\\')
{
*out = '/';
}
else
{
*out = *in;
}
in++;
out++;
}
*(out++) = '.';
*(out++) = 'b';
*(out++) = 's';
*(out++) = 'p';
*(out++) = 0;
return cleaned_filename;
}

View File

@ -1,71 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BSP_DEMO_H
#define BSP_DEMO_H
#include "GlutDemoApplication.h"
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///BspDemo shows the convex collision detection, by converting a Quake BSP file into convex objects and allowing interaction with boxes.
class BspDemo : public GlutDemoApplication
{
public:
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
virtual ~BspDemo();
virtual void initPhysics();
void initPhysics(const char* bspfilename);
virtual void clientMoveAndDisplay();
virtual void displayCallback();
static DemoApplication* Create()
{
BspDemo* demo = new BspDemo;
demo->myinit();
demo->initPhysics("BspDemo.bsp");
return demo;
}
};
#endif //BSP_DEMO_H

View File

@ -1,730 +0,0 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU bteral Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU bteral Public License for more details.
You should have received a copy of the GNU bteral Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "BspLoader.h"
#include <stdio.h>
#include <string.h>
typedef struct
{
char filename[1024];
char *buffer,*script_p,*end_p;
int line;
} BSPScript;
#define MAX_INCLUDES 8
BSPScript scriptstack[MAX_INCLUDES];
BSPScript *script;
int scriptline;
char token[BSPMAXTOKEN];
bool endofscript;
bool tokenready; // only true if UnGetToken was just called
//
//loadBSPFile
//
int extrasize = 100;
BspLoader::BspLoader()
:m_num_entities(0)
{
m_Endianness = getMachineEndianness();
if (m_Endianness == BSP_BIG_ENDIAN)
{
printf("Machine is BIG_ENDIAN\n");
} else
{
printf("Machine is Little Endian\n");
}
}
bool BspLoader::loadBSPFile( void* memoryBuffer) {
BSPHeader *header = (BSPHeader*) memoryBuffer;
// load the file header
if (header)
{
// swap the header
swapBlock( (int *)header, sizeof(*header) );
int length = (header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader);
m_dshaders.resize(length+extrasize);
m_numShaders = copyLump( header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader) );
length = (header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel);
m_dmodels.resize(length+extrasize);
m_nummodels = copyLump( header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel) );
length = (header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane);
m_dplanes.resize(length+extrasize);
m_numplanes = copyLump( header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane) );
length = (header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf);
m_dleafs.resize(length+extrasize);
m_numleafs = copyLump( header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf) );
length = (header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode);
m_dnodes.resize(length+extrasize);
m_numnodes = copyLump( header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode) );
length = (header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0]);
m_dleafsurfaces.resize(length+extrasize);
m_numleafsurfaces = copyLump( header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0]) );
length = (header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0]) ;
m_dleafbrushes.resize(length+extrasize);
m_numleafbrushes = copyLump( header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0]) );
length = (header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush);
m_dbrushes.resize(length+extrasize);
m_numbrushes = copyLump( header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush) );
length = (header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide);
m_dbrushsides.resize(length+extrasize);
m_numbrushsides = copyLump( header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide) );
length = (header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface);
m_drawSurfaces.resize(length+extrasize);
m_numDrawSurfaces = copyLump( header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface) );
length = (header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0]);
m_drawIndexes.resize(length+extrasize);
m_numDrawIndexes = copyLump( header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0]) );
length = (header->lumps[LUMP_VISIBILITY].filelen) / 1;
m_visBytes.resize(length+extrasize);
m_numVisBytes = copyLump( header, LUMP_VISIBILITY, &m_visBytes[0], 1 );
length = (header->lumps[LUMP_LIGHTMAPS].filelen) / 1;
m_lightBytes.resize(length+extrasize);
m_numLightBytes = copyLump( header, LUMP_LIGHTMAPS, &m_lightBytes[0], 1 );
length = (header->lumps[BSPLUMP_ENTITIES].filelen) / 1;
m_dentdata.resize(length+extrasize);
m_entdatasize = copyLump( header, BSPLUMP_ENTITIES, &m_dentdata[0], 1);
length = (header->lumps[LUMP_LIGHTGRID].filelen) / 1;
m_gridData.resize(length+extrasize);
m_numGridPoints = copyLump( header, LUMP_LIGHTGRID, &m_gridData[0], 8 );
// swap everything
swapBSPFile();
return true;
}
return false;
}
const char* BspLoader::getValueForKey( const BSPEntity* ent, const char* key ) const {
const BSPKeyValuePair* ep;
for (ep=ent->epairs ; ep ; ep=ep->next) {
if (!strcmp(ep->key, key) ) {
return ep->value;
}
}
return "";
}
float BspLoader::getFloatForKey( const BSPEntity *ent, const char *key ) {
const char *k;
k = getValueForKey( ent, key );
return float(atof(k));
}
bool BspLoader::getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ) {
const char *k;
k = getValueForKey (ent, key);
if (strcmp(k, ""))
{
sscanf (k, "%f %f %f", &vec[0], &vec[1], &vec[2]);
return true;
}
return false;
}
/*
==============
parseFromMemory
==============
*/
void BspLoader::parseFromMemory (char *buffer, int size)
{
script = scriptstack;
script++;
if (script == &scriptstack[MAX_INCLUDES])
{
//printf("script file exceeded MAX_INCLUDES");
}
strcpy (script->filename, "memory buffer" );
script->buffer = buffer;
script->line = 1;
script->script_p = script->buffer;
script->end_p = script->buffer + size;
endofscript = false;
tokenready = false;
}
bool BspLoader::isEndOfScript (bool crossline)
{
if (!crossline)
//printf("Line %i is incomplete\n",scriptline);
if (!strcmp (script->filename, "memory buffer"))
{
endofscript = true;
return false;
}
//free (script->buffer);
if (script == scriptstack+1)
{
endofscript = true;
return false;
}
script--;
scriptline = script->line;
//printf ("returning to %s\n", script->filename);
return getToken (crossline);
}
/*
==============
getToken
==============
*/
bool BspLoader::getToken (bool crossline)
{
char *token_p;
if (tokenready) // is a token allready waiting?
{
tokenready = false;
return true;
}
if (script->script_p >= script->end_p)
return isEndOfScript (crossline);
//
// skip space
//
skipspace:
while (*script->script_p <= 32)
{
if (script->script_p >= script->end_p)
return isEndOfScript (crossline);
if (*script->script_p++ == '\n')
{
if (!crossline)
{
//printf("Line %i is incomplete\n",scriptline);
}
scriptline = script->line++;
}
}
if (script->script_p >= script->end_p)
return isEndOfScript (crossline);
// ; # // comments
if (*script->script_p == ';' || *script->script_p == '#'
|| ( script->script_p[0] == '/' && script->script_p[1] == '/') )
{
if (!crossline)
{
//printf("Line %i is incomplete\n",scriptline);
}
while (*script->script_p++ != '\n')
if (script->script_p >= script->end_p)
return isEndOfScript (crossline);
scriptline = script->line++;
goto skipspace;
}
// /* */ comments
if (script->script_p[0] == '/' && script->script_p[1] == '*')
{
if (!crossline)
{
//printf("Line %i is incomplete\n",scriptline);
}
script->script_p+=2;
while (script->script_p[0] != '*' && script->script_p[1] != '/')
{
if ( *script->script_p == '\n' ) {
scriptline = script->line++;
}
script->script_p++;
if (script->script_p >= script->end_p)
return isEndOfScript (crossline);
}
script->script_p += 2;
goto skipspace;
}
//
// copy token
//
token_p = token;
if (*script->script_p == '"')
{
// quoted token
script->script_p++;
while (*script->script_p != '"')
{
*token_p++ = *script->script_p++;
if (script->script_p == script->end_p)
break;
if (token_p == &token[BSPMAXTOKEN])
{
//printf ("Token too large on line %i\n",scriptline);
}
}
script->script_p++;
}
else // regular token
while ( *script->script_p > 32 && *script->script_p != ';')
{
*token_p++ = *script->script_p++;
if (script->script_p == script->end_p)
break;
if (token_p == &token[BSPMAXTOKEN])
{
//printf ("Token too large on line %i\n",scriptline);
}
}
*token_p = 0;
if (!strcmp (token, "$include"))
{
//getToken (false);
//AddScriptToStack (token);
return false;//getToken (crossline);
}
return true;
}
char *BspLoader::copystring(const char *s)
{
char *b;
b = (char*) malloc( strlen(s)+1);
strcpy (b, s);
return b;
}
void BspLoader::stripTrailing( char *e ) {
char *s;
s = e + strlen(e)-1;
while (s >= e && *s <= 32)
{
*s = 0;
s--;
}
}
/*
=================
parseEpair
=================
*/
BSPKeyValuePair *BspLoader::parseEpair( void ) {
BSPKeyValuePair *e;
e = (struct BSPPair*) malloc( sizeof(BSPKeyValuePair));
memset( e, 0, sizeof(BSPKeyValuePair) );
if ( strlen(token) >= BSPMAX_KEY-1 ) {
//printf ("ParseEpar: token too long");
}
e->key = copystring( token );
getToken( false );
if ( strlen(token) >= BSPMAX_VALUE-1 ) {
//printf ("ParseEpar: token too long");
}
e->value = copystring( token );
// strip trailing spaces that sometimes get accidentally
// added in the editor
stripTrailing( e->key );
stripTrailing( e->value );
return e;
}
/*
================
parseEntity
================
*/
bool BspLoader::parseEntity( void ) {
BSPKeyValuePair *e;
BSPEntity *mapent;
if ( !getToken (true) ) {
return false;
}
if ( strcmp (token, "{") ) {
//printf ("parseEntity: { not found");
}
BSPEntity bla;
bla.brushes = 0;
bla.epairs = 0;
bla.firstDrawSurf = 0;
bla.origin[0] = 0.f;
bla.origin[1] = 0.f;
bla.origin[2] = 0.f;
bla.patches = 0;
m_entities.push_back(bla);
mapent = &m_entities[m_entities.size()-1];
m_num_entities++;
do {
if ( !getToken (true) ) {
//printf("parseEntity: EOF without closing brace");
}
if ( !strcmp (token, "}") ) {
break;
}
e = (struct BSPPair*)parseEpair ();
e->next = mapent->epairs;
mapent->epairs = e;
} while (1);
return true;
}
/*
================
parseEntities
Parses the dentdata string into entities
================
*/
void BspLoader::parseEntities( void ) {
m_num_entities = 0;
m_entities.clear();
parseFromMemory( &m_dentdata[0], m_entdatasize );
while ( parseEntity () ) {
}
}
int BspLoader::getMachineEndianness()
{
long int i = 1;
const char *p = (const char *) &i;
if (p[0] == 1) // Lowest address contains the least significant byte
return BSP_LITTLE_ENDIAN;
else
return BSP_BIG_ENDIAN;
}
short BspLoader::isLittleShort (short l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
unsigned char b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
//little endian
return l;
}
short BspLoader::isBigShort (short l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
return l;
}
unsigned char b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
int BspLoader::isLittleLong (int l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
unsigned char b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}
//little endian
return l;
}
int BspLoader::isBigLong (int l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
return l;
}
unsigned char b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}
float BspLoader::isLittleFloat (float l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
union {unsigned char b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
//little endian
return l;
}
float BspLoader::isBigFloat (float l)
{
if (machineEndianness() == BSP_BIG_ENDIAN)
{
return l;
}
//little endian
union {unsigned char b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
//
// swapBlock
// If all values are 32 bits, this can be used to swap everything
//
void BspLoader::swapBlock( int *block, int sizeOfBlock ) {
int i;
sizeOfBlock >>= 2;
for ( i = 0 ; i < sizeOfBlock ; i++ ) {
block[i] = isLittleLong( block[i] );
}
}
//
// copyLump
//
int BspLoader::copyLump( BSPHeader *header, int lump, void *dest, int size ) {
int length, ofs;
length = header->lumps[lump].filelen;
ofs = header->lumps[lump].fileofs;
//if ( length % size ) {
// printf ("loadBSPFile: odd lump size");
//}
memcpy( dest, (unsigned char *)header + ofs, length );
return length / size;
}
//
// swapBSPFile
//
void BspLoader::swapBSPFile( void ) {
int i;
// models
swapBlock( (int *) &m_dmodels[0], m_nummodels * sizeof( m_dmodels[0] ) );
// shaders (don't swap the name)
for ( i = 0 ; i < m_numShaders ; i++ ) {
m_dshaders[i].contentFlags = isLittleLong( m_dshaders[i].contentFlags );
m_dshaders[i].surfaceFlags = isLittleLong( m_dshaders[i].surfaceFlags );
}
// planes
swapBlock( (int *)&m_dplanes[0], m_numplanes * sizeof( m_dplanes[0] ) );
// nodes
swapBlock( (int *)&m_dnodes[0], m_numnodes * sizeof( m_dnodes[0] ) );
// leafs
swapBlock( (int *)&m_dleafs[0], m_numleafs * sizeof( m_dleafs[0] ) );
// leaffaces
swapBlock( (int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof( m_dleafsurfaces[0] ) );
// leafbrushes
swapBlock( (int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof( m_dleafbrushes[0] ) );
// brushes
swapBlock( (int *)&m_dbrushes[0], m_numbrushes * sizeof( m_dbrushes[0] ) );
// brushsides
swapBlock( (int *)&m_dbrushsides[0], m_numbrushsides * sizeof( m_dbrushsides[0] ) );
// vis
((int *)&m_visBytes)[0] = isLittleLong( ((int *)&m_visBytes)[0] );
((int *)&m_visBytes)[1] = isLittleLong( ((int *)&m_visBytes)[1] );
// drawindexes
swapBlock( (int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof( m_drawIndexes[0] ) );
// drawsurfs
swapBlock( (int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof( m_drawSurfaces[0] ) );
}
bool BspLoader::findVectorByName(float* outvec,const char* name)
{
const char *cl;
BSPVector3 origin;
bool found = false;
parseEntities();
for ( int i = 1; i < m_num_entities; i++ ) {
cl = getValueForKey (&m_entities[i], "classname");
if ( !strcmp( cl, "info_player_start" ) ) {
getVectorForKey( &m_entities[i], "origin", origin );
found = true;
break;
}
if ( !strcmp( cl, "info_player_deathmatch" ) ) {
getVectorForKey( &m_entities[i], "origin", origin );
found = true;
break;
}
}
if (found)
{
outvec[0] = origin[0];
outvec[1] = origin[1];
outvec[2] = origin[2];
}
return found;
}
const BSPEntity * BspLoader::getEntityByValue( const char* name, const char* value)
{
const BSPEntity* entity = NULL;
for ( int i = 1; i < m_num_entities; i++ ) {
const BSPEntity& ent = m_entities[i];
const char* cl = getValueForKey (&m_entities[i], name);
if ( !strcmp( cl, value ) ) {
entity = &ent;
break;
}
}
return entity;
}

View File

@ -1,295 +0,0 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU bteral Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU bteral Public License for more details.
You should have received a copy of the GNU bteral Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef BSP_LOADER_H
#define BSP_LOADER_H
#include "LinearMath/btAlignedObjectArray.h"
#define BSPMAXTOKEN 1024
#define BSPMAX_KEY 32
#define BSPMAX_VALUE 1024
#define BSPCONTENTS_SOLID 1
#define BSPCONTENTS_AREAPORTAL 0x8000
#define BSPLUMP_ENTITIES 0
#define BSPLUMP_SHADERS 1
#define BSPLUMP_PLANES 2
#define BSPLUMP_NODES 3
#define BSPLUMP_LEAFS 4
#define BSPLUMP_LEAFSURFACES 5
#define BSPLUMP_LEAFBRUSHES 6
#define LUMP_MODELS 7
#define LUMP_BRUSHES 8
#define LUMP_BRUSHSIDES 9
#define LUMP_DRAWVERTS 10
#define LUMP_DRAWINDEXES 11
#define LUMP_SURFACES 13
#define LUMP_LIGHTMAPS 14
#define LUMP_LIGHTGRID 15
#define LUMP_VISIBILITY 16
#define HEADER_LUMPS 17
#define MAX_QPATH 64
typedef struct {
int fileofs, filelen;
} BSPLump;
typedef float BSPVector3[3];
typedef struct {
int ident;
int version;
BSPLump lumps[HEADER_LUMPS];
} BSPHeader;
typedef struct {
float mins[3], maxs[3];
int firstSurface, numSurfaces;
int firstBrush, numBrushes;
} BSPModel;
typedef struct {
char shader[MAX_QPATH];
int surfaceFlags;
int contentFlags;
} BSPShader;
typedef struct {
float normal[3];
float dist;
} BSPPlane;
typedef struct {
int planeNum;
int children[2];
int mins[3];
int maxs[3];
} BSPNode;
typedef struct {
int cluster;
int area;
int mins[3];
int maxs[3];
int firstLeafSurface;
int numLeafSurfaces;
int firstLeafBrush;
int numLeafBrushes;
} BSPLeaf;
typedef struct {
int planeNum;
int shaderNum;
} BSPBrushSide;
typedef struct {
int firstSide;
int numSides;
int shaderNum;
} BSPBrush;
typedef struct BSPPair {
struct BSPPair *next;
char *key;
char *value;
} BSPKeyValuePair;
typedef struct {
BSPVector3 origin;
struct bspbrush_s *brushes;
struct parseMesh_s *patches;
int firstDrawSurf;
BSPKeyValuePair *epairs;
} BSPEntity;
typedef enum {
MST_BAD,
MST_PLANAR,
MST_PATCH,
MST_TRIANGLE_SOUP,
MST_FLARE
} BSPMapSurface;
typedef struct {
int shaderNum;
int fogNum;
int surfaceType;
int firstVert;
int numVerts;
int firstIndex;
int numIndexes;
int lightmapNum;
int lightmapX, lightmapY;
int lightmapWidth, lightmapHeight;
BSPVector3 lightmapOrigin;
BSPVector3 lightmapVecs[3];
int patchWidth;
int patchHeight;
} BSPSurface;
///GPL code from IdSofware to parse a Quake 3 BSP file
///check that your platform define __BIG_ENDIAN__ correctly (in BspLoader.cpp)
class BspLoader
{
int m_Endianness;
public:
BspLoader();
bool loadBSPFile( void* memoryBuffer);
const char* getValueForKey( const BSPEntity *ent, const char *key ) const;
bool getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec );
float getFloatForKey( const BSPEntity *ent, const char *key );
void parseEntities( void );
bool findVectorByName(float* outvec,const char* name);
const BSPEntity * getEntityByValue( const char* name, const char* value);
protected:
void parseFromMemory (char *buffer, int size);
bool isEndOfScript (bool crossline);
bool getToken (bool crossline);
char *copystring(const char *s);
void stripTrailing( char *e );
BSPKeyValuePair * parseEpair( void );
bool parseEntity( void );
short isLittleShort (short l);
int isLittleLong (int l);
float isLittleFloat (float l);
int isBigLong (int l);
short isBigShort (short l);
float isBigFloat (float l);
void swapBlock( int *block, int sizeOfBlock );
int copyLump( BSPHeader *header, int lump, void *dest, int size );
void swapBSPFile( void );
public: //easier for conversion
int m_num_entities;
btAlignedObjectArray<BSPEntity> m_entities;
int m_nummodels;
btAlignedObjectArray<BSPModel> m_dmodels;
int m_numShaders;
btAlignedObjectArray<BSPShader> m_dshaders;
int m_entdatasize;
btAlignedObjectArray<char> m_dentdata;
int m_numleafs;
btAlignedObjectArray<BSPLeaf> m_dleafs;
int m_numplanes;
btAlignedObjectArray<BSPPlane> m_dplanes;
int m_numnodes;
btAlignedObjectArray<BSPNode> m_dnodes;
int m_numleafsurfaces;
btAlignedObjectArray<int> m_dleafsurfaces;
int m_numleafbrushes;
btAlignedObjectArray<int> m_dleafbrushes;
int m_numbrushes;
btAlignedObjectArray<BSPBrush> m_dbrushes;
int m_numbrushsides;
btAlignedObjectArray<BSPBrushSide> m_dbrushsides;
int m_numLightBytes;
btAlignedObjectArray<unsigned char> m_lightBytes;
int m_numGridPoints;
btAlignedObjectArray<unsigned char> m_gridData;
int m_numVisBytes;
btAlignedObjectArray<unsigned char> m_visBytes;
int m_numDrawIndexes;
btAlignedObjectArray<int> m_drawIndexes;
int m_numDrawSurfaces;
btAlignedObjectArray<BSPSurface> m_drawSurfaces;
enum
{
BSP_LITTLE_ENDIAN = 0,
BSP_BIG_ENDIAN = 1
};
//returns machines big endian / little endian
//
int getMachineEndianness();
inline int machineEndianness()
{
return m_Endianness;
}
};
#endif //BSP_LOADER_H

View File

@ -1,60 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBspPhysicsDemo
main.cpp
BspDemo.cpp
BspLoader.cpp
BspConverter.cpp
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBspPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBspPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppBspPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBspPhysicsDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,59 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BspDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
char* makeExeToBspFilename(const char* lpCmdLine);
char* getLastFileName();
int main(int argc,char** argv)
{
BspDemo* bspDemo = new BspDemo();
const char* bspfilename = "BspDemo.bsp";
printf("argc=%i\n",argc);
{
for (int i=0;i<argc;i++)
{
printf("argv[%i]=%s\n",i,argv[i]);
}
bspfilename = makeExeToBspFilename(argv[0]);
printf("new name=%s\n",bspfilename);
}
if (argc>1)
{
bspfilename = argv[1];
}
GLDebugDrawer gDebugDrawer;
// Enrico: TODO: Should change parameter type of initPhysics() to std::string or at least const char *
bspDemo->initPhysics((char*)bspfilename);
bspDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
return glutmain(argc, argv,640,480,"Bullet Quake BSP Physics Viewer http://bulletphysics.org",bspDemo);
}

View File

@ -1,996 +0,0 @@
/* This demo has been modified to use the Bullet C-API.
The C-API is minimal, and will develop based on developer feedback.
The C++ API is recommended, and compatible with the C-API.
*/
/* Copyright (c) Mark J. Kilgard, 1994, 1997. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
/* Example for PC game developers to show how to *combine* texturing,
reflections, and projected shadows all in real-time with OpenGL.
Robust reflections use stenciling. Robust projected shadows
use both stenciling and polygon offset. PC game programmers
should realize that neither stenciling nor polygon offset are
supported by Direct3D, so these real-time rendering algorithms
are only really viable with OpenGL.
The program has modes for disabling the stenciling and polygon
offset uses. It is worth running this example with these features
toggled off so you can see the sort of artifacts that result.
Notice that the floor texturing, reflections, and shadowing
all co-exist properly. */
/* When you run this program: Left mouse button controls the
view. Middle mouse button controls light position (left &
right rotates light around dino; up & down moves light
position up and down). Right mouse button pops up menu. */
/* Check out the comments in the "redraw" routine to see how the
reflection blending and surface stenciling is done. You can
also see in "redraw" how the projected shadows are rendered,
including the use of stenciling and polygon offset. */
/* This program is derived from glutdino.c */
/* Compile: cc -o dinoshade dinoshade.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
#ifdef WIN32//for glut.h
#include <windows.h>
#endif
#ifndef WIN32
#ifndef CALLBACK
#define CALLBACK
#endif
#endif
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#define GLVOIDPTR GLvoid(*)()
#else
#include <GL/glut.h>
#include <GL/glext.h>
#define GLVOIDPTR void(CALLBACK*)()
#endif
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
#define M_PI 3.14159265
#endif
//#include "../../include/Bullet-C-Api.h"
#include "Bullet-C-Api.h"
plPhysicsSdkHandle physicsSdk=0;
plDynamicsWorldHandle dynamicsWorld=0;
plRigidBodyHandle floorRigidBody;
plRigidBodyHandle dinoRigidBody;
/* Variable controlling various rendering modes. */
static int stencilReflection = 1, stencilShadow = 1, offsetShadow = 1;
static int renderShadow = 1, renderDinosaur = 1, renderReflection = 1;
static int linearFiltering = 0, useMipmaps = 0, useTexture = 1;
static int reportSpeed = 0;
static int animation = 1;
static GLboolean lightSwitch = GL_TRUE;
static int directionalLight = 1;
static int forceExtension = 0;
/* Time varying or user-controled variables. */
static float jump = 0.0;
static float lightAngle = 0.0, lightHeight = 20;
GLfloat angle = -150; /* in degrees */
GLfloat angle2 = 30; /* in degrees */
int moving, startx, starty;
int lightMoving = 0, lightStartX, lightStartY;
enum {
MISSING, EXTENSION, ONE_DOT_ONE
};
int polygonOffsetVersion;
static GLdouble bodyWidth = 3.0;
/* *INDENT-OFF* */
static GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5},
{11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16},
{8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2},
{1, 2} };
static GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9},
{15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10},
{13, 9}, {11, 11}, {9, 11} };
static GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0},
{12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} };
static GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15},
{9.6, 15.25}, {9, 15.25} };
static GLfloat lightPosition[4];
static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */
static GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0};
/* *INDENT-ON* */
/* Nice floor texture tiling pattern. */
static char *circles[] = {
"....xxxx........",
"..xxxxxxxx......",
".xxxxxxxxxx.....",
".xxx....xxx.....",
"xxx......xxx....",
"xxx......xxx....",
"xxx......xxx....",
"xxx......xxx....",
".xxx....xxx.....",
".xxxxxxxxxx.....",
"..xxxxxxxx......",
"....xxxx........",
"................",
"................",
"................",
"................",
};
static void
makeFloorTexture(void)
{
GLubyte floorTexture[16][16][3];
GLubyte *loc;
int s, t;
loc=0;
/* Setup RGB image for the texture. */
loc = (GLubyte*) floorTexture;
for (t = 0; t < 16; t++) {
for (s = 0; s < 16; s++) {
if (circles[t][s] == 'x') {
/* Nice green. */
loc[0] = 0x1f;
loc[1] = 0x8f;
loc[2] = 0x1f;
} else {
/* Light gray. */
loc[0] = 0xaa;
loc[1] = 0xaa;
loc[2] = 0xaa;
}
loc += 3;
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (useMipmaps) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 16, 16,
GL_RGB, GL_UNSIGNED_BYTE, floorTexture);
} else {
if (linearFiltering) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
glTexImage2D(GL_TEXTURE_2D, 0, 3, 16, 16, 0,
GL_RGB, GL_UNSIGNED_BYTE, floorTexture);
}
}
enum {
X, Y, Z, W
};
enum {
A, B, C, D
};
/* Create a matrix that will project the desired shadow. */
void
shadowMatrix(GLfloat shadowMat[4][4],
GLfloat groundplane[4],
GLfloat lightpos[4])
{
GLfloat dot;
/* Find dot product between light position vector and ground plane normal. */
dot = groundplane[X] * lightpos[X] +
groundplane[Y] * lightpos[Y] +
groundplane[Z] * lightpos[Z] +
groundplane[W] * lightpos[W];
shadowMat[0][0] = dot - lightpos[X] * groundplane[X];
shadowMat[1][0] = 0.f - lightpos[X] * groundplane[Y];
shadowMat[2][0] = 0.f - lightpos[X] * groundplane[Z];
shadowMat[3][0] = 0.f - lightpos[X] * groundplane[W];
shadowMat[X][1] = 0.f - lightpos[Y] * groundplane[X];
shadowMat[1][1] = dot - lightpos[Y] * groundplane[Y];
shadowMat[2][1] = 0.f - lightpos[Y] * groundplane[Z];
shadowMat[3][1] = 0.f - lightpos[Y] * groundplane[W];
shadowMat[X][2] = 0.f - lightpos[Z] * groundplane[X];
shadowMat[1][2] = 0.f - lightpos[Z] * groundplane[Y];
shadowMat[2][2] = dot - lightpos[Z] * groundplane[Z];
shadowMat[3][2] = 0.f - lightpos[Z] * groundplane[W];
shadowMat[X][3] = 0.f - lightpos[W] * groundplane[X];
shadowMat[1][3] = 0.f - lightpos[W] * groundplane[Y];
shadowMat[2][3] = 0.f - lightpos[W] * groundplane[Z];
shadowMat[3][3] = dot - lightpos[W] * groundplane[W];
}
/* Find the plane equation given 3 points. */
void
findPlane(GLfloat plane[4],
GLfloat v0[3], GLfloat v1[3], GLfloat v2[3])
{
GLfloat vec0[3], vec1[3];
/* Need 2 vectors to find cross product. */
vec0[X] = v1[X] - v0[X];
vec0[Y] = v1[Y] - v0[Y];
vec0[Z] = v1[Z] - v0[Z];
vec1[X] = v2[X] - v0[X];
vec1[Y] = v2[Y] - v0[Y];
vec1[Z] = v2[Z] - v0[Z];
/* find cross product to get A, B, and C of plane equation */
plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y];
plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]);
plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X];
plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]);
}
void
extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize,
GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
{
static GLUtriangulatorObj *tobj = NULL;
GLdouble vertex[3], dx, dy, len;
int i;
int count = dataSize / (2 * sizeof(GLfloat));
if (tobj == NULL) {
tobj = gluNewTess(); /* create and initialize a GLU
polygon * * tesselation object */
gluTessCallback(tobj, (GLenum)GLU_BEGIN, (GLVOIDPTR)glBegin);
gluTessCallback(tobj, (GLenum)GLU_VERTEX, (GLVOIDPTR)glVertex2fv); /* semi-tricky */
gluTessCallback(tobj, (GLenum)GLU_END, (GLVOIDPTR)glEnd);
}
glNewList(side, GL_COMPILE);
glShadeModel(GL_SMOOTH); /* smooth minimizes seeing
tessellation */
gluBeginPolygon(tobj);
for (i = 0; i < count; i++) {
vertex[0] = data[i][0];
vertex[1] = data[i][1];
vertex[2] = 0;
gluTessVertex(tobj, vertex, data[i]);
}
gluEndPolygon(tobj);
glEndList();
glNewList(edge, GL_COMPILE);
glShadeModel(GL_FLAT); /* flat shade keeps angular hands
from being "smoothed" */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= count; i++) {
/* mod function handles closing the edge */
glVertex3f(data[i % count][0], data[i % count][1], 0.0);
glVertex3f(data[i % count][0], data[i % count][1], thickness);
/* Calculate a unit normal by dividing by Euclidean
distance. We * could be lazy and use
glEnable(GL_NORMALIZE) so we could pass in * arbitrary
normals for a very slight performance hit. */
dx = data[(i + 1) % count][1] - data[i % count][1];
dy = data[i % count][0] - data[(i + 1) % count][0];
len = sqrt(dx * dx + dy * dy);
glNormal3f(dx / len, dy / len, 0.0);
}
glEnd();
glEndList();
glNewList(whole, GL_COMPILE);
glFrontFace(GL_CW);
glCallList(edge);
glNormal3f(0.0, 0.0, -1.0); /* constant normal for side */
glCallList(side);
glPushMatrix();
glTranslatef(0.0, 0.0, thickness);
glFrontFace(GL_CCW);
glNormal3f(0.0, 0.0, 1.0); /* opposite normal for other side */
glCallList(side);
glPopMatrix();
glEndList();
}
/* Enumerants for refering to display lists. */
typedef enum {
RESERVED, BODY_SIDE, BODY_EDGE, BODY_WHOLE, ARM_SIDE, ARM_EDGE, ARM_WHOLE,
LEG_SIDE, LEG_EDGE, LEG_WHOLE, EYE_SIDE, EYE_EDGE, EYE_WHOLE
} displayLists;
static void
makeDinosaur(void)
{
extrudeSolidFromPolygon(body, sizeof(body), bodyWidth,
BODY_SIDE, BODY_EDGE, BODY_WHOLE);
extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4,
ARM_SIDE, ARM_EDGE, ARM_WHOLE);
extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2,
LEG_SIDE, LEG_EDGE, LEG_WHOLE);
extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2,
EYE_SIDE, EYE_EDGE, EYE_WHOLE);
}
static void
drawDinosaur(void)
{
plReal matrix[16];
glPushMatrix();
/* Translate the dinosaur to be at (0,8,0). */
plGetOpenGLMatrix(dinoRigidBody,matrix);
// plGetPosition(dinoRigidBody,dinoWorldPos);
// glTranslatef(-8, 0, -bodyWidth / 2);
//glTranslatef(0.0, jump, 0.0);
// glTranslatef(dinoWorldPos[0],dinoWorldPos[1],dinoWorldPos[2]);
#ifdef BT_USE_DOUBLE_PRECISION
glMultMatrixd(matrix);
#else
glMultMatrixf(matrix);
#endif
// glutSolidCube(15);
glTranslatef(-8.5, -8.5, 0);
glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
glCallList(BODY_WHOLE);
glTranslatef(0.0, 0.0, bodyWidth);
glCallList(ARM_WHOLE);
glCallList(LEG_WHOLE);
glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4);
glCallList(ARM_WHOLE);
glTranslatef(0.0, 0.0, -bodyWidth / 4);
glCallList(LEG_WHOLE);
glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1);
glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
glCallList(EYE_WHOLE);
glPopMatrix();
}
static GLfloat floorVertices[4][3] = {
{ -20.0, 0.0, 20.0 },
{ 20.0, 0.0, 20.0 },
{ 20.0, 0.0, -20.0 },
{ -20.0, 0.0, -20.0 },
};
/* Draw a floor (possibly textured). */
static void
drawFloor(void)
{
glDisable(GL_LIGHTING);
if (useTexture) {
glEnable(GL_TEXTURE_2D);
}
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3fv(floorVertices[0]);
glTexCoord2f(0.0, 16.0);
glVertex3fv(floorVertices[1]);
glTexCoord2f(16.0, 16.0);
glVertex3fv(floorVertices[2]);
glTexCoord2f(16.0, 0.0);
glVertex3fv(floorVertices[3]);
glEnd();
if (useTexture) {
glDisable(GL_TEXTURE_2D);
}
glEnable(GL_LIGHTING);
}
static GLfloat floorPlane[4];
static GLfloat floorShadow[4][4];
static void
redraw(void)
{
int start = 0, end = 0 ;
if (reportSpeed) {
start = glutGet(GLUT_ELAPSED_TIME);
}
/* Clear; default stencil clears to zero. */
if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow)) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
} else {
/* Avoid clearing stencil when not using it. */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
/* Reposition the light source. */
lightPosition[0] = 12*cos(lightAngle);
lightPosition[1] = lightHeight;
lightPosition[2] = 12*sin(lightAngle);
if (directionalLight) {
lightPosition[3] = 0.0;
} else {
lightPosition[3] = 1.0;
}
shadowMatrix(floorShadow, floorPlane, lightPosition);
glPushMatrix();
/* Perform scene rotations based on user mouse input. */
glRotatef(angle2, 1.0, 0.0, 0.0);
glRotatef(angle, 0.0, 1.0, 0.0);
/* Tell GL new light source position. */
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
if (renderReflection) {
if (stencilReflection) {
/* We can eliminate the visual "artifact" of seeing the "flipped"
dinosaur underneath the floor by using stencil. The idea is
draw the floor without color or depth update but so that
a stencil value of one is where the floor will be. Later when
rendering the dinosaur reflection, we will only update pixels
with a stencil value of 1 to make sure the reflection only
lives on the floor, not below the floor. */
/* Don't update color or depth. */
glDisable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
/* Draw 1 into the stencil buffer. */
glEnable(GL_STENCIL_TEST);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
/* Now render floor; floor pixels just get their stencil set to 1. */
drawFloor();
/* Re-enable update of color and depth. */
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glEnable(GL_DEPTH_TEST);
/* Now, only render where stencil is set to 1. */
glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
glPushMatrix();
/* The critical reflection step: Reflect dinosaur through the floor
(the Y=0 plane) to make a relection. */
glScalef(1.0, -1.0, 1.0);
/* Reflect the light position. */
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
/* To avoid our normals getting reversed and hence botched lighting
on the reflection, turn on normalize. */
glEnable(GL_NORMALIZE);
glCullFace(GL_FRONT);
/* Draw the reflected dinosaur. */
drawDinosaur();
/* Disable noramlize again and re-enable back face culling. */
glDisable(GL_NORMALIZE);
glCullFace(GL_BACK);
glPopMatrix();
/* Switch back to the unreflected light position. */
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
if (stencilReflection) {
glDisable(GL_STENCIL_TEST);
}
}
/* Back face culling will get used to only draw either the top or the
bottom floor. This let's us get a floor with two distinct
appearances. The top floor surface is reflective and kind of red.
The bottom floor surface is not reflective and blue. */
/* Draw "bottom" of floor in blue. */
glFrontFace(GL_CW); /* Switch face orientation. */
glColor4f(0.1, 0.1, 0.7, 1.0);
drawFloor();
glFrontFace(GL_CCW);
if (renderShadow) {
if (stencilShadow) {
/* Draw the floor with stencil value 3. This helps us only
draw the shadow once per floor pixel (and only on the
floor pixels). */
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 3, 0xffffffff);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
}
}
/* Draw "top" of floor. Use blending to blend in reflection. */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.7, 0.0, 0.0, 0.3);
glColor4f(1.0, 1.0, 1.0, 0.3);
drawFloor();
glDisable(GL_BLEND);
if (renderDinosaur) {
/* Draw "actual" dinosaur, not its reflection. */
drawDinosaur();
}
if (renderShadow) {
/* Render the projected shadow. */
if (stencilShadow) {
/* Now, only render where stencil is set above 2 (ie, 3 where
the top floor is). Update stencil with 2 where the shadow
gets drawn so we don't redraw (and accidently reblend) the
shadow). */
glStencilFunc(GL_LESS, 2, 0xffffffff); /* draw if ==1 */
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
}
/* To eliminate depth buffer artifacts, we use polygon offset
to raise the depth of the projected shadow slightly so
that it does not depth buffer alias with the floor. */
if (offsetShadow) {
switch (polygonOffsetVersion) {
case EXTENSION:
#ifdef GL_VERSION_1_1
case ONE_DOT_ONE:
glEnable(GL_POLYGON_OFFSET_FILL);
break;
#endif
case MISSING:
/* Oh well. */
break;
}
}
/* Render 50% black shadow color on top of whatever the
floor appareance is. */
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_LIGHTING); /* Force the 50% black. */
glColor4f(0.0, 0.0, 0.0, 0.5);
glPushMatrix();
/* Project the shadow. */
glMultMatrixf((GLfloat *) floorShadow);
drawDinosaur();
glPopMatrix();
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
if (offsetShadow) {
switch (polygonOffsetVersion) {
#ifdef GL_VERSION_1_1
case ONE_DOT_ONE:
glDisable(GL_POLYGON_OFFSET_FILL);
break;
#endif
case MISSING:
/* Oh well. */
break;
}
}
if (stencilShadow) {
glDisable(GL_STENCIL_TEST);
}
}
glPushMatrix();
glDisable(GL_LIGHTING);
glColor3f(1.0, 1.0, 0.0);
if (directionalLight) {
/* Draw an arrowhead. */
glDisable(GL_CULL_FACE);
glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
glRotatef(lightAngle * -180.0 / M_PI, 0, 1, 0);
glRotatef(atan(lightHeight/12) * 180.0 / M_PI, 0, 0, 1);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0, 0, 0);
glVertex3f(2, 1, 1);
glVertex3f(2, -1, 1);
glVertex3f(2, -1, -1);
glVertex3f(2, 1, -1);
glVertex3f(2, 1, 1);
glEnd();
/* Draw a white line from light direction. */
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(5, 0, 0);
glEnd();
glEnable(GL_CULL_FACE);
} else {
/* Draw a yellow ball at the light source. */
glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
glutSolidSphere(1.0, 5, 5);
}
glEnable(GL_LIGHTING);
glPopMatrix();
glPopMatrix();
if (reportSpeed) {
glFinish();
end = glutGet(GLUT_ELAPSED_TIME);
printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start);
}
glutSwapBuffers();
}
/* ARGSUSED2 */
static void
mouse(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON) {
if (state == GLUT_DOWN) {
moving = 1;
startx = x;
starty = y;
}
if (state == GLUT_UP) {
moving = 0;
}
}
if (button == GLUT_MIDDLE_BUTTON) {
if (state == GLUT_DOWN) {
lightMoving = 1;
lightStartX = x;
lightStartY = y;
}
if (state == GLUT_UP) {
lightMoving = 0;
}
}
}
/* ARGSUSED1 */
static void
motion(int x, int y)
{
if (moving) {
angle = angle + (x - startx);
angle2 = angle2 + (y - starty);
startx = x;
starty = y;
glutPostRedisplay();
}
if (0){//lightMoving) {
lightAngle += (x - lightStartX)/40.0;
lightHeight += (lightStartY - y)/20.0;
lightStartX = x;
lightStartY = y;
glutPostRedisplay();
}
}
/* Advance time varying state when idle callback registered. */
static void
idle(void)
{
static float time = 0.0;
static float prevtime = 0.0;
float dtime;
prevtime = time;
time = glutGet(GLUT_ELAPSED_TIME) / 500.0;
dtime = time - prevtime;
jump = 4.0 * fabs(sin(time)*0.5);
if (!lightMoving) {
lightAngle = time;
}
if (dynamicsWorld)
plStepSimulation(dynamicsWorld,dtime);
glutPostRedisplay();
}
enum {
M_NONE, M_MOTION, M_LIGHT, M_TEXTURE, M_SHADOWS, M_REFLECTION, M_DINOSAUR,
M_STENCIL_REFLECTION, M_STENCIL_SHADOW, M_OFFSET_SHADOW,
M_POSITIONAL, M_DIRECTIONAL, M_PERFORMANCE
};
static void
controlLights(int value)
{
switch (value) {
case M_NONE:
return;
case M_MOTION:
animation = 1 - animation;
if (animation) {
glutIdleFunc(idle);
} else {
glutIdleFunc(NULL);
}
break;
case M_LIGHT:
lightSwitch = !lightSwitch;
if (lightSwitch) {
glEnable(GL_LIGHT0);
} else {
glDisable(GL_LIGHT0);
}
break;
case M_TEXTURE:
useTexture = !useTexture;
break;
case M_SHADOWS:
renderShadow = 1 - renderShadow;
break;
case M_REFLECTION:
renderReflection = 1 - renderReflection;
break;
case M_DINOSAUR:
renderDinosaur = 1 - renderDinosaur;
break;
case M_STENCIL_REFLECTION:
stencilReflection = 1 - stencilReflection;
break;
case M_STENCIL_SHADOW:
stencilShadow = 1 - stencilShadow;
break;
case M_OFFSET_SHADOW:
offsetShadow = 1 - offsetShadow;
break;
case M_POSITIONAL:
directionalLight = 0;
break;
case M_DIRECTIONAL:
directionalLight = 1;
break;
case M_PERFORMANCE:
reportSpeed = 1 - reportSpeed;
break;
}
glutPostRedisplay();
}
/* When not visible, stop animating. Restart when visible again. */
static void
visible(int vis)
{
if (vis == GLUT_VISIBLE) {
if (animation)
glutIdleFunc(idle);
} else {
if (!animation)
glutIdleFunc(NULL);
}
}
/* Press any key to redraw; good when motion stopped and
performance reporting on. */
/* ARGSUSED */
static void
key(unsigned char c, int x, int y)
{
if (c == 27) {
exit(0); /* IRIS GLism, Escape quits. */
}
glutPostRedisplay();
}
/* Press any key to redraw; good when motion stopped and
performance reporting on. */
/* ARGSUSED */
static void
special(int k, int x, int y)
{
glutPostRedisplay();
}
static int
supportsOneDotOne(void)
{
const char *version;
int major, minor;
version = (char *) glGetString(GL_VERSION);
if (sscanf(version, "%d.%d", &major, &minor) == 2)
return ((major > 1) || (major >= 1 && minor >= 1));
return 0; /* OpenGL version string malformed! */
}
int
main(int argc, char **argv)
{
int i;
plCollisionShapeHandle floorShape;
plCollisionShapeHandle dinoShape,dinoChildShape;
plVector3 floorPos,childPos;
plVector3 dinoPos;
plQuaternion childOrn,dinoOrient;
void* user_data=NULL;
physicsSdk = plNewBulletSdk();
dynamicsWorld = plCreateDynamicsWorld(physicsSdk);
//create ground plane
floorShape = plNewConvexHullShape();
for (i=0;i<4;i++)
{
// floorVertices
plAddVertex(floorShape,floorVertices[i][0],floorVertices[i][1],floorVertices[i][2]);
}
floorShape = plNewBoxShape(120,0,120);
floorRigidBody = plCreateRigidBody(user_data,0.f,floorShape);
floorPos[0] = 0;
floorPos[1] = 0;
floorPos[2] = 0;
plSetPosition(floorRigidBody,floorPos);
plAddRigidBody(dynamicsWorld,floorRigidBody);
//create dino rigidbody
dinoChildShape = plNewBoxShape(8.5,8.5,8.5);
dinoShape = plNewCompoundShape();
childPos[0] = 0;
childPos[1] = 0;
childPos[2] = 0;
childOrn[0] = 0;
childOrn[1] = 0;
childOrn[2] = 0;
childOrn[3] = 1;
plAddChildShape(dinoShape,dinoChildShape,childPos,childOrn);
dinoPos[0] = -10; dinoPos[1] = 28; dinoPos[2] = 0;
dinoRigidBody = plCreateRigidBody(0,1.0,dinoShape);
plSetPosition(dinoRigidBody,dinoPos);
plSetEuler(0,0,3.15*0.20,dinoOrient);
plSetOrientation(dinoRigidBody,dinoOrient);
plAddRigidBody(dynamicsWorld,dinoRigidBody);
printf("BulletDino\n");
glutInit(&argc, argv);
for (i=1; i<argc; i++) {
if (!strcmp("-linear", argv[i])) {
linearFiltering = 1;
} else if (!strcmp("-mipmap", argv[i])) {
useMipmaps = 1;
} else if (!strcmp("-ext", argv[i])) {
forceExtension = 1;
}
}
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL | GLUT_MULTISAMPLE);
#if 0
/* In GLUT 4.0, you'll be able to do this an be sure to
get 2 bits of stencil if the machine has it for you. */
glutInitDisplayString("samples stencil>=2 rgb double depth");
#endif
glutCreateWindow("Shadowy Leapin' Lizards");
if (glutGet(GLUT_WINDOW_STENCIL_SIZE) <= 1) {
printf("dinoshade: Sorry, I need at least 2 bits of stencil.\n");
exit(1);
}
/* Register GLUT callbacks. */
glutDisplayFunc(redraw);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutVisibilityFunc(visible);
glutKeyboardFunc(key);
glutSpecialFunc(special);
glutCreateMenu(controlLights);
glutAddMenuEntry("Toggle motion", M_MOTION);
glutAddMenuEntry("-----------------------", M_NONE);
glutAddMenuEntry("Toggle light", M_LIGHT);
glutAddMenuEntry("Toggle texture", M_TEXTURE);
glutAddMenuEntry("Toggle shadows", M_SHADOWS);
glutAddMenuEntry("Toggle reflection", M_REFLECTION);
glutAddMenuEntry("Toggle dinosaur", M_DINOSAUR);
glutAddMenuEntry("-----------------------", M_NONE);
glutAddMenuEntry("Toggle reflection stenciling", M_STENCIL_REFLECTION);
glutAddMenuEntry("Toggle shadow stenciling", M_STENCIL_SHADOW);
glutAddMenuEntry("Toggle shadow offset", M_OFFSET_SHADOW);
glutAddMenuEntry("----------------------", M_NONE);
glutAddMenuEntry("Positional light", M_POSITIONAL);
glutAddMenuEntry("Directional light", M_DIRECTIONAL);
glutAddMenuEntry("-----------------------", M_NONE);
glutAddMenuEntry("Toggle performance", M_PERFORMANCE);
glutAttachMenu(GLUT_RIGHT_BUTTON);
makeDinosaur();
#ifdef GL_VERSION_1_1
if (supportsOneDotOne() && !forceExtension) {
polygonOffsetVersion = ONE_DOT_ONE;
glPolygonOffset(-2.0, -1.0);
} else
#endif
{
{
polygonOffsetVersion = MISSING;
printf("\ndinoshine: Missing polygon offset.\n");
printf(" Expect shadow depth aliasing artifacts.\n\n");
}
}
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glLineWidth(3.0);
glMatrixMode(GL_PROJECTION);
gluPerspective( /* field of view in degree */ 40.0,
/* aspect ratio */ 1.0,
/* Z near */ 20.0, /* Z far */ 100.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 8.0, 60.0, /* eye is at (0,0,30) */
0.0, 8.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.); /* up is in postivie Y direction */
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
makeFloorTexture();
/* Setup floor plane for projected shadow calculations. */
findPlane(floorPlane, floorVertices[1], floorVertices[2], floorVertices[3]);
glutMainLoop();
plDeleteDynamicsWorld(dynamicsWorld);
plDeletePhysicsSdk(physicsSdk);
return 0; /* ANSI C requires main to return int. */
}

View File

@ -1,61 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
# This should be the case.
INCLUDE (${CMAKE_ROOT}/Modules/FindGLU.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindGLUT.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
IF (WIN32)
# This is the Windows code for which Opengl, and Glut are not properly installed
# since I can't install them I must cheat and copy libraries around
INCLUDE_DIRECTORIES(${GLUT_ROOT})
# LINK_DIRECTORIES(${GLUT_ROOT}\\lib)
IF (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib)
# LINK_LIBRARIES(${GLUT_ROOT}\\lib\\glut32 ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${GLUT_ROOT}\\lib\\glut32)
#
# ADD_CUSTOM_COMMAND(TARGET table POST_BUILD COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2005\\Debug
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2003\\Debug
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs6\\Debug)
ELSE (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
# LINK_LIBRARIES(${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY})
ENDIF(${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
# TARGET_LINK_LIBRARIES(table ${OPENGL_gl_LIBRARY})
# TARGET_LINK_LIBRARIES(table ${OPENGL_glu_LIBRARY})
ELSE (WIN32)
# This is the lines for linux. This should always work if everything is installed and working fine.
# SET(CMAKE_BUILD_TYPE Debug)
# SET(CMAKE_CXX_FLAGS_DEBUG "-g")
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
# TARGET_LINK_LIBRARIES(checker ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
ENDIF (WIN32)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY}
)
ADD_EXECUTABLE(BulletDino
BulletDino.c
)

View File

@ -1,180 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BulletXmlImportDemo.h"
#include "GlutStuff.h"
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btSerializer.h"
#include "btBulletFile.h"
#include "btBulletWorldImporter.h"
#include "btBulletXmlWorldImporter.h"
#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
#include <stdio.h> //printf debugging
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
void BulletXmlImportDemo::initPhysics()
{
setTexturing(true);
setShadows(true);
setupEmptyDynamicsWorld();
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
btBulletXmlWorldImporter* importer = new btBulletXmlWorldImporter(m_dynamicsWorld);
importer->loadFile("bullet_basic.xml");
// importer->loadFile("bulletser.xml");
// importer->loadFile("bullet_constraints.xml");
}
void BulletXmlImportDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//simple dynamics world doesn't handle fixed-time-stepping
float ms = getDeltaTimeMicroseconds();
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
m_dynamicsWorld->debugDrawWorld();
}
renderme();
glFlush();
swapBuffers();
}
void BulletXmlImportDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing to detect problems
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
glFlush();
swapBuffers();
}
void BulletXmlImportDemo::setupEmptyDynamicsWorld()
{
m_collisionConfiguration = new btDefaultCollisionConfiguration();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher);
m_broadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
//btGImpactCollisionAlgorithm::registerAlgorithm((btCollisionDispatcher*)m_dynamicsWorld->getDispatcher());
}
BulletXmlImportDemo::~BulletXmlImportDemo()
{
m_fileLoader->deleteAllData();
delete m_fileLoader;
exitPhysics();
}
void BulletXmlImportDemo::clientResetScene()
{
exitPhysics();
initPhysics();
}
void BulletXmlImportDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,87 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SERIALIZE_DEMO_H
#define SERIALIZE_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///BulletXmlImportDemo shows how to use save and load XML Bullet physics files (work-in-progress)
class BulletXmlImportDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
class btBulletWorldImporter* m_fileLoader;
public:
BulletXmlImportDemo()
{
//m_idle=true;
setCameraDistance(btScalar(30.));
}
virtual ~BulletXmlImportDemo();
virtual void clientResetScene();
void initPhysics();
void setupEmptyDynamicsWorld();
void exitPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
static DemoApplication* Create()
{
BulletXmlImportDemo* demo = new BulletXmlImportDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
};
#endif //SERIALIZE_DEMO_H

View File

@ -1,94 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletXmlWorldImporter
)
ADD_DEFINITIONS(-DDESERIALIZE_SOFT_BODIES)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletXmlWorldImporter BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletFileLoader LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppBulletXmlImportDemo
main.cpp
BulletXmlImportDemo.cpp
BulletXmlImportDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBulletXmlImportDemo
main.cpp
BulletXmlImportDemo.cpp
BulletXmlImportDemo.h
)
ENDIF()
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (WIN32)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBulletXmlImportDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppBulletXmlImportDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF(WIN32)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletXmlWorldImporter BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletFileLoader LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBulletXmlImportDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32BulletXmlImportDemo.cpp
BulletXmlImportDemo.cpp
BulletXmlImportDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES AND NOT INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
ADD_CUSTOM_COMMAND(
TARGET AppBulletXmlImportDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BulletXmlImportDemo/bullet_basic.xml ${CMAKE_CURRENT_BINARY_DIR}/bullet_basic.xml
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BulletXmlImportDemo/bullet_basic.xml ${CMAKE_CURRENT_BINARY_DIR}/Debug/bullet_basic.xml
)
ENDIF ()
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppBulletXmlImportDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppBulletXmlImportDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppBulletXmlImportDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2010 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BulletXmlImportDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new BulletXmlImportDemo();
}
#endif

View File

@ -1,668 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<bullet_physics version=281 itemcount = 9>
<btDynamicsWorldFloatData pointer=2>
<m_solverInfo type="btContactSolverInfoFloatData">
<m_tau type="float"> 0.600000 </m_tau>
<m_damping type="float"> 1.000000 </m_damping>
<m_friction type="float"> 0.300000 </m_friction>
<m_timeStep type="float"> 0.016667 </m_timeStep>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_maxErrorReduction type="float"> 20.000000 </m_maxErrorReduction>
<m_sor type="float"> 1.000000 </m_sor>
<m_erp type="float"> 0.200000 </m_erp>
<m_erp2 type="float"> 0.800000 </m_erp2>
<m_globalCfm type="float"> 0.000000 </m_globalCfm>
<m_splitImpulsePenetrationThreshold type="float"> -0.040000 </m_splitImpulsePenetrationThreshold>
<m_splitImpulseTurnErp type="float"> 0.100000 </m_splitImpulseTurnErp>
<m_linearSlop type="float"> 0.000000 </m_linearSlop>
<m_warmstartingFactor type="float"> 0.850000 </m_warmstartingFactor>
<m_maxGyroscopicForce type="float"> 100.000000 </m_maxGyroscopicForce>
<m_singleAxisRollingFrictionThreshold type="float"> 1000000015047466200000000000000.000000 </m_singleAxisRollingFrictionThreshold>
<m_numIterations type="int"> 10 </m_numIterations>
<m_solverMode type="int"> 260 </m_solverMode>
<m_restingContactRestitutionThreshold type="int"> 2 </m_restingContactRestitutionThreshold>
<m_minimumSolverBatchSize type="int"> 128 </m_minimumSolverBatchSize>
<m_splitImpulse type="int"> 1 </m_splitImpulse>
<m_padding type="char" count=4> 0 0 0 0 </m_padding>
</m_solverInfo>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
</btDynamicsWorldFloatData>
<btRigidBodyFloatData pointer=4>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 3 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -50.000000 0.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 1 </m_collisionFlags>
<m_islandTag1 type="int"> -1 </m_islandTag1>
<m_companionId type="int"> -2 </m_companionId>
<m_activationState1 type="int"> 2 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 0.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btRigidBodyFloatData pointer=6>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 5 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 14.166666 -3.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 14.166666 -3.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 0 </m_collisionFlags>
<m_islandTag1 type="int"> 4 </m_islandTag1>
<m_companionId type="int"> -1 </m_companionId>
<m_activationState1 type="int"> 1 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.500000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.500000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.500000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 1.500000 1.500000 1.500000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 1.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btRigidBodyFloatData pointer=7>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 5 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 16.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 16.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 0 </m_collisionFlags>
<m_islandTag1 type="int"> 4 </m_islandTag1>
<m_companionId type="int"> -1 </m_companionId>
<m_activationState1 type="int"> 1 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.500000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.500000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.500000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 1.500000 1.500000 1.500000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 1.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btRigidBodyFloatData pointer=8>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 5 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 18.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 18.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 0 </m_collisionFlags>
<m_islandTag1 type="int"> 4 </m_islandTag1>
<m_companionId type="int"> -1 </m_companionId>
<m_activationState1 type="int"> 1 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.500000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.500000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.500000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 1.500000 1.500000 1.500000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 1.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btRigidBodyFloatData pointer=9>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 5 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 20.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 20.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 0 </m_collisionFlags>
<m_islandTag1 type="int"> 4 </m_islandTag1>
<m_companionId type="int"> -1 </m_companionId>
<m_activationState1 type="int"> 1 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.500000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.500000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.500000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 1.500000 1.500000 1.500000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 1.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btRigidBodyFloatData pointer=10>
<m_collisionObjectData type="btCollisionObjectFloatData">
<m_broadphaseHandle type="pointer"> 0 </m_broadphaseHandle>
<m_collisionShape type="pointer"> 5 </m_collisionShape>
<m_rootCollisionShape type="pointer"> 0 </m_rootCollisionShape>
<m_name type="pointer"> 0 </m_name>
<m_worldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 22.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_worldTransform>
<m_interpolationWorldTransform type="btTransformFloatData">
<m_basis type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.000000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.000000 0.000000 </m_floats>
</m_el>
</m_basis>
<m_origin type="btVector3FloatData">
<m_floats type="float" count=4> -5.000000 22.166668 -3.000000 0.000000 </m_floats>
</m_origin>
</m_interpolationWorldTransform>
<m_interpolationLinearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_interpolationLinearVelocity>
<m_interpolationAngularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_interpolationAngularVelocity>
<m_anisotropicFriction type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_anisotropicFriction>
<m_contactProcessingThreshold type="float"> 999999984306749440.000000 </m_contactProcessingThreshold>
<m_deactivationTime type="float"> 0.000000 </m_deactivationTime>
<m_friction type="float"> 0.500000 </m_friction>
<m_rollingFriction type="float"> -431602080.000000 </m_rollingFriction>
<m_restitution type="float"> 0.000000 </m_restitution>
<m_hitFraction type="float"> 1.000000 </m_hitFraction>
<m_ccdSweptSphereRadius type="float"> 0.000000 </m_ccdSweptSphereRadius>
<m_ccdMotionThreshold type="float"> 0.000000 </m_ccdMotionThreshold>
<m_hasAnisotropicFriction type="int"> 0 </m_hasAnisotropicFriction>
<m_collisionFlags type="int"> 0 </m_collisionFlags>
<m_islandTag1 type="int"> 4 </m_islandTag1>
<m_companionId type="int"> -1 </m_companionId>
<m_activationState1 type="int"> 1 </m_activationState1>
<m_internalType type="int"> 2 </m_internalType>
<m_checkCollideWith type="int"> 0 </m_checkCollideWith>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionObjectData>
<m_invInertiaTensorWorld type="btMatrix3x3FloatData">
<m_el type="btVector3FloatData" count=3>
<m_floats type="float" count=4> 1.500000 0.000000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 1.500000 0.000000 0.000000 </m_floats>
<m_floats type="float" count=4> 0.000000 0.000000 1.500000 0.000000 </m_floats>
</m_el>
</m_invInertiaTensorWorld>
<m_linearVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -4.000000 0.000000 0.000000 </m_floats>
</m_linearVelocity>
<m_angularVelocity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_angularVelocity>
<m_angularFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_angularFactor>
<m_linearFactor type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_linearFactor>
<m_gravity type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity>
<m_gravity_acceleration type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 -10.000000 0.000000 0.000000 </m_floats>
</m_gravity_acceleration>
<m_invInertiaLocal type="btVector3FloatData">
<m_floats type="float" count=4> 1.500000 1.500000 1.500000 0.000000 </m_floats>
</m_invInertiaLocal>
<m_totalForce type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalForce>
<m_totalTorque type="btVector3FloatData">
<m_floats type="float" count=4> 0.000000 0.000000 0.000000 0.000000 </m_floats>
</m_totalTorque>
<m_inverseMass type="float"> 1.000000 </m_inverseMass>
<m_linearDamping type="float"> 0.000000 </m_linearDamping>
<m_angularDamping type="float"> 0.000000 </m_angularDamping>
<m_additionalDampingFactor type="float"> 0.005000 </m_additionalDampingFactor>
<m_additionalLinearDampingThresholdSqr type="float"> 0.010000 </m_additionalLinearDampingThresholdSqr>
<m_additionalAngularDampingThresholdSqr type="float"> 0.010000 </m_additionalAngularDampingThresholdSqr>
<m_additionalAngularDampingFactor type="float"> 0.010000 </m_additionalAngularDampingFactor>
<m_linearSleepingThreshold type="float"> 0.800000 </m_linearSleepingThreshold>
<m_angularSleepingThreshold type="float"> 1.000000 </m_angularSleepingThreshold>
<m_additionalDamping type="int"> 0 </m_additionalDamping>
</btRigidBodyFloatData>
<btConvexInternalShapeData pointer=3>
<m_collisionShapeData type="btCollisionShapeData">
<m_name type="pointer"> 0 </m_name>
<m_shapeType type="int"> 0 </m_shapeType>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionShapeData>
<m_localScaling type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_localScaling>
<m_implicitShapeDimensions type="btVector3FloatData">
<m_floats type="float" count=4> 49.959999 49.959999 49.959999 0.000000 </m_floats>
</m_implicitShapeDimensions>
<m_collisionMargin type="float"> 0.040000 </m_collisionMargin>
<m_padding type="int"> -842150451 </m_padding>
</btConvexInternalShapeData>
<btConvexInternalShapeData pointer=5>
<m_collisionShapeData type="btCollisionShapeData">
<m_name type="pointer"> 0 </m_name>
<m_shapeType type="int"> 0 </m_shapeType>
<m_padding type="char" count=4> -51 -51 -51 -51 </m_padding>
</m_collisionShapeData>
<m_localScaling type="btVector3FloatData">
<m_floats type="float" count=4> 1.000000 1.000000 1.000000 0.000000 </m_floats>
</m_localScaling>
<m_implicitShapeDimensions type="btVector3FloatData">
<m_floats type="float" count=4> 0.960000 0.960000 0.960000 0.000000 </m_floats>
</m_implicitShapeDimensions>
<m_collisionMargin type="float"> 0.040000 </m_collisionMargin>
<m_padding type="int"> -842150451 </m_padding>
</btConvexInternalShapeData>
</bullet_physics>

File diff suppressed because it is too large Load Diff

View File

@ -1,107 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2007 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "BulletXmlImportDemo.h"
#include "GlutStuff.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btHashMap.h"
#ifdef USE_AMD_OPENCL
#include "btOpenCLUtils.h"
#include <LinearMath/btScalar.h>
cl_context g_cxMainContext;
cl_device_id g_cdDevice;
cl_command_queue g_cqCommandQue;
// Returns true if OpenCL is initialized properly, false otherwise.
bool initCL( void* glCtx, void* glDC )
{
const char* vendorSDK = btOpenCLUtils::getSdkVendorName();
printf("This program was compiled using the %s OpenCL SDK\n",vendorSDK);
int ciErrNum = 0;
#ifdef BT_USE_CLEW
ciErrNum = clewInit( "OpenCL.dll" );
if ( ciErrNum != CLEW_SUCCESS ) {
return false;
}
#endif
#if defined(CL_PLATFORM_MINI_CL)
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
#elif defined(CL_PLATFORM_AMD)
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
#elif defined(CL_PLATFORM_NVIDIA)
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
#else
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
#endif
g_cxMainContext = btOpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
int numDev = btOpenCLUtils::getNumDevices(g_cxMainContext);
if (!numDev)
return false;
g_cdDevice = btOpenCLUtils::getDevice(g_cxMainContext,0);
btOpenCLDeviceInfo clInfo;
btOpenCLUtils::getDeviceInfo(g_cdDevice,clInfo);
btOpenCLUtils::printDeviceInfo(g_cdDevice);
// create a command-queue
g_cqCommandQue = clCreateCommandQueue(g_cxMainContext, g_cdDevice, 0, &ciErrNum);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
return true;
}
#endif //#ifdef USE_AMD_OPENCL
int main(int argc,char** argv)
{
#ifdef USE_AMD_OPENCL
bool initialized = initCL(0,0);
btAssert(initialized);
#endif //USE_AMD_OPENCL
BulletXmlImportDemo serializeDemo;
serializeDemo.initPhysics();
#ifdef CHECK_MEMORY_LEAKS
serializeDemo.exitPhysics();
#else
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.org",&serializeDemo);
#endif
//default glut doesn't return from mainloop
return 0;
}

View File

@ -1,71 +0,0 @@
IF (USE_DX11 AND BUILD_MULTITHREADING)
SUBDIRS(DX11ClothDemo)
ENDIF()
SUBDIRS( HelloWorld )
IF (USE_GLUT)
IF (GLUT_FOUND)
IF(BUILD_CPU_DEMOS)
IF(BUILD_EXTRAS)
SUBDIRS(AllBulletDemos BulletXmlImportDemo ConcaveDemo ConstraintDemo ConvexDecompositionDemo SerializeDemo )
ENDIF()
SET(SharedDemoSubdirs
OpenGL
CcdPhysicsDemo SliderConstraintDemo GenericJointDemo Raytracer
RagdollDemo ForkLiftDemo BasicDemo FeatherstoneMultiBodyDemo RollingFrictionDemo RaytestDemo VoronoiFractureDemo
GyroscopicDemo FractureDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
UserCollisionAlgorithm CharacterDemo SoftDemo
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
ConvexHullDistance
DoublePrecisionDemo CollisionDemo
ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
MultiMaterialDemo InternalEdgeDemo
)
ELSE()
SET(SharedDemoSubdirs OpenGL )
ENDIF(BUILD_CPU_DEMOS)
IF(BUILD_MULTITHREADING)
SUBDIRS( MultiThreadedDemo OpenCLClothDemo )
ENDIF(BUILD_MULTITHREADING)
SUBDIRS(
${SharedDemoSubdirs}
Benchmarks
)
IF(BUILD_MULTITHREADING)
SUBDIRS( ThreadingDemo VectorAdd_OpenCL )
ENDIF()
ENDIF(GLUT_FOUND)
ELSE (USE_GLUT)
IF (WIN32)
SUBDIRS(
OpenGL
BasicDemo
RaytestDemo
FractureDemo
Benchmarks
Box2dDemo
CollisionInterfaceDemo
ConcaveDemo
ConstraintDemo
RollingFrictionDemo
ConvexDecompositionDemo
InternalEdgeDemo
GimpactTestDemo
GyroscopicDemo
FeatherstoneMultiBodyDemo
GenericJointDemo
SerializeDemo
SoftDemo
VectorAdd_OpenCL
VoronoiFractureDemo
)
ENDIF(WIN32)
ENDIF (USE_GLUT)

View File

@ -1,59 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppCcdPhysicsDemo
main.cpp
CcdPhysicsDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCcdPhysicsDemo
main.cpp
CcdPhysicsDemo.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCcdPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCcdPhysicsDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}/Debug
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppCcdPhysicsDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppCcdPhysicsDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppCcdPhysicsDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,424 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#define CUBE_HALF_EXTENTS 1
#define EXTRA_HEIGHT 1.f
#include "CcdPhysicsDemo.h"
#include "GlutStuff.h"
#include "GLDebugFont.h"
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
#include "btBulletDynamicsCommon.h"
#include <stdio.h> //printf debugging
#include "GLDebugDrawer.h"
#if 0
extern btAlignedObjectArray<btVector3> debugContacts;
extern btAlignedObjectArray<btVector3> debugNormals;
#endif
static GLDebugDrawer sDebugDrawer;
CcdPhysicsDemo::CcdPhysicsDemo()
:m_ccdMode(USE_CCD)
{
setDebugMode(btIDebugDraw::DBG_DrawText+btIDebugDraw::DBG_NoHelpText);
setCameraDistance(btScalar(40.));
}
void CcdPhysicsDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//simple dynamics world doesn't handle fixed-time-stepping
//float ms = getDeltaTimeMicroseconds();
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(1./60.,0);//ms / 1000000.f);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
}
renderme();
displayText();
#if 0
for (int i=0;i<debugContacts.size();i++)
{
getDynamicsWorld()->getDebugDrawer()->drawContactPoint(debugContacts[i],debugNormals[i],0,0,btVector3(1,0,0));
}
#endif
glFlush();
swapBuffers();
}
void CcdPhysicsDemo::displayText()
{
int lineWidth=440;
int xStart = m_glutScreenWidth - lineWidth;
int yStart = 20;
if((getDebugMode() & btIDebugDraw::DBG_DrawText)!=0)
{
setOrthographicProjection();
glDisable(GL_LIGHTING);
glColor3f(0, 0, 0);
char buf[124];
glRasterPos3f(xStart, yStart, 0);
switch (m_ccdMode)
{
case USE_CCD:
{
sprintf(buf,"Predictive contacts and motion clamping");
break;
}
case USE_NO_CCD:
{
sprintf(buf,"CCD handling disabled");
break;
}
default:
{
sprintf(buf,"unknown CCD setting");
};
};
GLDebugDrawString(xStart,20,buf);
glRasterPos3f(xStart, yStart, 0);
sprintf(buf,"Press 'p' to change CCD mode");
yStart+=20;
GLDebugDrawString(xStart,yStart,buf);
glRasterPos3f(xStart, yStart, 0);
sprintf(buf,"Press '.' or right mouse to shoot bullets");
yStart+=20;
GLDebugDrawString(xStart,yStart,buf);
glRasterPos3f(xStart, yStart, 0);
sprintf(buf,"space to restart, h(elp), t(ext), w(ire)");
yStart+=20;
GLDebugDrawString(xStart,yStart,buf);
resetPerspectiveProjection();
glEnable(GL_LIGHTING);
}
}
void CcdPhysicsDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
displayText();
//optional but useful: debug drawing to detect problems
if (m_dynamicsWorld)
{
m_dynamicsWorld->debugDrawWorld();
}
#if 0
for (int i=0;i<debugContacts.size();i++)
{
getDynamicsWorld()->getDebugDrawer()->drawContactPoint(debugContacts[i],debugNormals[i],0,0,btVector3(1,0,0));
}
#endif
glFlush();
swapBuffers();
}
void CcdPhysicsDemo::initPhysics()
{
setTexturing(true);
setShadows(true);
m_ShootBoxInitialSpeed = 4000.f;
m_defaultContactProcessingThreshold = 0.f;
///collision configuration contains default setup for memory, collision setup
m_collisionConfiguration = new btDefaultCollisionConfiguration();
// m_collisionConfiguration->setConvexConvexMultipointIterations();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
//m_dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,m_collisionConfiguration->getCollisionAlgorithmCreateFunc(CONVEX_SHAPE_PROXYTYPE,CONVEX_SHAPE_PROXYTYPE));
m_broadphase = new btDbvtBroadphase();
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld->getSolverInfo().m_solverMode |=SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_RANDMIZE_ORDER;
m_dynamicsWorld ->setDebugDrawer(&sDebugDrawer);
//m_dynamicsWorld->getSolverInfo().m_splitImpulse=false;
if (m_ccdMode==USE_CCD)
{
m_dynamicsWorld->getDispatchInfo().m_useContinuous=true;
} else
{
m_dynamicsWorld->getDispatchInfo().m_useContinuous=false;
}
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
///create a few basic rigid bodies
btBoxShape* box = new btBoxShape(btVector3(btScalar(110.),btScalar(1.),btScalar(110.)));
// box->initializePolyhedralFeatures();
btCollisionShape* groundShape = box;
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
//m_collisionShapes.push_back(new btCylinderShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)));
m_collisionShapes.push_back(new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)));
btTransform groundTransform;
groundTransform.setIdentity();
//groundTransform.setOrigin(btVector3(5,5,5));
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
{
btScalar mass(0.);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
body->setFriction(0.5);
//body->setRollingFriction(0.3);
//add the body to the dynamics world
m_dynamicsWorld->addRigidBody(body);
}
{
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance
btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);
/// Create Dynamic Objects
btTransform startTransform;
startTransform.setIdentity();
btScalar mass(1.f);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
colShape->calculateLocalInertia(mass,localInertia);
int gNumObjects = 120;//120;
int i;
for (i=0;i<gNumObjects;i++)
{
btCollisionShape* shape = m_collisionShapes[1];
btTransform trans;
trans.setIdentity();
//stack them
int colsize = 10;
int row = (i*CUBE_HALF_EXTENTS*2)/(colsize*2*CUBE_HALF_EXTENTS);
int row2 = row;
int col = (i)%(colsize)-colsize/2;
if (col>3)
{
col=11;
row2 |=1;
}
btVector3 pos(col*2*CUBE_HALF_EXTENTS + (row2%2)*CUBE_HALF_EXTENTS,
row*2*CUBE_HALF_EXTENTS+CUBE_HALF_EXTENTS+EXTRA_HEIGHT,0);
trans.setOrigin(pos);
float mass = 1.f;
btRigidBody* body = localCreateRigidBody(mass,trans,shape);
body->setAnisotropicFriction(shape->getAnisotropicRollingFrictionDirection(),btCollisionObject::CF_ANISOTROPIC_ROLLING_FRICTION);
body->setFriction(0.5);
//body->setRollingFriction(.3);
///when using m_ccdMode
if (m_ccdMode==USE_CCD)
{
body->setCcdMotionThreshold(CUBE_HALF_EXTENTS);
body->setCcdSweptSphereRadius(0.9*CUBE_HALF_EXTENTS);
}
}
}
}
void CcdPhysicsDemo::clientResetScene()
{
exitPhysics();
initPhysics();
}
void CcdPhysicsDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key=='p')
{
switch (m_ccdMode)
{
case USE_CCD:
{
m_ccdMode = USE_NO_CCD;
break;
}
case USE_NO_CCD:
default:
{
m_ccdMode = USE_CCD;
}
};
clientResetScene();
} else
{
DemoApplication::keyboardCallback(key,x,y);
}
}
void CcdPhysicsDemo::shootBox(const btVector3& destination)
{
if (m_dynamicsWorld)
{
float mass = 1.f;
btTransform startTransform;
startTransform.setIdentity();
btVector3 camPos = getCameraPosition();
startTransform.setOrigin(camPos);
setShootBoxShape ();
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
body->setLinearFactor(btVector3(1,1,1));
//body->setRestitution(1);
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
linVel.normalize();
linVel*=m_ShootBoxInitialSpeed;
body->getWorldTransform().setOrigin(camPos);
body->getWorldTransform().setRotation(btQuaternion(0,0,0,1));
body->setLinearVelocity(linVel);
body->setAngularVelocity(btVector3(0,0,0));
body->setContactProcessingThreshold(1e30);
///when using m_ccdMode, disable regular CCD
if (m_ccdMode==USE_CCD)
{
body->setCcdMotionThreshold(CUBE_HALF_EXTENTS);
body->setCcdSweptSphereRadius(0.4f);
}
}
}
void CcdPhysicsDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
delete m_dynamicsWorld;
delete m_solver;
delete m_broadphase;
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,94 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_CCD_PHYSICS_DEMO_H
#define BT_CCD_PHYSICS_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
///CcdPhysicsDemo is good starting point for learning the code base and porting.
class CcdPhysicsDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
enum
{
USE_CCD=1,
USE_NO_CCD
};
int m_ccdMode;
btDefaultCollisionConfiguration* m_collisionConfiguration;
public:
CcdPhysicsDemo();
virtual ~CcdPhysicsDemo()
{
exitPhysics();
}
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
void displayText();
virtual void keyboardCallback(unsigned char key, int x, int y);
virtual void displayCallback();
virtual void shootBox(const btVector3& destination);
virtual void clientResetScene();
static DemoApplication* Create()
{
CcdPhysicsDemo* demo = new CcdPhysicsDemo;
demo->myinit();
demo->initPhysics();
return demo;
}
};
#endif //BT_CCD_PHYSICS_DEMO_H

View File

@ -1,5 +0,0 @@
noinst_PROGRAMS=CcdPhysicsDemo
CcdPhysicsDemo_SOURCES=CcdPhysicsDemo.cpp CcdPhysicsDemo.h main.cpp
CcdPhysicsDemo_CXXFLAGS=-I@top_builddir@/src -I@top_builddir@/Demos/OpenGL $(CXXFLAGS)
CcdPhysicsDemo_LDADD=-L../OpenGL -lbulletopenglsupport -L../../src -lBulletDynamics -lBulletCollision -lLinearMath @opengl_LIBS@

View File

@ -1,49 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "CcdPhysicsDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
#ifdef __DEBUG_FPU_ISSUES
#define _GNU_SOURCE
#include <fenv.h>
#endif
GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
CcdPhysicsDemo* ccdDemo = new CcdPhysicsDemo();
#ifdef __DEBUG_FPU_ISSUES
// feenableexcept (FE_DIVBYZERO);
// feenableexcept (FE_INEXACT);
// feenableexcept (FE_INVALID);
// feenableexcept (FE_OVERFLOW|FE_DIVBYZERO|FE_UNDERFLOW);
// feenableexcept (FE_UNDERFLOW);
#endif
ccdDemo->initPhysics();
ccdDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.com",ccdDemo);
delete ccdDemo;
return 0;
}

View File

@ -1,277 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
//#define USE_GROUND_BOX 1
#define PRINT_CONTACT_STATISTICS 1
#define USE_PARALLEL_DISPATCHER 1
//#define USE_SIMPLE_DYNAMICS_WORLD 1
int gNumObjects = 5;
#define HALF_EXTENTS btScalar(1.)
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h"
#include "LinearMath/btIDebugDraw.h"
#include <stdio.h> //printf debugging
btScalar deltaTime = btScalar(1./60.);
btScalar gCollisionMargin = btScalar(0.05);
#include "BasicDemo2.h"
#ifdef USE_PARALLEL_DISPATCHER
#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
#include "BulletMultiThreaded/Win32ThreadSupport.h"
#include "BulletMultiThreaded/SpuLibspe2Support.h"
#include "BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif//USE_PARALLEL_DISPATCHER
#include <LinearMath/btAlignedObjectArray.h>
////////////////////////////////////
int main(int argc,char** argv)
{
BasicDemo ccdDemo;
ccdDemo.initPhysics();
int i;
for (i=0;i<5;i++)
ccdDemo.clientMoveAndDisplay();
ccdDemo.exitPhysics();
return 0;
}
extern int gNumManifold;
void BasicDemo::clientMoveAndDisplay()
{
//simple dynamics world doesn't handle fixed-time-stepping
float ms = m_clock.getTimeMicroseconds();
m_clock.reset();
float minFPS = 1000000.f/60.f;
if (ms > minFPS)
ms = minFPS;
if (m_dynamicsWorld)
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
//some additional debugging info
#ifdef PRINT_CONTACT_STATISTICS
printf("num contact manifolds: %i\n",gNumManifold);
int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
printf("contact manifold[%d],pointA[%d]=(%f,%f,%f)\n",i,j,ptA[0],ptA[1],ptA[2]);
}
}
#endif //PRINT_CONTACT_STATISTICS
}
void BasicDemo::initPhysics()
{
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
int maxNumOutstandingTasks = 1;//number of maximum outstanding tasks
#ifdef USE_WIN32_THREADING
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"collision",
processCollisionTask,
createCollisionLocalStoreMemory,
maxNumOutstandingTasks));
#else
spe_program_handle_t * program_handle;
#ifndef USE_CESOF
char* spuFileName = "../../../src/BulletMultiThreaded/out/spuCollision.elf";
program_handle = spe_image_open (spuFileName);
if (program_handle == NULL)
{
printf( "SPU OPEN IMAGE ERROR:%s\n",spuFileName);
exit(0);
}
else
{
printf( "IMAGE OPENED:%s\n",spuFileName);
}
#else
extern spe_program_handle_t spu_program;
program_handle = &spu_program;
#endif
SpuLibspe2Support* threadSupport = new SpuLibspe2Support( program_handle, maxNumOutstandingTasks);
#endif // WIN32
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
#else
m_dispatcher = new btCollisionDispatcher(collisionConfiguration);
#endif //USE_PARALLEL_DISPATCHER
m_collisionConfiguration = new btDefaultCollisionConfiguration();
#define USE_SWEEP_AND_PRUNE 1
#ifdef USE_SWEEP_AND_PRUNE
#define maxProxies 8192
btVector3 worldAabbMin(-10000,-10000,-10000);
btVector3 worldAabbMax(10000,10000,10000);
m_overlappingPairCache = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
//m_overlappingPairCache = new btMultiSapBroadphase();
#else
m_overlappingPairCache = new btSimpleBroadphase;
#endif //USE_SWEEP_AND_PRUNE
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
///create a few basic rigid bodies
//static ground
#ifdef USE_GROUND_BOX
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
#else
btCollisionShape* groundShape = new btSphereShape(btScalar(50.));
#endif//USE_GROUND_BOX
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
//btCollisionShape* sphereShape = new btBoxShape(btVector3(1,1,1));
btCollisionShape* sphereShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(sphereShape);
int i;
for (i=0;i<gNumObjects;i++)
{
sphereShape->setMargin(gCollisionMargin);
btTransform trans;
trans.setIdentity();
//stack them
int colsize = 2;
int row = (int)((i*HALF_EXTENTS*2)/(colsize*2*HALF_EXTENTS));
int row2 = row;
int col = (i)%(colsize)-colsize/2;
btVector3 pos(col*2*HALF_EXTENTS + (row2%2)*HALF_EXTENTS,
row*2*HALF_EXTENTS+HALF_EXTENTS,0);
trans.setOrigin(pos);
//btRigidBody* body = localCreateRigidBody(btScalar(1.),trans,sphereShape);
localCreateRigidBody(btScalar(1.),trans,sphereShape);
}
//clientResetScene();
}
btRigidBody* BasicDemo::localCreateRigidBody(btScalar mass,const btTransform& startTrans,btCollisionShape* colShape)
{
btVector3 inertia(0,0,0);
if (mass)
colShape->calculateLocalInertia(mass,inertia);
btRigidBody::btRigidBodyConstructionInfo rbci(mass,0,colShape,inertia);
rbci.m_startWorldTransform = startTrans;
btRigidBody* body = new btRigidBody(rbci);
m_dynamicsWorld->addRigidBody(body);
return body;
}
void BasicDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
//delete dynamics world
delete m_dynamicsWorld;
//delete solver
delete m_solver;
//delete broadphase
delete m_overlappingPairCache;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,62 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BASIC_DEMO_H
#define BASIC_DEMO_H
#include "LinearMath/btQuickprof.h"
class btDiscreteDynamicsworld;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
///BasicDemo is good starting point for learning the code base and porting.
class BasicDemo
{
btClock m_clock;
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btBroadphaseInterface* m_overlappingPairCache;
btCollisionDispatcher* m_dispatcher;
btDefaultCollisionConfiguration* m_collisionConfiguration;
btConstraintSolver* m_solver;
btDiscreteDynamicsWorld* m_dynamicsWorld;
btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
btCollisionAlgorithmCreateFunc* m_boxSphereCF;
btRigidBody* localCreateRigidBody(btScalar mass,const btTransform& startTrans,btCollisionShape* colShape);
public:
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
};
#endif //BASIC_DEMO_H

View File

@ -1,75 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
SET(CharacterDemo_SRCS
DynamicCharacterController.cpp
DynamicCharacterController.h
CharacterDemo.cpp
CharacterDemo.h
../BspDemo/BspConverter.cpp
../BspDemo/BspConverter.h
../BspDemo/BspLoader.cpp
../BspDemo/BspLoader.h
main.cpp
)
IF (WIN32)
ADD_EXECUTABLE(AppCharacterDemo
${CharacterDemo_SRCS}
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCharacterDemo
${CharacterDemo_SRCS}
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCharacterDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCharacterDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppCharacterDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/BspDemo.bsp ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppCharacterDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppCharacterDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppCharacterDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,531 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h"
#include "BulletCollision/CollisionDispatch/btGhostObject.h"
#include "GLDebugDrawer.h"
#include <stdio.h> //printf debugging
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#include "CharacterDemo.h"
#ifdef DYNAMIC_CHARACTER_CONTROLLER
#include "DynamicCharacterController.h"
#else
#include "BulletDynamics/Character/btKinematicCharacterController.h"
#endif
const int maxProxies = 32766;
const int maxOverlap = 65535;
static int gForward = 0;
static int gBackward = 0;
static int gLeft = 0;
static int gRight = 0;
static int gJump = 0;
CharacterDemo::CharacterDemo()
:
m_indexVertexArrays(0),
m_vertices(0),
m_cameraHeight(4.f),
m_minCameraDistance(3.f),
m_maxCameraDistance(10.f)
{
m_character = 0;
m_cameraPosition = btVector3(30,30,30);
}
void CharacterDemo::initPhysics()
{
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
m_collisionShapes.push_back(groundShape);
m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btAxisSweep3* sweepBP = new btAxisSweep3(worldMin,worldMax);
m_overlappingPairCache = sweepBP;
m_constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);
m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
#ifdef DYNAMIC_CHARACTER_CONTROLLER
m_character = new DynamicCharacterController ();
#else
btTransform startTransform;
startTransform.setIdentity ();
//startTransform.setOrigin (btVector3(0.0, 4.0, 0.0));
startTransform.setOrigin (btVector3(10.210098,-1.6433364,16.453260));
m_ghostObject = new btPairCachingGhostObject();
m_ghostObject->setWorldTransform(startTransform);
sweepBP->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
btScalar characterHeight=1.75;
btScalar characterWidth =1.75;
btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight);
m_ghostObject->setCollisionShape (capsule);
m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.35);
m_character = new btKinematicCharacterController (m_ghostObject,capsule,stepHeight);
#endif
////////////////
/// Create some basic environment from a Quake level
//m_dynamicsWorld->setGravity(btVector3(0,0,0));
btTransform tr;
tr.setIdentity();
const char* bspfilename = "BspDemo.bsp";
void* memoryBuffer = 0;
FILE* file = fopen(bspfilename,"r");
if (!file)
{
//cmake generated visual studio projects need 4 levels back
bspfilename = "../../../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//visual studio leaves the current working directory in the projectfiles folder
bspfilename = "../../BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (!file)
{
//visual studio leaves the current working directory in the projectfiles folder
bspfilename = "BspDemo.bsp";
file = fopen(bspfilename,"r");
}
if (file)
{
BspLoader bspLoader;
int size=0;
if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */
printf("Error: cannot get filesize from %s\n", bspfilename);
} else
{
//how to detect file size?
memoryBuffer = malloc(size+1);
fread(memoryBuffer,1,size,file);
bspLoader.loadBSPFile( memoryBuffer);
BspToBulletConverter bsp2bullet(this);
float bspScaling = 0.1f;
bsp2bullet.convertBsp(bspLoader,bspScaling);
}
fclose(file);
}
///only collide with static for now (no interaction with dynamic objects)
m_dynamicsWorld->addCollisionObject(m_ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
m_dynamicsWorld->addAction(m_character);
///////////////
clientResetScene();
setCameraDistance(56.f);
}
//to be implemented by the demo
void CharacterDemo::renderme()
{
updateCamera();
DemoApplication::renderme();
}
void CharacterDemo::debugDrawContacts()
{
// printf("numPairs = %d\n",m_customPairCallback->getOverlappingPairArray().size());
{
btManifoldArray manifoldArray;
btBroadphasePairArray& pairArray = m_ghostObject->getOverlappingPairCache()->getOverlappingPairArray();
int numPairs = pairArray.size();
for (int i=0;i<numPairs;i++)
{
manifoldArray.clear();
const btBroadphasePair& pair = pairArray[i];
btBroadphasePair* collisionPair = m_overlappingPairCache->getOverlappingPairCache()->findPair(pair.m_pProxy0,pair.m_pProxy1);
if (!collisionPair)
continue;
if (collisionPair->m_algorithm)
collisionPair->m_algorithm->getAllContactManifolds(manifoldArray);
for (int j=0;j<manifoldArray.size();j++)
{
btPersistentManifold* manifold = manifoldArray[j];
for (int p=0;p<manifold->getNumContacts();p++)
{
const btManifoldPoint&pt = manifold->getContactPoint(p);
btVector3 color(255,255,255);
m_dynamicsWorld->getDebugDrawer()->drawContactPoint(pt.getPositionWorldOnB(),pt.m_normalWorldOnB,pt.getDistance(),pt.getLifeTime(),color);
}
}
}
}
}
void CharacterDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
/* Character stuff &*/
if (m_character)
{
}
debugDrawContacts();
if (m_dynamicsWorld)
{
//during idle mode, just run 1 simulation step maximum
int maxSimSubSteps = m_idle ? 1 : 2;
if (m_idle)
dt = 1.0/420.f;
///set walkDirection for our character
btTransform xform;
xform = m_ghostObject->getWorldTransform ();
btVector3 forwardDir = xform.getBasis()[2];
// printf("forwardDir=%f,%f,%f\n",forwardDir[0],forwardDir[1],forwardDir[2]);
btVector3 upDir = xform.getBasis()[1];
btVector3 strafeDir = xform.getBasis()[0];
forwardDir.normalize ();
upDir.normalize ();
strafeDir.normalize ();
btVector3 walkDirection = btVector3(0.0, 0.0, 0.0);
btScalar walkVelocity = btScalar(1.1) * 4.0; // 4 km/h -> 1.1 m/s
btScalar walkSpeed = walkVelocity * dt;
//rotate view
if (gLeft)
{
btMatrix3x3 orn = m_ghostObject->getWorldTransform().getBasis();
orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0),0.01));
m_ghostObject->getWorldTransform ().setBasis(orn);
}
if (gRight)
{
btMatrix3x3 orn = m_ghostObject->getWorldTransform().getBasis();
orn *= btMatrix3x3(btQuaternion(btVector3(0,1,0),-0.01));
m_ghostObject->getWorldTransform ().setBasis(orn);
}
if (gForward)
walkDirection += forwardDir;
if (gBackward)
walkDirection -= forwardDir;
m_character->setWalkDirection(walkDirection*walkSpeed);
int numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps);
//optional but useful: debug drawing
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
//#define VERBOSE_FEEDBACK
#ifdef VERBOSE_FEEDBACK
if (!numSimSteps)
printf("Interpolated transforms\n");
else
{
if (numSimSteps > maxSimSubSteps)
{
//detect dropping frames
printf("Dropped (%i) simulation steps out of %i\n",numSimSteps - maxSimSubSteps,numSimSteps);
} else
{
printf("Simulated (%i) steps\n",numSimSteps);
}
}
#endif //VERBOSE_FEEDBACK
}
#ifdef USE_QUICKPROF
btProfiler::beginBlock("render");
#endif //USE_QUICKPROF
renderme();
#ifdef USE_QUICKPROF
btProfiler::endBlock("render");
#endif
glFlush();
glutSwapBuffers();
}
void CharacterDemo::displayCallback(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
debugDrawContacts();
glFlush();
glutSwapBuffers();
}
void CharacterDemo::clientResetScene()
{
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_ghostObject->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
m_character->reset (m_dynamicsWorld);
///WTF
m_character->warp (btVector3(10.210001,-2.0306311,16.576973));
}
void CharacterDemo::specialKeyboardUp(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_UP:
{
gForward = 0;
}
break;
case GLUT_KEY_DOWN:
{
gBackward = 0;
}
break;
case GLUT_KEY_LEFT:
{
gLeft = 0;
}
break;
case GLUT_KEY_RIGHT:
{
gRight = 0;
}
break;
default:
DemoApplication::specialKeyboardUp(key,x,y);
break;
}
}
void CharacterDemo::specialKeyboard(int key, int x, int y)
{
// printf("key = %i x=%i y=%i\n",key,x,y);
switch (key)
{
case GLUT_KEY_UP:
{
gForward = 1;
}
break;
case GLUT_KEY_DOWN:
{
gBackward = 1;
}
break;
case GLUT_KEY_LEFT:
{
gLeft = 1;
}
break;
case GLUT_KEY_RIGHT:
{
gRight = 1;
}
break;
case GLUT_KEY_F1:
{
if (m_character && m_character->canJump())
gJump = 1;
}
break;
default:
DemoApplication::specialKeyboard(key,x,y);
break;
}
// glutPostRedisplay();
}
void CharacterDemo::updateCamera()
{
//#define DISABLE_CAMERA 1
#ifdef DISABLE_CAMERA
DemoApplication::updateCamera();
return;
#endif //DISABLE_CAMERA
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
btTransform characterWorldTrans;
//look at the vehicle
characterWorldTrans = m_ghostObject->getWorldTransform();
btVector3 up = characterWorldTrans.getBasis()[1];
btVector3 backward = -characterWorldTrans.getBasis()[2];
up.normalize ();
backward.normalize ();
m_cameraTargetPosition = characterWorldTrans.getOrigin();
m_cameraPosition = m_cameraTargetPosition + up * 10.0 + backward * 12.0;
//use the convex sweep test to find a safe position for the camera (not blocked by static geometry)
btSphereShape cameraSphere(0.2f);
btTransform cameraFrom,cameraTo;
cameraFrom.setIdentity();
cameraFrom.setOrigin(characterWorldTrans.getOrigin());
cameraTo.setIdentity();
cameraTo.setOrigin(m_cameraPosition);
btCollisionWorld::ClosestConvexResultCallback cb( characterWorldTrans.getOrigin(), cameraTo.getOrigin() );
cb.m_collisionFilterMask = btBroadphaseProxy::StaticFilter;
m_dynamicsWorld->convexSweepTest(&cameraSphere,cameraFrom,cameraTo,cb);
if (cb.hasHit())
{
btScalar minFraction = cb.m_closestHitFraction;//btMax(btScalar(0.3),cb.m_closestHitFraction);
m_cameraPosition.setInterpolate3(cameraFrom.getOrigin(),cameraTo.getOrigin(),minFraction);
}
//update OpenGL camera settings
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2],
m_cameraTargetPosition[0],m_cameraTargetPosition[1], m_cameraTargetPosition[2],
m_cameraUp.getX(),m_cameraUp.getY(),m_cameraUp.getZ());
}
CharacterDemo::~CharacterDemo()
{
//cleanup in the reverse order of creation/initialization
if (m_character)
{
m_dynamicsWorld->removeCollisionObject(m_ghostObject);
}
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
delete m_indexVertexArrays;
delete m_vertices;
//delete dynamics world
delete m_dynamicsWorld;
//delete solver
delete m_constraintSolver;
//delete broadphase
delete m_overlappingPairCache;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,153 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CHARACTER_DEMO_H
#define CHARACTER_DEMO_H
///DYNAMIC_CHARACTER_CONTROLLER is not fully implemented yet at the moment
//#define DYNAMIC_CHARACTER_CONTROLLER 1
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
class btCharacterControllerInterface;
class btDynamicCharacterController;
class btKinematicCharacterController;
class btCollisionShape;
#include "GlutDemoApplication.h"
///CharacterDemo shows how to setup and use the built-in raycast vehicle
class CharacterDemo : public GlutDemoApplication
{
public:
#ifdef DYNAMIC_CHARACTER_CONTROLLER
btCharacterControllerInterface* m_character;
#else
btKinematicCharacterController* m_character;
class btPairCachingGhostObject* m_ghostObject;
#endif
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
class btBroadphaseInterface* m_overlappingPairCache;
class btCollisionDispatcher* m_dispatcher;
class btConstraintSolver* m_constraintSolver;
class btDefaultCollisionConfiguration* m_collisionConfiguration;
class btTriangleIndexVertexArray* m_indexVertexArrays;
btVector3* m_vertices;
void debugDrawContacts();
float m_cameraHeight;
float m_minCameraDistance;
float m_maxCameraDistance;
CharacterDemo();
virtual ~CharacterDemo();
virtual void clientMoveAndDisplay();
virtual void clientResetScene();
virtual void displayCallback();
///a very basic camera following the character
virtual void updateCamera();
virtual void specialKeyboard(int key, int x, int y);
virtual void specialKeyboardUp(int key, int x, int y);
void renderme();
void initPhysics();
static DemoApplication* Create()
{
CharacterDemo* demo = new CharacterDemo();
demo->myinit();
demo->initPhysics();
return demo;
}
};
#define QUAKE_BSP_IMPORTING 1
#ifdef QUAKE_BSP_IMPORTING
#include "../BspDemo/BspLoader.h"
#include "../BspDemo/BspConverter.h"
class BspToBulletConverter : public BspConverter
{
CharacterDemo* m_demoApp;
public:
BspToBulletConverter(CharacterDemo* demoApp)
:m_demoApp(demoApp)
{
}
virtual void addConvexVerticesCollider(btAlignedObjectArray<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
{
///perhaps we can do something special with entities (isEntity)
///like adding a collision Triggering (as example)
if (vertices.size() > 0)
{
float mass = 0.f;
btTransform startTransform;
//can use a shift
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-10.0f,0.0f));
//this create an internal copy of the vertices
for (int i = 0; i < vertices.size(); i++)
{
vertices[i] *= btScalar(0.5);
float t = vertices[i].getZ() * btScalar(0.75);
vertices[i].setZ(-vertices[i].getY());
vertices[i].setY(t);
}
btCollisionShape* shape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
m_demoApp->m_collisionShapes.push_back(shape);
//btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
m_demoApp->localCreateRigidBody(mass, startTransform,shape);
}
}
};
#endif //QUAKE_BSP_IMPORTING
#endif //CHARACTER_DEMO_H

View File

@ -1,204 +0,0 @@
#include "BulletCollision/CollisionShapes/btMultiSphereShape.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
#include "LinearMath/btDefaultMotionState.h"
#include "DynamicCharacterController.h"
DynamicCharacterController::DynamicCharacterController ()
{
m_rayLambda[0] = 1.0;
m_rayLambda[1] = 1.0;
m_halfHeight = 1.0;
m_turnAngle = 0.0;
m_maxLinearVelocity = 10.0;
m_walkVelocity = 8.0; // meters/sec
m_turnVelocity = 1.0; // radians/sec
m_shape = NULL;
m_rigidBody = NULL;
}
DynamicCharacterController::~DynamicCharacterController ()
{
}
void DynamicCharacterController::setup (btScalar height, btScalar width, btScalar stepHeight)
{
btVector3 spherePositions[2];
btScalar sphereRadii[2];
sphereRadii[0] = width;
sphereRadii[1] = width;
spherePositions[0] = btVector3 (0.0, (height/btScalar(2.0) - width), 0.0);
spherePositions[1] = btVector3 (0.0, (-height/btScalar(2.0) + width), 0.0);
m_halfHeight = height/btScalar(2.0);
m_shape = new btMultiSphereShape (&spherePositions[0], &sphereRadii[0], 2);
btTransform startTransform;
startTransform.setIdentity ();
startTransform.setOrigin (btVector3(0.0, 2.0, 0.0));
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo cInfo(1.0, myMotionState, m_shape);
m_rigidBody = new btRigidBody(cInfo);
// kinematic vs. static doesn't work
//m_rigidBody->setCollisionFlags( m_rigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
m_rigidBody->setSleepingThresholds (0.0, 0.0);
m_rigidBody->setAngularFactor (0.0);
}
void DynamicCharacterController::destroy ()
{
if (m_shape)
{
delete m_shape;
}
if (m_rigidBody)
{
delete m_rigidBody;
m_rigidBody = 0;
}
}
btCollisionObject* DynamicCharacterController::getCollisionObject ()
{
return m_rigidBody;
}
void DynamicCharacterController::preStep (const btCollisionWorld* collisionWorld)
{
btTransform xform;
m_rigidBody->getMotionState()->getWorldTransform (xform);
btVector3 down = -xform.getBasis()[1];
btVector3 forward = xform.getBasis()[2];
down.normalize ();
forward.normalize();
m_raySource[0] = xform.getOrigin();
m_raySource[1] = xform.getOrigin();
m_rayTarget[0] = m_raySource[0] + down * m_halfHeight * btScalar(1.1);
m_rayTarget[1] = m_raySource[1] + forward * m_halfHeight * btScalar(1.1);
class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback
{
public:
ClosestNotMe (btRigidBody* me) : btCollisionWorld::ClosestRayResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0))
{
m_me = me;
}
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
if (rayResult.m_collisionObject == m_me)
return 1.0;
return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace
);
}
protected:
btRigidBody* m_me;
};
ClosestNotMe rayCallback(m_rigidBody);
int i = 0;
for (i = 0; i < 2; i++)
{
rayCallback.m_closestHitFraction = 1.0;
collisionWorld->rayTest (m_raySource[i], m_rayTarget[i], rayCallback);
if (rayCallback.hasHit())
{
m_rayLambda[i] = rayCallback.m_closestHitFraction;
} else {
m_rayLambda[i] = 1.0;
}
}
}
void DynamicCharacterController::playerStep (const btCollisionWorld* dynaWorld,btScalar dt,
int forward,
int backward,
int left,
int right,
int jump)
{
btTransform xform;
m_rigidBody->getMotionState()->getWorldTransform (xform);
/* Handle turning */
if (left)
m_turnAngle -= dt * m_turnVelocity;
if (right)
m_turnAngle += dt * m_turnVelocity;
xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle));
btVector3 linearVelocity = m_rigidBody->getLinearVelocity();
btScalar speed = m_rigidBody->getLinearVelocity().length();
btVector3 forwardDir = xform.getBasis()[2];
forwardDir.normalize ();
btVector3 walkDirection = btVector3(0.0, 0.0, 0.0);
btScalar walkSpeed = m_walkVelocity * dt;
if (forward)
walkDirection += forwardDir;
if (backward)
walkDirection -= forwardDir;
if (!forward && !backward && onGround())
{
/* Dampen when on the ground and not being moved by the player */
linearVelocity *= btScalar(0.2);
m_rigidBody->setLinearVelocity (linearVelocity);
} else {
if (speed < m_maxLinearVelocity)
{
btVector3 velocity = linearVelocity + walkDirection * walkSpeed;
m_rigidBody->setLinearVelocity (velocity);
}
}
m_rigidBody->getMotionState()->setWorldTransform (xform);
m_rigidBody->setCenterOfMassTransform (xform);
}
bool DynamicCharacterController::canJump () const
{
return onGround();
}
void DynamicCharacterController::jump ()
{
if (!canJump())
return;
btTransform xform;
m_rigidBody->getMotionState()->getWorldTransform (xform);
btVector3 up = xform.getBasis()[1];
up.normalize ();
btScalar magnitude = (btScalar(1.0)/m_rigidBody->getInvMass()) * btScalar(8.0);
m_rigidBody->applyCentralImpulse (up * magnitude);
}
bool DynamicCharacterController::onGround () const
{
return m_rayLambda[0] < btScalar(1.0);
}
void DynamicCharacterController::reset ()
{
}
void DynamicCharacterController::warp (const btVector3& origin)
{
}
void DynamicCharacterController::registerPairCacheAndDispatcher (btOverlappingPairCache* pairCache, btCollisionDispatcher* dispatcher)
{
}

View File

@ -1,55 +0,0 @@
#ifndef CHARACTER_CONTROLLER_H
#define CHARACTER_CONTROLLER_H
#include "LinearMath/btVector3.h"
#include "BulletDynamics/Character/btCharacterControllerInterface.h"
class btCollisionShape;
class btRigidBody;
class btCollisionWorld;
///DynamicCharacterController is obsolete/unsupported at the moment
class DynamicCharacterController : public btCharacterControllerInterface
{
protected:
btScalar m_halfHeight;
btCollisionShape* m_shape;
btRigidBody* m_rigidBody;
btVector3 m_raySource[2];
btVector3 m_rayTarget[2];
btScalar m_rayLambda[2];
btVector3 m_rayNormal[2];
btScalar m_turnAngle;
btScalar m_maxLinearVelocity;
btScalar m_walkVelocity;
btScalar m_turnVelocity;
public:
DynamicCharacterController ();
~DynamicCharacterController ();
void setup (btScalar height = 2.0, btScalar width = 0.25, btScalar stepHeight = 0.25);
void destroy ();
virtual void reset ();
virtual void warp (const btVector3& origin);
virtual void registerPairCacheAndDispatcher (btOverlappingPairCache* pairCache, btCollisionDispatcher* dispatcher);
btCollisionObject* getCollisionObject ();
void preStep (const btCollisionWorld* collisionWorld);
void playerStep (const btCollisionWorld* collisionWorld,btScalar dt,
int forward,
int backward,
int left,
int right,
int jump);
bool canJump () const;
void jump ();
bool onGround () const;
};
#endif

View File

@ -1,19 +0,0 @@
#include "CharacterDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
CharacterDemo* characterDemo = new CharacterDemo;
characterDemo->initPhysics();
characterDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
return glutmain(argc, argv,640,480,"Bullet Character Demo. http://www.continuousphysics.com/Bullet/phpBB2/", characterDemo);
}

View File

@ -1,54 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppCollisionDemo
CollisionDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCollisionDemo
CollisionDemo.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCollisionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCollisionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppCollisionDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppCollisionDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppCollisionDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,380 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
///
/// Collision Demo shows a degenerate case, where the Simplex solver has to deal with near-affine dependent cases
/// See the define CATCH_DEGENERATE_TETRAHEDRON in Bullet's btVoronoiSimplexSolver.cpp
///
//#define CHECK_GENSHER_TRIANGLE_CASE 1
///This low-level internal demo does intentionally NOT use the btBulletCollisionCommon.h header
///It needs internal access
#include "GL_Simplex1to4.h"
#include "LinearMath/btQuaternion.h"
#include "LinearMath/btTransform.h"
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
#include "BulletCollision/NarrowPhaseCollision/btPointCollector.h"
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
#include "LinearMath/btTransformUtil.h"
#include "CollisionDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#include "LinearMath/btIDebugDraw.h"
#include "../OpenGL/GLDebugDrawer.h"
GLDebugDrawer debugDrawer;
float yaw=0.f,pitch=0.f,roll=0.f;
const int maxNumObjects = 4;
const int numObjects = 2;
GL_Simplex1to4 simplex;
btPolyhedralConvexShape* shapePtr[maxNumObjects];
btTransform tr[numObjects];
int screenWidth = 640;
int screenHeight = 480;
void DrawRasterizerLine(float const* , float const*, int)
{
}
int main(int argc,char** argv)
{
CollisionDemo* colDemo = new CollisionDemo();
#ifdef CHECK_GENSHER_TRIANGLE_CASE
colDemo->setCameraDistance(8.f);
#else
colDemo->setCameraDistance(4.f);
#endif //
colDemo->initPhysics();
return glutmain(argc, argv,screenWidth,screenHeight,"Collision Demo",colDemo);
}
void CollisionDemo::initPhysics()
{
setTexturing(false);
setShadows(false);
//m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
#ifdef CHECK_GENSHER_TRIANGLE_CASE
m_azi = 140.f;
#else
m_azi = 250.f;
#endif
m_ele = 25.f;
m_azi = 0;
m_ele = 0;
m_cameraTargetPosition.setValue(8.12,0.39,0);
tr[0].setIdentity();
tr[0].setOrigin(btVector3(10,0,0));
tr[1].setIdentity();
tr[1].setOrigin(btVector3(0,0,0));
#ifdef CHECK_GENSHER_TRIANGLE_CASE
tr[0].setIdentity();
tr[1].setIdentity();
#endif //CHECK_GENSHER_TRIANGLE_CASE
btVector3 boxHalfExtentsA(1,1,1);//1.0000004768371582f,1.0000004768371582f,1.0000001192092896f);
btVector3 boxHalfExtentsB(4,4,4);//3.2836332321166992f,3.2836332321166992f,3.2836320400238037f);
#ifndef CHECK_GENSHER_TRIANGLE_CASE
btBoxShape* boxA = new btBoxShape(boxHalfExtentsA);
btBoxShape* boxB = new btBoxShape(boxHalfExtentsB);
#endif
#ifdef CHECK_GENSHER_TRIANGLE_CASE
shapePtr[0] = trishapeA;
shapePtr[1] = trishapeB;
#else
shapePtr[0] = boxA;
shapePtr[1] = boxB;
#endif
}
void CollisionDemo::clientMoveAndDisplay()
{
displayCallback();
}
static btVoronoiSimplexSolver sGjkSimplexSolver;
btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver;
static btScalar gContactBreakingThreshold=.02f;
int myiter = 1;
int mystate = 2;
int checkPerturbation = 1;
int numPerturbationIterations = 20;
void CollisionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
btVoronoiSimplexSolver sGjkSimplexSolver;
btGjkEpaPenetrationDepthSolver epaSolver;
btPointCollector gjkOutput;
btVector3 worldBoundsMin(-1000,-1000,-1000);
btVector3 worldBoundsMax(1000,1000,1000);
{
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,&epaSolver);
btGjkPairDetector::ClosestPointInput input;
input.m_transformA = tr[0];
input.m_transformB = tr[1];
convexConvex.getClosestPoints(input, gjkOutput, 0);
}
ATTRIBUTE_ALIGNED16(btScalar) m[16];
int i;
//m_ele = 21.2;
//m_azi = -56.6;
for (i=0;i<numObjects;i++)
{
tr[i].getOpenGLMatrix( m );
//m_shapeDrawer->drawOpenGL(m,shapePtr[i],btVector3(119./255.,147./255.,60./255.),btIDebugDraw::DBG_FastWireframe,worldBoundsMin,worldBoundsMax);
m_shapeDrawer->drawOpenGL(m,shapePtr[i],btVector3(0.6,0.6,0.6),btIDebugDraw::DBG_FastWireframe,worldBoundsMin,worldBoundsMax);
}
if (gjkOutput.m_hasResult)
{
printf("original distance: %10.4f\n", gjkOutput.m_distance);
btVector3 endPt = gjkOutput.m_pointInWorld +
gjkOutput.m_normalOnBInWorld*gjkOutput.m_distance;
debugDrawer.drawLine(gjkOutput.m_pointInWorld,endPt,btVector3(0,0,0));
debugDrawer.drawSphere(gjkOutput.m_pointInWorld,0.05,btVector3(0,0,0));
debugDrawer.drawSphere(endPt,0.05,btVector3(0,0,0));
bool perturbeA = false;//true;
const btScalar angleLimit = 0.125f * SIMD_PI;
btScalar perturbeAngle;
btScalar radiusA = shapePtr[0]->getAngularMotionDisc();
btScalar radiusB = shapePtr[1]->getAngularMotionDisc();
if (radiusA < radiusB)
{
perturbeAngle = gContactBreakingThreshold /radiusA;
perturbeA = true;
} else
{
perturbeAngle = gContactBreakingThreshold / radiusB;
perturbeA = false;
}
if ( perturbeAngle > angleLimit )
perturbeAngle = angleLimit;
perturbeAngle*=5;
btVector3 v0,v1;
btPlaneSpace1(gjkOutput.m_normalOnBInWorld,v0,v1);
glLineWidth(5);
int i;
i=0;
if (myiter>=numPerturbationIterations)
myiter=0;
if (mystate<2)
{
i= myiter;
}
for ( ;i<numPerturbationIterations;i++)
{
btGjkPairDetector::ClosestPointInput input;
input.m_transformA = tr[0];
input.m_transformB = tr[1];
sGjkSimplexSolver.reset();
btQuaternion perturbeRot(v0,perturbeAngle);
btScalar iterationAngle = i*(SIMD_2_PI/btScalar(numPerturbationIterations));
btQuaternion rotq(gjkOutput.m_normalOnBInWorld,iterationAngle);
if (perturbeA)
{
input.m_transformA.setBasis( btMatrix3x3(rotq*perturbeRot*rotq.inverse())*tr[0].getBasis());
} else
{
input.m_transformB.setBasis( btMatrix3x3(rotq.inverse()*perturbeRot*rotq)*tr[1].getBasis());
}
debugDrawer.drawTransform(input.m_transformA,1.0);
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,&epaSolver);
input.m_maximumDistanceSquared = BT_LARGE_FLOAT;
gjkOutput.m_distance = BT_LARGE_FLOAT;
convexConvex.getClosestPoints(input, gjkOutput, 0);
if (mystate!=2 || i==myiter)
{
ATTRIBUTE_ALIGNED16(btScalar) m[16];
input.m_transformA.getOpenGLMatrix( m );
//m_shapeDrawer->drawOpenGL(m,shapePtr[0],btVector3(108./255.,131./255.,158./255),btIDebugDraw::DBG_FastWireframe,worldBoundsMin,worldBoundsMax);
m_shapeDrawer->drawOpenGL(m,shapePtr[0],btVector3(0.3,0.3,1),btIDebugDraw::DBG_FastWireframe,worldBoundsMin,worldBoundsMax);
}
if (1)//gjkOutput.m_hasResult)
{
printf("perturbed distance: %10.4f\n", gjkOutput.m_distance);
btVector3 startPt,endPt;
btScalar depth = 0;
if (perturbeA)
{
btVector3 endPtOrg = gjkOutput.m_pointInWorld + gjkOutput.m_normalOnBInWorld*gjkOutput.m_distance;
endPt = (tr[0]*input.m_transformA.inverse())(endPtOrg);
depth = (endPt - gjkOutput.m_pointInWorld).dot(gjkOutput.m_normalOnBInWorld);
startPt = endPt-gjkOutput.m_normalOnBInWorld*depth;
} else
{
endPt = gjkOutput.m_pointInWorld + gjkOutput.m_normalOnBInWorld*gjkOutput.m_distance;
startPt = (tr[1]*input.m_transformB.inverse())(gjkOutput.m_pointInWorld);
depth = (endPt - startPt).dot(gjkOutput.m_normalOnBInWorld);
}
printf("corrected distance: %10.4f\n", depth);
debugDrawer.drawLine(startPt,endPt,btVector3(1,0,0));
debugDrawer.drawSphere(startPt,0.05,btVector3(0,1,0));
debugDrawer.drawSphere(endPt,0.05,btVector3(0,0,1));
}
if (mystate<2)
break;
if (mystate==2 && i>myiter)
break;
}
}
static int looper = 0;
if (looper++>10)
{
looper =0;
checkPerturbation++;
if (checkPerturbation>numPerturbationIterations)
checkPerturbation=0;
}
GL_ShapeDrawer::drawCoordSystem();
if (mystate==1 || mystate==2)
{
static int count = 10;
count--;
if (count<0)
{
count=10;
myiter++;
}
}
btQuaternion orn;
orn.setEuler(yaw,pitch,roll);
//let it rotate
//tr[0].setRotation(orn);
pitch += 0.005f;
yaw += 0.01f;
glFlush();
glutSwapBuffers();
}
void CollisionDemo::specialKeyboard(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_DOWN:
case GLUT_KEY_UP:
{
break;
}
default:
DemoApplication::specialKeyboard(key,x,y);
break;
}
}
void CollisionDemo::specialKeyboardUp(int key, int x, int y)
{
switch (key)
{
case GLUT_KEY_UP :
{
myiter++;
break;
}
case GLUT_KEY_DOWN:
{
mystate++;
if (mystate>1)
myiter=0;
if (mystate>=4)
mystate = 0;
break;
}
default:
DemoApplication::specialKeyboardUp(key,x,y);
break;
}
}

View File

@ -1,38 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef COLLISION_DEMO_H
#define COLLISION_DEMO_H
#include "GlutDemoApplication.h"
///CollisionDemo shows the low-level direct access to GJK
class CollisionDemo : public GlutDemoApplication
{
public:
void initPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
virtual void specialKeyboardUp(int key, int x, int y);
virtual void specialKeyboard(int key, int x, int y);
};
#endif //COLLISION_DEMO_H

View File

@ -1,77 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
IF (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppCollisionInterfaceDemo
CollisionInterfaceDemo.cpp
CollisionInterfaceDemo.h
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCollisionInterfaceDemo
CollisionInterfaceDemo.cpp
CollisionInterfaceDemo.h
main.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCollisionInterfaceDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppCollisionInterfaceDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppCollisionInterfaceDemo
WIN32
CollisionInterfaceDemo.cpp
CollisionInterfaceDemo.h
Win32CollisionInterfaceDemo.cpp
../OpenGL/Win32AppMain.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppCollisionInterfaceDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppCollisionInterfaceDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppCollisionInterfaceDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,292 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
///
/// CollisionInterfaceDemo shows high level usage of the Collision Detection.
///
#define TEST_NOT_ADDING_OBJECTS_TO_WORLD
#include "GL_Simplex1to4.h"
//include common Bullet Collision Detection headerfiles
#include "btBulletCollisionCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "GL_ShapeDrawer.h"
#include "CollisionInterfaceDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
btScalar yaw=0.f,pitch=0.f,roll=0.f;
const int maxNumObjects = 4;
const int numObjects = 2;
GL_Simplex1to4 simplex;
btCollisionObject objects[maxNumObjects];
btCollisionWorld* collisionWorld = 0;
GLDebugDrawer debugDrawer;
void CollisionInterfaceDemo::initPhysics()
{
m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
btMatrix3x3 basisA;
basisA.setIdentity();
btMatrix3x3 basisB;
basisB.setIdentity();
objects[0].getWorldTransform().setBasis(basisA);
objects[1].getWorldTransform().setBasis(basisB);
btBoxShape* boxA = new btBoxShape(btVector3(1,1,1));
boxA->setMargin(0.f);
btBoxShape* boxB = new btBoxShape(btVector3(0.5,0.5,0.5));
boxB->setMargin(0.f);
//ConvexHullShape hullA(points0,3);
//hullA.setLocalScaling(btVector3(3,3,3));
//ConvexHullShape hullB(points1,4);
//hullB.setLocalScaling(btVector3(4,4,4));
objects[0].setCollisionShape(boxA);//&hullA;
objects[1].setCollisionShape(boxB);//&hullB;
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btVector3 worldAabbMin(-1000,-1000,-1000);
btVector3 worldAabbMax(1000,1000,1000);
btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
//SimpleBroadphase is a brute force alternative, performing N^2 aabb overlap tests
//SimpleBroadphase* broadphase = new btSimpleBroadphase;
collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);
collisionWorld->setDebugDrawer(&debugDrawer);
#ifdef TEST_NOT_ADDING_OBJECTS_TO_WORLD
// collisionWorld->addCollisionObject(&objects[0]);
collisionWorld->addCollisionObject(&objects[1]);
#endif //TEST_NOT_ADDING_OBJECTS_TO_WORLD
}
//to be implemented by the demo
void CollisionInterfaceDemo::clientMoveAndDisplay()
{
displayCallback();
}
static btVoronoiSimplexSolver sGjkSimplexSolver;
btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver;
struct btDrawingResult : public btCollisionWorld::ContactResultCallback
{
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
glBegin(GL_LINES);
glColor3f(0, 0, 0);
btVector3 ptA = cp.getPositionWorldOnA();
btVector3 ptB = cp.getPositionWorldOnB();
glVertex3d(ptA.x(),ptA.y(),ptA.z());
glVertex3d(ptB.x(),ptB.y(),ptB.z());
glEnd();
return 0;
}
};
void CollisionInterfaceDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
btScalar m[16];
btVector3 worldBoundsMin,worldBoundsMax;
collisionWorld->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);
int i;
for (i=0;i<numObjects;i++)
{
objects[i].getWorldTransform().getOpenGLMatrix( m );
m_shapeDrawer->drawOpenGL(m,objects[i].getCollisionShape(),btVector3(1,1,1),getDebugMode(),worldBoundsMin,worldBoundsMax);
}
collisionWorld->getDispatchInfo().m_debugDraw = &debugDrawer;
if (collisionWorld)
collisionWorld->performDiscreteCollisionDetection();
#ifndef TEST_NOT_ADDING_OBJECTS_TO_WORLD
collisionWorld->debugDrawWorld();
///one way to draw all the contact points is iterating over contact manifolds in the dispatcher:
int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
for (i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
glBegin(GL_LINES);
glColor3f(0, 0, 0);
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
glVertex3d(ptA.x(),ptA.y(),ptA.z());
glVertex3d(ptB.x(),ptB.y(),ptB.z());
glEnd();
}
//you can un-comment out this line, and then all points are removed
//contactManifold->clearManifold();
}
#else
glDisable(GL_TEXTURE_2D);
for (i=0;i<numObjects;i++)
{
collisionWorld->debugDrawObject(objects[i].getWorldTransform(),objects[i].getCollisionShape(), btVector3(1,1,0));
}
btDrawingResult renderCallback;
//collisionWorld->contactPairTest(&objects[0],&objects[1], renderCallback);
collisionWorld->contactTest(&objects[0],renderCallback);
#if 0
//another way is to directly query the dispatcher for both objects. The objects don't need to be inserted into the world
btCollisionAlgorithm* algo = collisionWorld->getDispatcher()->findAlgorithm(&objects[0],&objects[1]);
btManifoldResult contactPointResult(&objects[0],&objects[1]);
algo->processCollision(&objects[0],&objects[1],collisionWorld->getDispatchInfo(),&contactPointResult);
btManifoldArray manifoldArray;
algo->getAllContactManifolds(manifoldArray);
int numManifolds = manifoldArray.size();
for (i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = manifoldArray[i];
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
// btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
glDisable(GL_DEPTH_TEST);
int numContacts = contactManifold->getNumContacts();
bool swap = obA == &objects[0];
for (int j=0;j<numContacts;j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
glBegin(GL_LINES);
glColor3f(0, 0, 0);
btVector3 ptA = swap ?pt.getPositionWorldOnA():pt.getPositionWorldOnB();
btVector3 ptB = swap ? pt.getPositionWorldOnB():pt.getPositionWorldOnA();
glVertex3d(ptA.x(),ptA.y(),ptA.z());
glVertex3d(ptB.x(),ptB.y(),ptB.z());
glEnd();
}
//you can un-comment out this line, and then all points are removed
//contactManifold->clearManifold();
}
#endif
#endif
//GL_ShapeDrawer::drawCoordSystem();
// btQuaternion qA = objects[0].getWorldTransform().getRotation();
// btQuaternion qB = objects[1].getWorldTransform().getRotation();
if (!m_idle)
{
btScalar timeInSeconds = getDeltaTimeMicroseconds()/1000.f;
btQuaternion orn;
objects[0].getWorldTransform().getBasis().getEulerYPR(yaw,pitch,roll);
pitch += 0.00005f*timeInSeconds;
yaw += 0.0001f*timeInSeconds;
objects[0].getWorldTransform().getBasis().setEulerYPR(yaw,pitch,roll);
orn.setEuler(yaw,pitch,roll);
objects[1].getWorldTransform().setOrigin(objects[1].getWorldTransform().getOrigin()+btVector3(0,-0.00001*timeInSeconds,0));
//objects[0].getWorldTransform().setRotation(orn);
}
glFlush();
swapBuffers();
}
void CollisionInterfaceDemo::clientResetScene()
{
objects[0].getWorldTransform().setOrigin(btVector3(0.0f,3.f,0.f));
btQuaternion rotA(0.739f,-0.204f,0.587f,0.257f);
rotA.normalize();
objects[0].getWorldTransform().setRotation(rotA);
objects[1].getWorldTransform().setOrigin(btVector3(0.0f,4.248f,0.f));
}

View File

@ -1,42 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef COLLISION_INTERFACE_DEMO_H
#define COLLISION_INTERFACE_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
///CollisionInterfaceDemo shows how to use the collision detection without dynamics (btCollisionWorld/CollisionObject)
class CollisionInterfaceDemo : public PlatformDemoApplication
{
public:
void initPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
virtual void clientResetScene();
};
#endif //COLLISION_INTERFACE_DEMO_H

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "CollisionInterfaceDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new CollisionInterfaceDemo();
}
#endif

View File

@ -1,19 +0,0 @@
#include "CollisionInterfaceDemo.h"
#include "GlutStuff.h"
#include "btBulletDynamicsCommon.h"
int screenWidth = 640;
int screenHeight = 480;
int main(int argc,char** argv)
{
CollisionInterfaceDemo* collisionInterfaceDemo = new CollisionInterfaceDemo();
collisionInterfaceDemo->initPhysics();
collisionInterfaceDemo->clientResetScene();
return glutmain(argc, argv,screenWidth,screenHeight,"Collision Interface Demo",collisionInterfaceDemo);
}

View File

@ -1,48 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConcaveConvexCastDemo
ConcaveConvexcastDemo.cpp
main.cpp
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveConvexCastDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveConvexCastDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConcaveConvexCastDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConcaveConvexCastDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConcaveConvexCastDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,516 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "GLDebugDrawer.h"
#include "ConcaveConvexcastDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#define NUM_DYNAMIC_BOXES_X 30
#define NUM_DYNAMIC_BOXES_Y 30
static btVector3* gVertices=0;
static int* gIndices=0;
static btBvhTriangleMeshShape* trimeshShape =0;
static btRigidBody* staticBody = 0;
static float waveheight = 5.f;
const float TRIANGLE_SIZE=8.f;
/* Scrolls back and forth over terrain */
#define NUMRAYS_IN_BAR 100
class btConvexcastBatch
{
public:
btVector3 source[NUMRAYS_IN_BAR];
btVector3 dest[NUMRAYS_IN_BAR];
btVector3 direction[NUMRAYS_IN_BAR];
btVector3 hit_com[NUMRAYS_IN_BAR];
btVector3 hit_surface[NUMRAYS_IN_BAR];
btScalar hit_fraction[NUMRAYS_IN_BAR];
btVector3 normal[NUMRAYS_IN_BAR];
int frame_counter;
int ms;
int sum_ms;
int sum_ms_samples;
int min_ms;
int max_ms;
#ifdef USE_BT_CLOCK
btClock frame_timer;
#endif //USE_BT_CLOCK
btScalar dx;
btScalar min_x;
btScalar max_x;
btScalar min_y;
btScalar max_y;
btScalar sign;
btVector3 boxShapeHalfExtents;
btBoxShape boxShape;
btConvexcastBatch () : boxShape(btVector3(0.0, 0.0, 0.0))
{
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
}
btConvexcastBatch (bool unused, btScalar ray_length, btScalar min_z, btScalar max_z, btScalar min_y , btScalar max_y ) : boxShape(btVector3(0.0, 0.0, 0.0))
{
boxShapeHalfExtents = btVector3(1.0, 1.0, 1.0);
boxShape = btBoxShape(boxShapeHalfExtents);
frame_counter = 0;
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
dx = 10.0;
min_x = -40;
max_x = 20;
this->min_y = min_y;
this->max_y = max_y;
sign = 1.0;
// btScalar dalpha = 2*SIMD_2_PI/NUMRAYS_IN_BAR;
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btScalar z = (max_z-min_z)/NUMRAYS_IN_BAR * i + min_z;
source[i] = btVector3(min_x, max_y, z);
dest[i] = btVector3(min_x + ray_length, min_y, z);
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
btConvexcastBatch (btScalar ray_length, btScalar z, btScalar min_y = -1000, btScalar max_y = 10) : boxShape(btVector3(0.0, 0.0, 0.0))
{
boxShapeHalfExtents = btVector3(1.0, 1.0, 1.0);
boxShape = btBoxShape(boxShapeHalfExtents);
frame_counter = 0;
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
dx = 10.0;
min_x = -40;
max_x = 20;
this->min_y = min_y;
this->max_y = max_y;
sign = 1.0;
btScalar dalpha = btScalar(2)*SIMD_2_PI/btScalar(NUMRAYS_IN_BAR);
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btScalar alpha = dalpha * btScalar(i);
// rotate around by alpha degrees y
btTransform tr(btQuaternion(btVector3(0.0, 1.0, 0.0), alpha));
direction[i] = btVector3(1.0, 0.0, 0.0);
direction[i] = tr * direction[i];
source[i] = btVector3(min_x, max_y, z);
dest[i] = source[i] + direction[i] * ray_length;
dest[i][1] = min_y;
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
void move (btScalar dt)
{
if (dt > (1.0/60.0))
dt = 1.0/60.0;
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
source[i][0] += dx * dt * sign;
dest[i][0] += dx * dt * sign;
}
if (source[0][0] < min_x)
sign = 1.0;
else if (source[0][0] > max_x)
sign = -1.0;
}
void cast (btCollisionWorld* cw)
{
#ifdef USE_BT_CLOCK
frame_timer.reset ();
#endif //USE_BT_CLOCK
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btCollisionWorld::ClosestConvexResultCallback cb(source[i], dest[i]);
btQuaternion qFrom;
btQuaternion qTo;
qFrom.setRotation (btVector3(1.0, 0.0, 0.0), 0.0);
qTo.setRotation (btVector3(1.0, 0.0, 0.0), 0.7);
btTransform from(qFrom, source[i]);
btTransform to(qTo, dest[i]);
cw->convexSweepTest (&boxShape, from, to, cb);
if (cb.hasHit ())
{
hit_surface[i] = cb.m_hitPointWorld;
hit_com[i].setInterpolate3(source[i], dest[i], cb.m_closestHitFraction);
hit_fraction[i] = cb.m_closestHitFraction;
normal[i] = cb.m_hitNormalWorld;
normal[i].normalize ();
} else {
hit_com[i] = dest[i];
hit_surface[i] = dest[i];
hit_fraction[i] = 1.0f;
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
#ifdef USE_BT_CLOCK
ms += frame_timer.getTimeMilliseconds ();
#endif //USE_BT_CLOCK
frame_counter++;
if (frame_counter > 50)
{
min_ms = ms < min_ms ? ms : min_ms;
max_ms = ms > max_ms ? ms : max_ms;
sum_ms += ms;
sum_ms_samples++;
btScalar mean_ms = (btScalar)sum_ms/(btScalar)sum_ms_samples;
printf("%d rays in %d ms %d %d %f\n", NUMRAYS_IN_BAR * frame_counter, ms, min_ms, max_ms, mean_ms);
ms = 0;
frame_counter = 0;
}
}
void drawCube (const btTransform& T)
{
ATTRIBUTE_ALIGNED16(btScalar) m[16];
T.getOpenGLMatrix (&m[0]);
glPushMatrix ();
#ifdef BT_USE_DOUBLE_PRECISION
glMultMatrixd (&m[0]);
glScaled (2.0 * boxShapeHalfExtents[0], 2.0 * boxShapeHalfExtents[1], 2.0 * boxShapeHalfExtents[2]);
#else
glMultMatrixf (&m[0]);
glScalef (2.0 * boxShapeHalfExtents[0], 2.0 * boxShapeHalfExtents[1], 2.0 * boxShapeHalfExtents[2]);
#endif //BT_USE_DOUBLE_PRECISION
glutSolidCube (1.0);
glPopMatrix ();
}
void draw ()
{
glDisable (GL_LIGHTING);
glColor3f (0.0, 1.0, 0.0);
glBegin (GL_LINES);
int i;
for (i = 0; i < NUMRAYS_IN_BAR; i++)
{
glVertex3f (source[i][0], source[i][1], source[i][2]);
glVertex3f (hit_com[i][0], hit_com[i][1], hit_com[i][2]);
}
glColor3f (1.0, 1.0, 1.0);
glBegin (GL_LINES);
btScalar normal_scale = 10.0; // easier to see if this is big
for (i = 0; i < NUMRAYS_IN_BAR; i++)
{
glVertex3f (hit_surface[i][0], hit_surface[i][1], hit_surface[i][2]);
glVertex3f (hit_surface[i][0] + normal_scale * normal[i][0], hit_surface[i][1] + normal_scale * normal[i][1], hit_surface[i][2] + normal_scale * normal[i][2]);
}
glEnd ();
glColor3f (0.0, 1.0, 1.0);
btQuaternion qFrom;
btQuaternion qTo;
qFrom.setRotation (btVector3(1.0, 0.0, 0.0), 0.0);
qTo.setRotation (btVector3(1.0, 0.0, 0.0), 0.7);
for ( i = 0; i < NUMRAYS_IN_BAR; i++)
{
btTransform from(qFrom, source[i]);
btTransform to(qTo, dest[i]);
btVector3 linVel, angVel;
btTransformUtil::calculateVelocity (from, to, 1.0, linVel, angVel);
btTransform T;
btTransformUtil::integrateTransform (from, linVel, angVel, hit_fraction[i], T);
drawCube (T);
}
glEnable (GL_LIGHTING);
}
};
static btConvexcastBatch convexcastBatch;
const int NUM_VERTS_X = 30;
const int NUM_VERTS_Y = 30;
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
void ConcaveConvexcastDemo::setVertexPositions(float waveheight, float offset)
{
int i;
int j;
for ( i=0;i<NUM_VERTS_X;i++)
{
for (j=0;j<NUM_VERTS_Y;j++)
{
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
//0.f,
waveheight*sinf((float)i+offset)*cosf((float)j+offset),
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
}
}
}
void ConcaveConvexcastDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key == 'g')
{
m_animatedMesh = !m_animatedMesh;
if (m_animatedMesh)
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->setActivationState(DISABLE_DEACTIVATION);
} else
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->forceActivationState(ACTIVE_TAG);
}
}
DemoApplication::keyboardCallback(key,x,y);
}
void ConcaveConvexcastDemo::initPhysics()
{
#define TRISIZE 10.f
setCameraDistance(100.f);
int vertStride = sizeof(btVector3);
int indexStride = 3*sizeof(int);
const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1);
gVertices = new btVector3[totalVerts];
gIndices = new int[totalTriangles*3];
int i;
setVertexPositions(waveheight,0.f);
int index=0;
for ( i=0;i<NUM_VERTS_X-1;i++)
{
for (int j=0;j<NUM_VERTS_Y-1;j++)
{
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = j*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i;
}
}
m_indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
gIndices,
indexStride,
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
bool useQuantizedAabbCompression = true;
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
m_collisionShapes.push_back(trimeshShape);
btCollisionShape* groundShape = trimeshShape;
m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
m_broadphase = new btAxisSweep3(worldMin,worldMax);
m_solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
float mass = 0.f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-2,0));
btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
m_collisionShapes.push_back(colShape);
{
for (int j=0;j<NUM_DYNAMIC_BOXES_X;j++)
for (int i=0;i<NUM_DYNAMIC_BOXES_Y;i++)
{
//btCollisionShape* colShape = new btCapsuleShape(0.5,2.0);//boxShape = new btSphereShape(1.f);
startTransform.setOrigin(btVector3(5*(i-NUM_DYNAMIC_BOXES_X/2),10,5*(j-NUM_DYNAMIC_BOXES_Y/2)));
localCreateRigidBody(1, startTransform,colShape);
}
}
startTransform.setIdentity();
//startTransform = btTransform(btQuaternion (btVector3(1,1,1), 1.5));
staticBody = localCreateRigidBody(mass, startTransform,groundShape);
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
//enable custom material callback
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
convexcastBatch = btConvexcastBatch (40.0, 0.0, -10.0,80.0);
//convexcastBatch = btConvexcastBatch (true, 40.0, -50.0, 50.0);
}
void ConcaveConvexcastDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
if (m_animatedMesh)
{
static float offset=0.f;
offset+=0.01f;
int i;
int j;
btVector3 aabbMin(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
btVector3 aabbMax(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
for ( i=NUM_VERTS_X/2-3;i<NUM_VERTS_X/2+2;i++)
{
for (j=NUM_VERTS_X/2-3;j<NUM_VERTS_Y/2+2;j++)
{
aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);
aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
//0.f,
waveheight*sinf((float)i+offset)*cosf((float)j+offset),
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);
}
}
trimeshShape->partialRefitTree(aabbMin,aabbMax);
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
}
m_dynamicsWorld->stepSimulation(dt);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
convexcastBatch.move (dt);
convexcastBatch.cast (m_dynamicsWorld);
renderme();
convexcastBatch.draw ();
glFlush();
glutSwapBuffers();
}
void ConcaveConvexcastDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
convexcastBatch.draw ();
glFlush();
glutSwapBuffers();
}
void ConcaveConvexcastDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
//delete dynamics world
delete m_dynamicsWorld;
if (m_indexVertexArrays)
delete m_indexVertexArrays;
//delete solver
delete m_solver;
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,84 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONCAVE_CONVEXCAST_DEMO_H
#define CONCAVE_CONVEXCAST_DEMO_H
#include "GlutDemoApplication.h"
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btTriangleIndexVertexArray;
///ConcaveRaycaseDemo shows usage of static concave triangle meshes
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
class ConcaveConvexcastDemo : public GlutDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btTriangleIndexVertexArray* m_indexVertexArrays;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
bool m_animatedMesh;
public:
ConcaveConvexcastDemo() : m_animatedMesh(true)
{
}
void initPhysics();
void exitPhysics();
virtual ~ConcaveConvexcastDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
//to show refit works
void setVertexPositions(float waveheight, float offset);
virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
ConcaveConvexcastDemo* demo = new ConcaveConvexcastDemo();
demo->myinit();
demo->initPhysics();
return demo;
};
};
#endif //CONCAVE_CONVEXCAST_DEMO_H

View File

@ -1,15 +0,0 @@
#include "ConcaveConvexcastDemo.h"
#include "GlutStuff.h"
int main(int argc,char** argv)
{
ConcaveConvexcastDemo* concaveConvexcastDemo = new ConcaveConvexcastDemo();
concaveConvexcastDemo->initPhysics();
concaveConvexcastDemo->setCameraDistance(30.f);
return glutmain(argc, argv,640,480,"Concave Convexcast Demo",concaveConvexcastDemo);
}

View File

@ -1,80 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
IF (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision BulletFileLoader LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppConcaveDemo
ConcavePhysicsDemo.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConcaveDemo
ConcavePhysicsDemo.cpp
main.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision BulletFileLoader LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConcaveDemo
WIN32
../OpenGL/Win32AppMain.cpp
ConcavePhysicsDemo.cpp
ConcaveDemo.h
Win32ConcaveDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConcaveDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConcaveDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConcaveDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,91 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONCAVE_DEMO_H
#define CONCAVE_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btTriangleIndexVertexArray;
///ConcaveDemo shows usage of static concave triangle meshes
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
class ConcaveDemo : public PlatformDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btTriangleIndexVertexArray* m_indexVertexArrays;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
bool m_animatedMesh;
public:
ConcaveDemo() : m_animatedMesh(true)
{
}
void initPhysics();
void exitPhysics();
virtual ~ConcaveDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
//to show refit works
void setVertexPositions(float waveheight, float offset);
virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
ConcaveDemo* demo = new ConcaveDemo();
demo->myinit();
demo->initPhysics();
return demo;
};
};
#endif //CONCAVE_DEMO_H

View File

@ -1,474 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "GLDebugDrawer.h"
#include "ConcaveDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#define SERIALIZE_TO_DISK 1
#ifndef SERIALIZE_TO_DISK
#include "btBulletWorldImporter.h"
#endif //SERIALIZE_TO_DISK
//by default, the sample only (de)serializes the BVH to disk.
//If you enable the SERIALIZE_SHAPE define then it will serialize the entire collision shape
//then the animation will not play, because it is using the deserialized vertices
//#define SERIALIZE_SHAPE
//#define USE_PARALLEL_DISPATCHER 1
#ifdef USE_PARALLEL_DISPATCHER
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif//USE_PARALLEL_DISPATCHER
static btVector3* gVertices=0;
static int* gIndices=0;
static btBvhTriangleMeshShape* trimeshShape =0;
static btRigidBody* staticBody = 0;
static float waveheight = 5.f;
const float TRIANGLE_SIZE=8.f;
///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
inline btScalar calculateCombinedFriction(float friction0,float friction1)
{
btScalar friction = friction0 * friction1;
const btScalar MAX_FRICTION = 10.f;
if (friction < -MAX_FRICTION)
friction = -MAX_FRICTION;
if (friction > MAX_FRICTION)
friction = MAX_FRICTION;
return friction;
}
inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
{
return restitution0 * restitution1;
}
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
float friction0 = colObj0Wrap->getCollisionObject()->getFriction();
float friction1 = colObj1Wrap->getCollisionObject()->getFriction();
float restitution0 = colObj0Wrap->getCollisionObject()->getRestitution();
float restitution1 = colObj1Wrap->getCollisionObject()->getRestitution();
if (colObj0Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
friction0 = 1.0;//partId0,index0
restitution0 = 0.f;
}
if (colObj1Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
if (index1&1)
{
friction1 = 1.0f;//partId1,index1
} else
{
friction1 = 0.f;
}
restitution1 = 0.f;
}
cp.m_combinedFriction = calculateCombinedFriction(friction0,friction1);
cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
//this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
return true;
}
extern ContactAddedCallback gContactAddedCallback;
const int NUM_VERTS_X = 30;
const int NUM_VERTS_Y = 30;
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
void ConcaveDemo::setVertexPositions(float waveheight, float offset)
{
int i;
int j;
for ( i=0;i<NUM_VERTS_X;i++)
{
for (j=0;j<NUM_VERTS_Y;j++)
{
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
//0.f,
waveheight*sinf((float)i+offset)*cosf((float)j+offset),
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
}
}
}
void ConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key == 'g')
{
m_animatedMesh = !m_animatedMesh;
if (m_animatedMesh)
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->setActivationState(DISABLE_DEACTIVATION);
} else
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->forceActivationState(ACTIVE_TAG);
}
}
DemoApplication::keyboardCallback(key,x,y);
}
void ConcaveDemo::initPhysics()
{
setTexturing(true);
setShadows(false);//true);
#define TRISIZE 10.f
gContactAddedCallback = CustomMaterialCombinerCallback;
#define USE_TRIMESH_SHAPE 1
#ifdef USE_TRIMESH_SHAPE
int vertStride = sizeof(btVector3);
int indexStride = 3*sizeof(int);
const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1);
gVertices = new btVector3[totalVerts];
gIndices = new int[totalTriangles*3];
int i;
setVertexPositions(waveheight,0.f);
int index=0;
for ( i=0;i<NUM_VERTS_X-1;i++)
{
for (int j=0;j<NUM_VERTS_Y-1;j++)
{
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = j*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i;
}
}
m_indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
gIndices,
indexStride,
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
bool useQuantizedAabbCompression = true;
//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
#ifdef SERIALIZE_TO_DISK
btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax);
m_collisionShapes.push_back(trimeshShape);
int maxSerializeBufferSize = 1024*1024*5;
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
//serializer->setSerializationFlags(BT_SERIALIZE_NO_BVH);// or BT_SERIALIZE_NO_TRIANGLEINFOMAP
serializer->startSerialization();
//registering a name is optional, it allows you to retrieve the shape by name
//serializer->registerNameForPointer(trimeshShape,"mymesh");
#ifdef SERIALIZE_SHAPE
trimeshShape->serializeSingleShape(serializer);
#else
trimeshShape->serializeSingleBvh(serializer);
#endif
serializer->finishSerialization();
FILE* f2 = fopen("myShape.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2);
fclose(f2);
#else
btBulletWorldImporter import(0);//don't store info into the world
if (import.loadFile("myShape.bullet"))
{
int numBvh = import.getNumBvhs();
if (numBvh)
{
btOptimizedBvh* bvh = import.getBvhByIndex(0);
btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax,false);
trimeshShape->setOptimizedBvh(bvh);
//trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax);
//trimeshShape->setOptimizedBvh(bvh);
}
int numShape = import.getNumCollisionShapes();
if (numShape)
{
trimeshShape = (btBvhTriangleMeshShape*)import.getCollisionShapeByIndex(0);
//if you know the name, you can also try to get the shape by name:
const char* meshName = import.getNameForPointer(trimeshShape);
if (meshName)
trimeshShape = (btBvhTriangleMeshShape*)import.getCollisionShapeByName(meshName);
}
}
#endif
btCollisionShape* groundShape = trimeshShape;
#else
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
m_collisionShapes.push_back(groundShape);
#endif //USE_TRIMESH_SHAPE
m_collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
#ifdef USE_WIN32_THREADING
int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"collision",
processCollisionTask,
createCollisionLocalStoreMemory,
maxNumOutstandingTasks));
#else
///@todo show other platform threading
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
///Libspe2 SPU support will be available soon
///pthreads version
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
#endif
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,m_collisionConfiguration);
#else
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
#endif//USE_PARALLEL_DISPATCHER
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
m_broadphase = new btAxisSweep3(worldMin,worldMax);
m_solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
#ifdef USE_PARALLEL_DISPATCHER
m_dynamicsWorld->getDispatchInfo().m_enableSPU=true;
#endif //USE_PARALLEL_DISPATCHER
float mass = 0.f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-2,0));
#ifdef USE_BOX_SHAPE
btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
#else
btCompoundShape* colShape = new btCompoundShape;
btCollisionShape* cylinderShape = new btCylinderShapeX(btVector3(4,1,1));
btCollisionShape* boxShape = new btBoxShape(btVector3(4,1,1));
btTransform localTransform;
localTransform.setIdentity();
colShape->addChildShape(localTransform,boxShape);
btQuaternion orn(SIMD_HALF_PI,0,0);
localTransform.setRotation(orn);
colShape->addChildShape(localTransform,cylinderShape);
#endif //USE_BOX_SHAPE
m_collisionShapes.push_back(colShape);
{
for (int i=0;i<10;i++)
{
startTransform.setOrigin(btVector3(2,10+i*2,1));
localCreateRigidBody(1, startTransform,colShape);
}
}
startTransform.setIdentity();
staticBody = localCreateRigidBody(mass, startTransform,groundShape);
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);//STATIC_OBJECT);
//enable custom material callback
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
}
void ConcaveDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
if (m_animatedMesh)
{
static float offset=0.f;
offset+=dt;
// setVertexPositions(waveheight,offset);
int i;
int j;
btVector3 aabbMin(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
btVector3 aabbMax(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
for ( i=NUM_VERTS_X/2-3;i<NUM_VERTS_X/2+2;i++)
{
for (j=NUM_VERTS_X/2-3;j<NUM_VERTS_Y/2+2;j++)
{
aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);
aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
//0.f,
waveheight*sinf((float)i+offset)*cosf((float)j+offset),
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
aabbMin.setMin(gVertices[i+j*NUM_VERTS_X]);
aabbMax.setMax(gVertices[i+j*NUM_VERTS_X]);
}
}
trimeshShape->partialRefitTree(aabbMin,aabbMax);
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
}
m_dynamicsWorld->stepSimulation(dt);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
renderme();
glFlush();
swapBuffers();
}
void ConcaveDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderme();
//optional but useful: debug drawing
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
glFlush();
swapBuffers();
}
void ConcaveDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
//delete dynamics world
delete m_dynamicsWorld;
if (m_indexVertexArrays)
delete m_indexVertexArrays;
//delete solver
delete m_solver;
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}

View File

@ -1,3 +0,0 @@
SubDir TOP Demos ConcaveDemo ;
BulletDemo ConcaveDemo : [ Wildcard *.h *.cpp ] ;

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "ConcaveDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new ConcaveDemo();
}
#endif

View File

@ -1,19 +0,0 @@
#include "ConcaveDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
ConcaveDemo* concaveDemo = new ConcaveDemo();
concaveDemo->initPhysics();
concaveDemo->setCameraDistance(30.f);
concaveDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
return glutmain(argc, argv,640,480,"Static Concave Mesh Demo",concaveDemo);
}

View File

@ -1,57 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppConcaveRayCastDemo
ConcaveRaycastDemo.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConcaveRayCastDemo
ConcaveRaycastDemo.cpp
main.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveRayCastDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConcaveRayCastDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConcaveRayCastDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConcaveRayCastDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConcaveRayCastDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,490 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "GLDebugDrawer.h"
#include "ConcaveRaycastDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
static GLDebugDrawer sDebugDraw;
static btVector3* gVertices=0;
static int* gIndices=0;
static btBvhTriangleMeshShape* trimeshShape =0;
static btRigidBody* staticBody = 0;
static float waveheight = 5.f;
const float TRIANGLE_SIZE=8.f;
/* Scrolls back and forth over terrain */
#define NUMRAYS_IN_BAR 100
class btRaycastBar
{
public:
btVector3 source[NUMRAYS_IN_BAR];
btVector3 dest[NUMRAYS_IN_BAR];
btVector3 direction[NUMRAYS_IN_BAR];
btVector3 hit[NUMRAYS_IN_BAR];
btVector3 normal[NUMRAYS_IN_BAR];
int frame_counter;
int ms;
int sum_ms;
int sum_ms_samples;
int min_ms;
int max_ms;
#ifdef USE_BT_CLOCK
btClock frame_timer;
#endif //USE_BT_CLOCK
btScalar dx;
btScalar min_x;
btScalar max_x;
btScalar min_y;
btScalar max_y;
btScalar sign;
btRaycastBar ()
{
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
}
btRaycastBar (bool unused, btScalar ray_length, btScalar min_z, btScalar max_z, btScalar min_y = -10, btScalar max_y = 10)
{
frame_counter = 0;
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
dx = 10.0;
min_x = -40;
max_x = 20;
this->min_y = min_y;
this->max_y = max_y;
sign = 1.0;
// btScalar dalpha = 2*SIMD_2_PI/NUMRAYS_IN_BAR;
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btScalar z = (max_z-min_z)/btScalar(NUMRAYS_IN_BAR) * btScalar(i) + min_z;
source[i] = btVector3(min_x, max_y, z);
dest[i] = btVector3(min_x + ray_length, min_y, z);
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
btRaycastBar (btScalar ray_length, btScalar z, btScalar min_y = -1000, btScalar max_y = 10)
{
frame_counter = 0;
ms = 0;
max_ms = 0;
min_ms = 9999.0;
sum_ms_samples = 0;
sum_ms = 0;
dx = 10.0;
min_x = -40;
max_x = 20;
this->min_y = min_y;
this->max_y = max_y;
sign = 1.0;
btScalar dalpha = 2*SIMD_2_PI/NUMRAYS_IN_BAR;
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btScalar alpha = dalpha * i;
// rotate around by alpha degrees y
btTransform tr (btQuaternion (btVector3(0.0, 1.0, 0.0), alpha));
direction[i] = btVector3(1.0, 0.0, 0.0);
direction[i] = tr* direction[i];
direction[i] = direction[i] * ray_length;
source[i] = btVector3(min_x, max_y, z);
dest[i] = source[i] + direction[i];
dest[i][1] = min_y;
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
void move (btScalar dt)
{
if (dt > (1.0/60.0))
dt = 1.0/60.0;
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
source[i][0] += dx * dt * sign;
dest[i][0] += dx * dt * sign;
}
if (source[0][0] < min_x)
sign = 1.0;
else if (source[0][0] > max_x)
sign = -1.0;
}
void cast (btCollisionWorld* cw)
{
#ifdef USE_BT_CLOCK
frame_timer.reset ();
#endif //USE_BT_CLOCK
#ifdef BATCH_RAYCASTER
if (!gBatchRaycaster)
return;
gBatchRaycaster->clearRays ();
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
gBatchRaycaster->addRay (source[i], dest[i]);
}
gBatchRaycaster->performBatchRaycast ();
for (int i = 0; i < gBatchRaycaster->getNumRays (); i++)
{
const SpuRaycastTaskWorkUnitOut& out = (*gBatchRaycaster)[i];
hit[i].setInterpolate3(source[i],dest[i],out.hitFraction);
normal[i] = out.hitNormal;
normal[i].normalize ();
}
#else
for (int i = 0; i < NUMRAYS_IN_BAR; i++)
{
btCollisionWorld::ClosestRayResultCallback cb(source[i], dest[i]);
cw->rayTest (source[i], dest[i], cb);
if (cb.hasHit ())
{
hit[i] = cb.m_hitPointWorld;
normal[i] = cb.m_hitNormalWorld;
normal[i].normalize ();
} else {
hit[i] = dest[i];
normal[i] = btVector3(1.0, 0.0, 0.0);
}
}
#ifdef USE_BT_CLOCK
ms += frame_timer.getTimeMilliseconds ();
#endif //USE_BT_CLOCK
frame_counter++;
if (frame_counter > 50)
{
min_ms = ms < min_ms ? ms : min_ms;
max_ms = ms > max_ms ? ms : max_ms;
sum_ms += ms;
sum_ms_samples++;
btScalar mean_ms = (btScalar)sum_ms/(btScalar)sum_ms_samples;
printf("%d rays in %d ms %d %d %f\n", NUMRAYS_IN_BAR * frame_counter, ms, min_ms, max_ms, mean_ms);
ms = 0;
frame_counter = 0;
}
#endif
}
void draw ()
{
glDisable (GL_LIGHTING);
glColor3f (0.0, 1.0, 0.0);
glBegin (GL_LINES);
int i;
for (i = 0; i < NUMRAYS_IN_BAR; i++)
{
glVertex3f (source[i][0], source[i][1], source[i][2]);
glVertex3f (hit[i][0], hit[i][1], hit[i][2]);
}
glEnd ();
glColor3f (1.0, 1.0, 1.0);
glBegin (GL_LINES);
for (i = 0; i < NUMRAYS_IN_BAR; i++)
{
glVertex3f (hit[i][0], hit[i][1], hit[i][2]);
glVertex3f (hit[i][0] + normal[i][0], hit[i][1] + normal[i][1], hit[i][2] + normal[i][2]);
}
glEnd ();
glColor3f (0.0, 1.0, 1.0);
glBegin (GL_POINTS);
for ( i = 0; i < NUMRAYS_IN_BAR; i++)
{
glVertex3f (hit[i][0], hit[i][1], hit[i][2]);
}
glEnd ();
glEnable (GL_LIGHTING);
}
};
static btRaycastBar raycastBar;
const int NUM_VERTS_X = 30;
const int NUM_VERTS_Y = 30;
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
void ConcaveRaycastDemo::setVertexPositions(float waveheight, float offset)
{
int i;
int j;
for ( i=0;i<NUM_VERTS_X;i++)
{
for (j=0;j<NUM_VERTS_Y;j++)
{
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
//0.f,
waveheight*sinf((float)i+offset)*cosf((float)j+offset),
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
}
}
}
void ConcaveRaycastDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key == 'g')
{
m_animatedMesh = !m_animatedMesh;
if (m_animatedMesh)
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->setActivationState(DISABLE_DEACTIVATION);
} else
{
staticBody->setCollisionFlags( staticBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
staticBody->forceActivationState(ACTIVE_TAG);
}
}
DemoApplication::keyboardCallback(key,x,y);
}
void ConcaveRaycastDemo::initPhysics()
{
#define TRISIZE 10.f
int vertStride = sizeof(btVector3);
int indexStride = 3*sizeof(int);
const int totalTriangles = 2*(NUM_VERTS_X-1)*(NUM_VERTS_Y-1);
gVertices = new btVector3[totalVerts];
gIndices = new int[totalTriangles*3];
int i;
setVertexPositions(waveheight,0.f);
int index=0;
for ( i=0;i<NUM_VERTS_X-1;i++)
{
for (int j=0;j<NUM_VERTS_Y-1;j++)
{
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = j*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = j*NUM_VERTS_X+i;
gIndices[index++] = (j+1)*NUM_VERTS_X+i+1;
gIndices[index++] = (j+1)*NUM_VERTS_X+i;
}
}
m_indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
gIndices,
indexStride,
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
bool useQuantizedAabbCompression = true;
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
m_collisionShapes.push_back(trimeshShape);
btCollisionShape* groundShape = trimeshShape;
m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
m_broadphase = new btAxisSweep3(worldMin,worldMax);
m_solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld->getSolverInfo().m_splitImpulse=true;
m_dynamicsWorld->setDebugDrawer(&sDebugDraw);
float mass = 0.f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-2,0));
btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
m_collisionShapes.push_back(colShape);
{
for (int i=0;i<10;i++)
{
//btCollisionShape* colShape = new btCapsuleShape(0.5,2.0);//boxShape = new btSphereShape(1.f);
startTransform.setOrigin(btVector3(2*i,10,1));
localCreateRigidBody(1, startTransform,colShape);
}
}
startTransform.setIdentity();
staticBody = localCreateRigidBody(mass, startTransform,groundShape);
staticBody->setCollisionFlags(staticBody->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT);
#ifdef BATCH_RAYCASTER
int maxNumOutstandingTasks = 4;
#ifdef USE_WIN32_THREADING
Win32ThreadSupport::Win32ThreadConstructionInfo tci("batch raycast",
processRaycastTask,
createRaycastLocalStoreMemory,
maxNumOutstandingTasks);
m_threadSupportRaycast = new Win32ThreadSupport(tci);
printf("m_threadSupportRaycast = %p\n", m_threadSupportRaycast);
#endif
gBatchRaycaster = new SpuBatchRaycaster (m_threadSupportRaycast, maxNumOutstandingTasks, m_dynamicsWorld->getCollisionObjectArray(), m_dynamicsWorld->getNumCollisionObjects());
#endif
raycastBar = btRaycastBar (4000.0, 0.0);
//raycastBar = btRaycastBar (true, 40.0, -50.0, 50.0);
}
void ConcaveRaycastDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
if (m_animatedMesh)
{
static float offset=0.f;
offset+=0.01f;
setVertexPositions(waveheight,offset);
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
trimeshShape->refitTree(worldMin,worldMax);
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
}
m_dynamicsWorld->stepSimulation(1./60.,0);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
raycastBar.move (dt);
raycastBar.cast (m_dynamicsWorld);
renderme();
raycastBar.draw ();
glFlush();
glutSwapBuffers();
}
void ConcaveRaycastDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//optional but useful: debug drawing
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
renderme();
raycastBar.draw ();
glFlush();
glutSwapBuffers();
}
void ConcaveRaycastDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
//delete dynamics world
delete m_dynamicsWorld;
if (m_indexVertexArrays)
delete m_indexVertexArrays;
//delete solver
delete m_solver;
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
delete[] gVertices;
}

View File

@ -1,85 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONCAVE_RAYCAST_DEMO_H
#define CONCAVE_RAYCAST_DEMO_H
#include "GlutDemoApplication.h"
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btTriangleIndexVertexArray;
///ConcaveRaycastDemo shows usage of static concave triangle meshes
class ConcaveRaycastDemo : public GlutDemoApplication
{
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btTriangleIndexVertexArray* m_indexVertexArrays;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
class btThreadSupportInterface* m_threadSupportRaycast;
btDefaultCollisionConfiguration* m_collisionConfiguration;
bool m_animatedMesh;
public:
ConcaveRaycastDemo() : m_animatedMesh(false)
{
}
void initPhysics();
void exitPhysics();
virtual ~ConcaveRaycastDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
//to show refit works
void setVertexPositions(float waveheight, float offset);
virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
ConcaveRaycastDemo* demo = new ConcaveRaycastDemo();
demo->myinit();
demo->initPhysics();
return demo;
};
};
#endif //CONCAVE_RAYCAST_DEMO_H

View File

@ -1,15 +0,0 @@
#include "ConcaveRaycastDemo.h"
#include "GlutStuff.h"
int main(int argc,char** argv)
{
ConcaveRaycastDemo* concaveRaycastDemo = new ConcaveRaycastDemo();
concaveRaycastDemo->initPhysics();
concaveRaycastDemo->setCameraDistance(30.f);
return glutmain(argc, argv,640,480,"Concave Raycast Demo",concaveRaycastDemo);
}

View File

@ -1,71 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConstraintDemo
ConstraintDemo.cpp
ConstraintDemo.h
main.cpp
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConstraintDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConstraintDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}/Debug
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConstraintDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32ConstraintDemo.cpp
ConstraintDemo.cpp
ConstraintDemo.h
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,863 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "GLDebugDrawer.h"
#include "GLDebugFont.h"
#include <stdio.h> //printf debugging
#include "ConstraintDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
static GLDebugDrawer gDebugDrawer;
const int numObjects = 3;
#define ENABLE_ALL_DEMOS 1
#define CUBE_HALF_EXTENTS 1.f
#define SIMD_PI_2 ((SIMD_PI)*0.5f)
#define SIMD_PI_4 ((SIMD_PI)*0.25f)
btTransform sliderTransform;
btVector3 lowerSliderLimit = btVector3(-10,0,0);
btVector3 hiSliderLimit = btVector3(10,0,0);
btRigidBody* d6body0 =0;
btHingeConstraint* spDoorHinge = NULL;
btHingeConstraint* spHingeDynAB = NULL;
btGeneric6DofConstraint* spSlider6Dof = NULL;
static bool s_bTestConeTwistMotor = false;
void drawLimit()
{
btVector3 from = sliderTransform*lowerSliderLimit;
btVector3 to = sliderTransform*hiSliderLimit;
btVector3 color(255,0,0);
glBegin(GL_LINES);
glColor3f(color.getX(), color.getY(), color.getZ());
glVertex3d(from.getX(), from.getY(), from.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
if (d6body0)
{
from = d6body0->getWorldTransform().getOrigin();
to = from + d6body0->getWorldTransform().getBasis() * btVector3(0,0,10);
glVertex3d(from.getX(), from.getY(), from.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
}
glEnd();
}
void ConstraintDemo::setupEmptyDynamicsWorld()
{
m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_overlappingPairCache = new btDbvtBroadphase();
m_constraintSolver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_constraintSolver,m_collisionConfiguration);
}
void ConstraintDemo::clientResetScene()
{
exitPhysics();
initPhysics();
}
void ConstraintDemo::initPhysics()
{
setTexturing(true);
setShadows(true);
setCameraDistance(26.f);
m_Time = 0;
setupEmptyDynamicsWorld();
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
//btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(40.),btScalar(50.)));
btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),40);
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-56,0));
btRigidBody* groundBody;
groundBody= localCreateRigidBody(0, groundTransform, groundShape);
btCollisionShape* shape = new btBoxShape(btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS));
m_collisionShapes.push_back(shape);
btTransform trans;
trans.setIdentity();
trans.setOrigin(btVector3(0,20,0));
float mass = 1.f;
#if ENABLE_ALL_DEMOS
///gear constraint demo
#define THETA SIMD_PI/4.f
#define L_1 (2 - tan(THETA))
#define L_2 (1 / cos(THETA))
#define RATIO L_2 / L_1
btRigidBody* bodyA=0;
btRigidBody* bodyB=0;
{
btCollisionShape* cylA = new btCylinderShape(btVector3(0.2,0.25,0.2));
btCollisionShape* cylB = new btCylinderShape(btVector3(L_1,0.025,L_1));
btCompoundShape* cyl0 = new btCompoundShape();
cyl0->addChildShape(btTransform::getIdentity(),cylA);
cyl0->addChildShape(btTransform::getIdentity(),cylB);
btScalar mass = 6.28;
btVector3 localInertia;
cyl0->calculateLocalInertia(mass,localInertia);
btRigidBody::btRigidBodyConstructionInfo ci(mass,0,cyl0,localInertia);
ci.m_startWorldTransform.setOrigin(btVector3(-8,1,-8));
btRigidBody* body = new btRigidBody(ci);//1,0,cyl0,localInertia);
m_dynamicsWorld->addRigidBody(body);
body->setLinearFactor(btVector3(0,0,0));
body->setAngularFactor(btVector3(0,1,0));
bodyA = body;
}
{
btCollisionShape* cylA = new btCylinderShape(btVector3(0.2,0.26,0.2));
btCollisionShape* cylB = new btCylinderShape(btVector3(L_2,0.025,L_2));
btCompoundShape* cyl0 = new btCompoundShape();
cyl0->addChildShape(btTransform::getIdentity(),cylA);
cyl0->addChildShape(btTransform::getIdentity(),cylB);
btScalar mass = 6.28;
btVector3 localInertia;
cyl0->calculateLocalInertia(mass,localInertia);
btRigidBody::btRigidBodyConstructionInfo ci(mass,0,cyl0,localInertia);
ci.m_startWorldTransform.setOrigin(btVector3(-10,2,-8));
btQuaternion orn(btVector3(0,0,1),-THETA);
ci.m_startWorldTransform.setRotation(orn);
btRigidBody* body = new btRigidBody(ci);//1,0,cyl0,localInertia);
body->setLinearFactor(btVector3(0,0,0));
btHingeConstraint* hinge = new btHingeConstraint(*body,btVector3(0,0,0),btVector3(0,1,0),true);
m_dynamicsWorld->addConstraint(hinge);
bodyB= body;
body->setAngularVelocity(btVector3(0,3,0));
m_dynamicsWorld->addRigidBody(body);
}
btVector3 axisA(0,1,0);
btVector3 axisB(0,1,0);
btQuaternion orn(btVector3(0,0,1),-THETA);
btMatrix3x3 mat(orn);
axisB = mat.getRow(1);
btGearConstraint* gear = new btGearConstraint(*bodyA,*bodyB, axisA,axisB,RATIO);
m_dynamicsWorld->addConstraint(gear,true);
#endif
#if ENABLE_ALL_DEMOS
//point to point constraint with a breaking threshold
{
trans.setIdentity();
trans.setOrigin(btVector3(1,30,-5));
localCreateRigidBody( mass,trans,shape);
trans.setOrigin(btVector3(0,0,-5));
btRigidBody* body0 = localCreateRigidBody( mass,trans,shape);
trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0));
mass = 1.f;
// btRigidBody* body1 = 0;//localCreateRigidBody( mass,trans,shape);
btVector3 pivotInA(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,0);
btTypedConstraint* p2p = new btPoint2PointConstraint(*body0,pivotInA);
m_dynamicsWorld->addConstraint(p2p);
p2p ->setBreakingImpulseThreshold(10.2);
p2p->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
//point to point constraint (ball socket)
{
btRigidBody* body0 = localCreateRigidBody( mass,trans,shape);
trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0));
mass = 1.f;
// btRigidBody* body1 = 0;//localCreateRigidBody( mass,trans,shape);
// btRigidBody* body1 = localCreateRigidBody( 0.0,trans,0);
//body1->setActivationState(DISABLE_DEACTIVATION);
//body1->setDamping(0.3,0.3);
btVector3 pivotInA(CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS);
btVector3 axisInA(0,0,1);
// btVector3 pivotInB = body1 ? body1->getCenterOfMassTransform().inverse()(body0->getCenterOfMassTransform()(pivotInA)) : pivotInA;
// btVector3 axisInB = body1?
// (body1->getCenterOfMassTransform().getBasis().inverse()*(body1->getCenterOfMassTransform().getBasis() * axisInA)) :
body0->getCenterOfMassTransform().getBasis() * axisInA;
#define P2P
#ifdef P2P
btTypedConstraint* p2p = new btPoint2PointConstraint(*body0,pivotInA);
//btTypedConstraint* p2p = new btPoint2PointConstraint(*body0,*body1,pivotInA,pivotInB);
//btTypedConstraint* hinge = new btHingeConstraint(*body0,*body1,pivotInA,pivotInB,axisInA,axisInB);
m_dynamicsWorld->addConstraint(p2p);
p2p->setDbgDrawSize(btScalar(5.f));
#else
btHingeConstraint* hinge = new btHingeConstraint(*body0,pivotInA,axisInA);
//use zero targetVelocity and a small maxMotorImpulse to simulate joint friction
//float targetVelocity = 0.f;
//float maxMotorImpulse = 0.01;
float targetVelocity = 1.f;
float maxMotorImpulse = 1.0f;
hinge->enableAngularMotor(true,targetVelocity,maxMotorImpulse);
m_dynamicsWorld->addConstraint(hinge);
hinge->setDbgDrawSize(btScalar(5.f));
#endif //P2P
}
#endif
#if ENABLE_ALL_DEMOS
{
btTransform trans;
trans.setIdentity();
btVector3 worldPos(-20,0,30);
trans.setOrigin(worldPos);
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInB = btTransform::getIdentity();
btRigidBody* pRbA1 = localCreateRigidBody(mass, trans, shape);
// btRigidBody* pRbA1 = localCreateRigidBody(0.f, trans, shape);
pRbA1->setActivationState(DISABLE_DEACTIVATION);
// add dynamic rigid body B1
worldPos.setValue(-30,0,30);
trans.setOrigin(worldPos);
btRigidBody* pRbB1 = localCreateRigidBody(mass, trans, shape);
// btRigidBody* pRbB1 = localCreateRigidBody(0.f, trans, shape);
pRbB1->setActivationState(DISABLE_DEACTIVATION);
// create slider constraint between A1 and B1 and add it to world
btSliderConstraint* spSlider1 = new btSliderConstraint(*pRbA1, *pRbB1, frameInA, frameInB, true);
// spSlider1 = new btSliderConstraint(*pRbA1, *pRbB1, frameInA, frameInB, false);
spSlider1->setLowerLinLimit(-15.0F);
spSlider1->setUpperLinLimit(-5.0F);
// spSlider1->setLowerLinLimit(5.0F);
// spSlider1->setUpperLinLimit(15.0F);
// spSlider1->setLowerLinLimit(-10.0F);
// spSlider1->setUpperLinLimit(-10.0F);
spSlider1->setLowerAngLimit(-SIMD_PI / 3.0F);
spSlider1->setUpperAngLimit( SIMD_PI / 3.0F);
m_dynamicsWorld->addConstraint(spSlider1, true);
spSlider1->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
//create a slider, using the generic D6 constraint
{
mass = 1.f;
btVector3 sliderWorldPos(0,10,0);
btVector3 sliderAxis(1,0,0);
btScalar angle=0.f;//SIMD_RADS_PER_DEG * 10.f;
btMatrix3x3 sliderOrientation(btQuaternion(sliderAxis ,angle));
trans.setIdentity();
trans.setOrigin(sliderWorldPos);
//trans.setBasis(sliderOrientation);
sliderTransform = trans;
d6body0 = localCreateRigidBody( mass,trans,shape);
d6body0->setActivationState(DISABLE_DEACTIVATION);
btRigidBody* fixedBody1 = localCreateRigidBody(0,trans,0);
m_dynamicsWorld->addRigidBody(fixedBody1);
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInB = btTransform::getIdentity();
frameInA.setOrigin(btVector3(0., 5., 0.));
frameInB.setOrigin(btVector3(0., 5., 0.));
// bool useLinearReferenceFrameA = false;//use fixed frame B for linear llimits
bool useLinearReferenceFrameA = true;//use fixed frame A for linear llimits
spSlider6Dof = new btGeneric6DofConstraint(*fixedBody1, *d6body0,frameInA,frameInB,useLinearReferenceFrameA);
spSlider6Dof->setLinearLowerLimit(lowerSliderLimit);
spSlider6Dof->setLinearUpperLimit(hiSliderLimit);
//range should be small, otherwise singularities will 'explode' the constraint
// spSlider6Dof->setAngularLowerLimit(btVector3(-1.5,0,0));
// spSlider6Dof->setAngularUpperLimit(btVector3(1.5,0,0));
// spSlider6Dof->setAngularLowerLimit(btVector3(0,0,0));
// spSlider6Dof->setAngularUpperLimit(btVector3(0,0,0));
spSlider6Dof->setAngularLowerLimit(btVector3(-SIMD_PI,0,0));
spSlider6Dof->setAngularUpperLimit(btVector3(1.5,0,0));
spSlider6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
spSlider6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = -5.0f;
spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
m_dynamicsWorld->addConstraint(spSlider6Dof);
spSlider6Dof->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{ // create a door using hinge constraint attached to the world
btCollisionShape* pDoorShape = new btBoxShape(btVector3(2.0f, 5.0f, 0.2f));
m_collisionShapes.push_back(pDoorShape);
btTransform doorTrans;
doorTrans.setIdentity();
doorTrans.setOrigin(btVector3(-5.0f, -2.0f, 0.0f));
btRigidBody* pDoorBody = localCreateRigidBody( 1.0, doorTrans, pDoorShape);
pDoorBody->setActivationState(DISABLE_DEACTIVATION);
const btVector3 btPivotA(10.f + 2.1f, -2.0f, 0.0f ); // right next to the door slightly outside
btVector3 btAxisA( 0.0f, 1.0f, 0.0f ); // pointing upwards, aka Y-axis
spDoorHinge = new btHingeConstraint( *pDoorBody, btPivotA, btAxisA );
// spDoorHinge->setLimit( 0.0f, SIMD_PI_2 );
// test problem values
// spDoorHinge->setLimit( -SIMD_PI, SIMD_PI*0.8f);
// spDoorHinge->setLimit( 1.f, -1.f);
// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI);
// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI, 0.9f, 0.3f, 0.0f);
// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI, 0.9f, 0.01f, 0.0f); // "sticky limits"
spDoorHinge->setLimit( -SIMD_PI * 0.25f, SIMD_PI * 0.25f );
// spDoorHinge->setLimit( 0.0f, 0.0f );
m_dynamicsWorld->addConstraint(spDoorHinge);
spDoorHinge->setDbgDrawSize(btScalar(5.f));
//doorTrans.setOrigin(btVector3(-5.0f, 2.0f, 0.0f));
//btRigidBody* pDropBody = localCreateRigidBody( 10.0, doorTrans, shape);
}
#endif
#if ENABLE_ALL_DEMOS
{ // create a generic 6DOF constraint
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(10.), btScalar(6.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
// btRigidBody* pBodyA = localCreateRigidBody( mass, tr, shape);
btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
// btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, 0);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(0.), btScalar(6.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyB = localCreateRigidBody(mass, tr, shape);
// btRigidBody* pBodyB = localCreateRigidBody(0.f, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInA.setOrigin(btVector3(btScalar(-5.), btScalar(0.), btScalar(0.)));
frameInB = btTransform::getIdentity();
frameInB.setOrigin(btVector3(btScalar(5.), btScalar(0.), btScalar(0.)));
btGeneric6DofConstraint* pGen6DOF = new btGeneric6DofConstraint(*pBodyA, *pBodyB, frameInA, frameInB, true);
// btGeneric6DofConstraint* pGen6DOF = new btGeneric6DofConstraint(*pBodyA, *pBodyB, frameInA, frameInB, false);
pGen6DOF->setLinearLowerLimit(btVector3(-10., -2., -1.));
pGen6DOF->setLinearUpperLimit(btVector3(10., 2., 1.));
// pGen6DOF->setLinearLowerLimit(btVector3(-10., 0., 0.));
// pGen6DOF->setLinearUpperLimit(btVector3(10., 0., 0.));
// pGen6DOF->setLinearLowerLimit(btVector3(0., 0., 0.));
// pGen6DOF->setLinearUpperLimit(btVector3(0., 0., 0.));
// pGen6DOF->getTranslationalLimitMotor()->m_enableMotor[0] = true;
// pGen6DOF->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
// pGen6DOF->setAngularLowerLimit(btVector3(0., SIMD_HALF_PI*0.9, 0.));
// pGen6DOF->setAngularUpperLimit(btVector3(0., -SIMD_HALF_PI*0.9, 0.));
// pGen6DOF->setAngularLowerLimit(btVector3(0., 0., -SIMD_HALF_PI));
// pGen6DOF->setAngularUpperLimit(btVector3(0., 0., SIMD_HALF_PI));
pGen6DOF->setAngularLowerLimit(btVector3(-SIMD_HALF_PI * 0.5f, -0.75, -SIMD_HALF_PI * 0.8f));
pGen6DOF->setAngularUpperLimit(btVector3(SIMD_HALF_PI * 0.5f, 0.75, SIMD_HALF_PI * 0.8f));
// pGen6DOF->setAngularLowerLimit(btVector3(0.f, -0.75, SIMD_HALF_PI * 0.8f));
// pGen6DOF->setAngularUpperLimit(btVector3(0.f, 0.75, -SIMD_HALF_PI * 0.8f));
// pGen6DOF->setAngularLowerLimit(btVector3(0.f, -SIMD_HALF_PI * 0.8f, SIMD_HALF_PI * 1.98f));
// pGen6DOF->setAngularUpperLimit(btVector3(0.f, SIMD_HALF_PI * 0.8f, -SIMD_HALF_PI * 1.98f));
// pGen6DOF->setAngularLowerLimit(btVector3(-0.75,-0.5, -0.5));
// pGen6DOF->setAngularUpperLimit(btVector3(0.75,0.5, 0.5));
// pGen6DOF->setAngularLowerLimit(btVector3(-0.75,0., 0.));
// pGen6DOF->setAngularUpperLimit(btVector3(0.75,0., 0.));
// pGen6DOF->setAngularLowerLimit(btVector3(0., -0.7,0.));
// pGen6DOF->setAngularUpperLimit(btVector3(0., 0.7, 0.));
// pGen6DOF->setAngularLowerLimit(btVector3(-1., 0.,0.));
// pGen6DOF->setAngularUpperLimit(btVector3(1., 0., 0.));
m_dynamicsWorld->addConstraint(pGen6DOF, true);
pGen6DOF->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{ // create a ConeTwist constraint
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-10.), btScalar(5.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyA = localCreateRigidBody( 1.0, tr, shape);
// btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-10.), btScalar(-5.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyB = localCreateRigidBody(0.0, tr, shape);
// btRigidBody* pBodyB = localCreateRigidBody(1.0, tr, shape);
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInA.getBasis().setEulerZYX(0, 0, SIMD_PI_2);
frameInA.setOrigin(btVector3(btScalar(0.), btScalar(-5.), btScalar(0.)));
frameInB = btTransform::getIdentity();
frameInB.getBasis().setEulerZYX(0,0, SIMD_PI_2);
frameInB.setOrigin(btVector3(btScalar(0.), btScalar(5.), btScalar(0.)));
m_ctc = new btConeTwistConstraint(*pBodyA, *pBodyB, frameInA, frameInB);
// m_ctc->setLimit(btScalar(SIMD_PI_4), btScalar(SIMD_PI_4), btScalar(SIMD_PI) * 0.8f);
// m_ctc->setLimit(btScalar(SIMD_PI_4*0.6f), btScalar(SIMD_PI_4), btScalar(SIMD_PI) * 0.8f, 1.0f); // soft limit == hard limit
m_ctc->setLimit(btScalar(SIMD_PI_4*0.6f), btScalar(SIMD_PI_4), btScalar(SIMD_PI) * 0.8f, 0.5f);
m_dynamicsWorld->addConstraint(m_ctc, true);
m_ctc->setDbgDrawSize(btScalar(5.f));
// s_bTestConeTwistMotor = true; // use only with old solver for now
s_bTestConeTwistMotor = false;
}
#endif
#if ENABLE_ALL_DEMOS
{ // Hinge connected to the world, with motor (to hinge motor with new and old constraint solver)
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(0.), btScalar(0.), btScalar(0.)));
btRigidBody* pBody = localCreateRigidBody( 1.0, tr, shape);
pBody->setActivationState(DISABLE_DEACTIVATION);
const btVector3 btPivotA( 10.0f, 0.0f, 0.0f );
btVector3 btAxisA( 0.0f, 0.0f, 1.0f );
btHingeConstraint* pHinge = new btHingeConstraint( *pBody, btPivotA, btAxisA );
// pHinge->enableAngularMotor(true, -1.0, 0.165); // use for the old solver
pHinge->enableAngularMotor(true, -1.0f, 1.65f); // use for the new SIMD solver
m_dynamicsWorld->addConstraint(pHinge);
pHinge->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{
// create a universal joint using generic 6DOF constraint
// create two rigid bodies
// static bodyA (parent) on top:
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(20.), btScalar(4.), btScalar(0.)));
btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
// dynamic bodyB (child) below it :
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(20.), btScalar(0.), btScalar(0.)));
btRigidBody* pBodyB = localCreateRigidBody(1.0, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);
// add some (arbitrary) data to build constraint frames
btVector3 parentAxis(1.f, 0.f, 0.f);
btVector3 childAxis(0.f, 0.f, 1.f);
btVector3 anchor(20.f, 2.f, 0.f);
btUniversalConstraint* pUniv = new btUniversalConstraint(*pBodyA, *pBodyB, anchor, parentAxis, childAxis);
pUniv->setLowerLimit(-SIMD_HALF_PI * 0.5f, -SIMD_HALF_PI * 0.5f);
pUniv->setUpperLimit(SIMD_HALF_PI * 0.5f, SIMD_HALF_PI * 0.5f);
// add constraint to world
m_dynamicsWorld->addConstraint(pUniv, true);
// draw constraint frames and limits for debugging
pUniv->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{ // create a generic 6DOF constraint with springs
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-20.), btScalar(16.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-10.), btScalar(16.), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyB = localCreateRigidBody(1.0, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);
btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInA.setOrigin(btVector3(btScalar(10.), btScalar(0.), btScalar(0.)));
frameInB = btTransform::getIdentity();
frameInB.setOrigin(btVector3(btScalar(0.), btScalar(0.), btScalar(0.)));
btGeneric6DofSpringConstraint* pGen6DOFSpring = new btGeneric6DofSpringConstraint(*pBodyA, *pBodyB, frameInA, frameInB, true);
pGen6DOFSpring->setLinearUpperLimit(btVector3(5., 0., 0.));
pGen6DOFSpring->setLinearLowerLimit(btVector3(-5., 0., 0.));
pGen6DOFSpring->setAngularLowerLimit(btVector3(0.f, 0.f, -1.5f));
pGen6DOFSpring->setAngularUpperLimit(btVector3(0.f, 0.f, 1.5f));
m_dynamicsWorld->addConstraint(pGen6DOFSpring, true);
pGen6DOFSpring->setDbgDrawSize(btScalar(5.f));
pGen6DOFSpring->enableSpring(0, true);
pGen6DOFSpring->setStiffness(0, 39.478f);
pGen6DOFSpring->setDamping(0, 0.5f);
pGen6DOFSpring->enableSpring(5, true);
pGen6DOFSpring->setStiffness(5, 39.478f);
pGen6DOFSpring->setDamping(0, 0.3f);
pGen6DOFSpring->setEquilibriumPoint();
}
#endif
#if ENABLE_ALL_DEMOS
{
// create a Hinge2 joint
// create two rigid bodies
// static bodyA (parent) on top:
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-20.), btScalar(4.), btScalar(0.)));
btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
// dynamic bodyB (child) below it :
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-20.), btScalar(0.), btScalar(0.)));
btRigidBody* pBodyB = localCreateRigidBody(1.0, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);
// add some data to build constraint frames
btVector3 parentAxis(0.f, 1.f, 0.f);
btVector3 childAxis(1.f, 0.f, 0.f);
btVector3 anchor(-20.f, 0.f, 0.f);
btHinge2Constraint* pHinge2 = new btHinge2Constraint(*pBodyA, *pBodyB, anchor, parentAxis, childAxis);
pHinge2->setLowerLimit(-SIMD_HALF_PI * 0.5f);
pHinge2->setUpperLimit( SIMD_HALF_PI * 0.5f);
// add constraint to world
m_dynamicsWorld->addConstraint(pHinge2, true);
// draw constraint frames and limits for debugging
pHinge2->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{
// create a Hinge joint between two dynamic bodies
// create two rigid bodies
// static bodyA (parent) on top:
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-20.), btScalar(-2.), btScalar(0.)));
btRigidBody* pBodyA = localCreateRigidBody( 1.0f, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);
// dynamic bodyB:
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(-30.), btScalar(-2.), btScalar(0.)));
btRigidBody* pBodyB = localCreateRigidBody(10.0, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);
// add some data to build constraint frames
btVector3 axisA(0.f, 1.f, 0.f);
btVector3 axisB(0.f, 1.f, 0.f);
btVector3 pivotA(-5.f, 0.f, 0.f);
btVector3 pivotB( 5.f, 0.f, 0.f);
spHingeDynAB = new btHingeConstraint(*pBodyA, *pBodyB, pivotA, pivotB, axisA, axisB);
spHingeDynAB->setLimit(-SIMD_HALF_PI * 0.5f, SIMD_HALF_PI * 0.5f);
// add constraint to world
m_dynamicsWorld->addConstraint(spHingeDynAB, true);
// draw constraint frames and limits for debugging
spHingeDynAB->setDbgDrawSize(btScalar(5.f));
}
#endif
#if ENABLE_ALL_DEMOS
{ // 6DOF connected to the world, with motor
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(10.), btScalar(-15.), btScalar(0.)));
btRigidBody* pBody = localCreateRigidBody( 1.0, tr, shape);
pBody->setActivationState(DISABLE_DEACTIVATION);
btTransform frameB;
frameB.setIdentity();
btGeneric6DofConstraint* pGen6Dof = new btGeneric6DofConstraint( *pBody, frameB, false );
m_dynamicsWorld->addConstraint(pGen6Dof);
pGen6Dof->setDbgDrawSize(btScalar(5.f));
pGen6Dof->setAngularLowerLimit(btVector3(0,0,0));
pGen6Dof->setAngularUpperLimit(btVector3(0,0,0));
pGen6Dof->setLinearLowerLimit(btVector3(-10., 0, 0));
pGen6Dof->setLinearUpperLimit(btVector3(10., 0, 0));
pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
}
#endif
}
void ConstraintDemo::exitPhysics()
{
int i;
//removed/delete constraints
for (i=m_dynamicsWorld->getNumConstraints()-1; i>=0 ;i--)
{
btTypedConstraint* constraint = m_dynamicsWorld->getConstraint(i);
m_dynamicsWorld->removeConstraint(constraint);
delete constraint;
}
m_ctc = NULL;
//remove the rigidbodies from the dynamics world and delete them
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
{
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
//delete dynamics world
delete m_dynamicsWorld;
//delete solver
delete m_constraintSolver;
//delete broadphase
delete m_overlappingPairCache;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}
ConstraintDemo::~ConstraintDemo()
{
//cleanup in the reverse order of creation/initialization
exitPhysics();
}
void ConstraintDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = float(getDeltaTimeMicroseconds()) * 0.000001f;
//printf("dt = %f: ",dt);
// drive cone-twist motor
m_Time += 0.03f;
if (s_bTestConeTwistMotor)
{ // this works only for obsolete constraint solver for now
// build cone target
btScalar t = 1.25f*m_Time;
btVector3 axis(0,sin(t),cos(t));
axis.normalize();
btQuaternion q1(axis, 0.75f*SIMD_PI);
// build twist target
//btQuaternion q2(0,0,0);
//btQuaternion q2(btVehictor3(1,0,0), -0.3*sin(m_Time));
btQuaternion q2(btVector3(1,0,0), -1.49f*btSin(1.5f*m_Time));
// compose cone + twist and set target
q1 = q1 * q2;
m_ctc->enableMotor(true);
m_ctc->setMotorTargetInConstraintSpace(q1);
}
{
static bool once = true;
if ( m_dynamicsWorld->getDebugDrawer() && once)
{
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawConstraints+btIDebugDraw::DBG_DrawConstraintLimits);
once=false;
}
}
{
//during idle mode, just run 1 simulation step maximum
int maxSimSubSteps = m_idle ? 1 : 1;
if (m_idle)
dt = 1.0f/420.f;
int numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
bool verbose = false;
if (verbose)
{
if (!numSimSteps)
printf("Interpolated transforms\n");
else
{
if (numSimSteps > maxSimSubSteps)
{
//detect dropping frames
printf("Dropped (%i) simulation steps out of %i\n",numSimSteps - maxSimSubSteps,numSimSteps);
} else
{
printf("Simulated (%i) steps\n",numSimSteps);
}
}
}
}
renderme();
// drawLimit();
glFlush();
swapBuffers();
}
void ConstraintDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
// drawLimit();
renderme();
glFlush();
swapBuffers();
}
void ConstraintDemo::keyboardCallback(unsigned char key, int x, int y)
{
(void)x;
(void)y;
switch (key)
{
case 'O' :
{
bool offectOnOff;
if(spDoorHinge)
{
offectOnOff = spDoorHinge->getUseFrameOffset();
offectOnOff = !offectOnOff;
spDoorHinge->setUseFrameOffset(offectOnOff);
printf("DoorHinge %s frame offset\n", offectOnOff ? "uses" : "does not use");
}
if(spHingeDynAB)
{
offectOnOff = spHingeDynAB->getUseFrameOffset();
offectOnOff = !offectOnOff;
spHingeDynAB->setUseFrameOffset(offectOnOff);
printf("HingeDynAB %s frame offset\n", offectOnOff ? "uses" : "does not use");
}
if(spSlider6Dof)
{
offectOnOff = spSlider6Dof->getUseFrameOffset();
offectOnOff = !offectOnOff;
spSlider6Dof->setUseFrameOffset(offectOnOff);
printf("Slider6Dof %s frame offset\n", offectOnOff ? "uses" : "does not use");
}
}
break;
default :
{
DemoApplication::keyboardCallback(key, x, y);
}
break;
}
}

View File

@ -1,75 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONSTRAINT_DEMO_H
#define CONSTRAINT_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
///ConstraintDemo shows how to create a constraint, like Hinge or btGenericD6constraint
class ConstraintDemo : public PlatformDemoApplication
{
//keep track of variables to delete memory at the end
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
class btBroadphaseInterface* m_overlappingPairCache;
class btCollisionDispatcher* m_dispatcher;
class btConstraintSolver* m_constraintSolver;
class btDefaultCollisionConfiguration* m_collisionConfiguration;
void setupEmptyDynamicsWorld();
void clientResetScene();
public:
virtual ~ConstraintDemo();
void initPhysics();
void exitPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
static DemoApplication* Create()
{
ConstraintDemo* demo = new ConstraintDemo();
demo->myinit();
demo->initPhysics();
return demo;
}
virtual void keyboardCallback(unsigned char key, int x, int y);
// for cone-twist motor driving
float m_Time;
class btConeTwistConstraint* m_ctc;
};
#endif //CONSTRAINT_DEMO_H

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "ConstraintDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new ConstraintDemo();
}
#endif

View File

@ -1,20 +0,0 @@
#include "ConstraintDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
int main(int argc,char** argv)
{
ConstraintDemo* constraintDemo = new ConstraintDemo();
constraintDemo->initPhysics();
constraintDemo->setDebugMode(btIDebugDraw::DBG_DrawConstraints+btIDebugDraw::DBG_DrawConstraintLimits);
return glutmain(argc, argv,640,480,"Constraint Demo. http://www.continuousphysics.com/Bullet/phpBB2/",constraintDemo);
}

View File

@ -1,47 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppContinuousConvexCollisionDemo
ContinuousConvexCollisionDemo.cpp
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppContinuousConvexCollisionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppContinuousConvexCollisionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppContinuousConvexCollisionDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppContinuousConvexCollisionDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppContinuousConvexCollisionDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,36 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONTINUOUS_CONVEX_COLLISION_DEMO_H
#define CONTINUOUS_CONVEX_COLLISION_DEMO_H
///ContinuousConvexCollisionDemo shows the working of the continuous collision detection, including linear and angular motion
#include "GlutDemoApplication.h"
class btContinuousConvexCollisionDemo : public GlutDemoApplication
{
public:
void initPhysics();
virtual void clientMoveAndDisplay();
virtual void displayCallback();
};
#endif //CONTINUOUS_CONVEX_COLLISION_DEMO_H

View File

@ -1,287 +0,0 @@
/*
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies.
* Erwin Coumans makes no representations about the suitability
* of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*/
/*
Continuous Convex Collision Demo demonstrates an efficient continuous collision detection algorithm.
Both linear and angular velocities are supported. Convex Objects are sampled using Supporting Vertex.
Motion using Exponential Map.
Future ideas: Comparison with Screwing Motion.
Also comparision with Algebraic CCD and Interval Arithmetic methods (Stephane Redon)
*/
///This low level demo need internal access, and intentionally doesn't include the btBulletCollisionCommon.h headerfile
#include "LinearMath/btQuaternion.h"
#include "LinearMath/btTransform.h"
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
#include "LinearMath/btTransformUtil.h"
#include "DebugCastResult.h"
#include "BulletCollision/CollisionShapes/btSphereShape.h"
#include "BulletCollision/CollisionShapes/btTetrahedronShape.h"
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
#include "GL_ShapeDrawer.h"
#include "ContinuousConvexCollision.h"
#include "GlutStuff.h"
float yaw=0.f,pitch=0.f,roll=0.f;
const int maxNumObjects = 4;
const int numObjects = 2;
btVector3 angVels[numObjects];
btVector3 linVels[numObjects];
btPolyhedralConvexShape* shapePtr[maxNumObjects];
btTransform fromTrans[maxNumObjects];
btTransform toTrans[maxNumObjects];
int screenWidth = 640;
int screenHeight = 480;
int main(int argc,char** argv)
{
btContinuousConvexCollisionDemo* ccdDemo = new btContinuousConvexCollisionDemo();
ccdDemo->setCameraDistance(40.f);
ccdDemo->initPhysics();
return glutmain(argc, argv,screenWidth,screenHeight,"Continuous Convex Collision Demo",ccdDemo);
}
void btContinuousConvexCollisionDemo::initPhysics()
{
fromTrans[0].setOrigin(btVector3(0,10,20));
toTrans[0].setOrigin(btVector3(0,10,-20));
fromTrans[1].setOrigin(btVector3(-2,7,0));
toTrans[1].setOrigin(btVector3(-2,10,0));
btMatrix3x3 identBasis;
identBasis.setIdentity();
btMatrix3x3 basisA;
basisA.setIdentity();
basisA.setEulerZYX(0.f,-SIMD_HALF_PI,0.f);
fromTrans[0].setBasis(identBasis);
toTrans[0].setBasis(basisA);
fromTrans[1].setBasis(identBasis);
toTrans[1].setBasis(identBasis);
toTrans[1].setBasis(identBasis);
btVector3 boxHalfExtentsA(10,1,1);
btVector3 boxHalfExtentsB(1.1f,1.1f,1.1f);
btBoxShape* boxA = new btBoxShape(boxHalfExtentsA);
// btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btVector3(-2,0,-2),btVector3(2,0,-2),btVector3(0,0,2),btVector3(0,2,0));
// btBU_Simplex1to4* boxA = new btBU_Simplex1to4(btVector3(-12,0,0),btVector3(12,0,0));
btBoxShape* boxB = new btBoxShape(boxHalfExtentsB);
shapePtr[0] = boxA;
shapePtr[1] = boxB;
shapePtr[0]->setMargin(0.01f);
shapePtr[1]->setMargin(0.01f);
for (int i=0;i<numObjects;i++)
{
btTransformUtil::calculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
}
}
//to be implemented by the demo
void btContinuousConvexCollisionDemo::clientMoveAndDisplay()
{
displayCallback();
}
static btVoronoiSimplexSolver sVoronoiSimplexSolver;
btSimplexSolverInterface& gGjkSimplexSolver = sVoronoiSimplexSolver;
bool drawLine= false;
int minlines = 0;
int maxlines = 512;
void btContinuousConvexCollisionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
//GL_ShapeDrawer::drawCoordSystem();
btScalar m[16];
int i;
btVector3 worldBoundsMin(-1000,-1000,-1000);
btVector3 worldBoundsMax(1000,1000,1000);
/*for (i=0;i<numObjects;i++)
{
fromTrans[i].getOpenGLMatrix( m );
m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
}
*/
if (getDebugMode()==btIDebugDraw::DBG_DrawAabb)
{
i=0;//for (i=1;i<numObjects;i++)
{
//for each object, subdivide the from/to transform in 10 equal steps
int numSubSteps = 10;
for (int s=0;s<10;s++)
{
btScalar subStep = s * 1.f/(float)numSubSteps;
btTransform interpolatedTrans;
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
//fromTrans[i].getOpenGLMatrix(m);
//m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
//toTrans[i].getOpenGLMatrix(m);
//m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
interpolatedTrans.getOpenGLMatrix( m );
m_shapeDrawer->drawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode(),worldBoundsMin,worldBoundsMax);
}
}
}
btMatrix3x3 mat;
mat.setEulerZYX(yaw,pitch,roll);
btQuaternion orn;
mat.getRotation(orn);
orn.setEuler(yaw,pitch,roll);
fromTrans[1].setRotation(orn);
toTrans[1].setRotation(orn);
if (m_stepping || m_singleStep)
{
m_singleStep = false;
pitch += 0.005f;
// yaw += 0.01f;
}
// btVector3 fromA(-25,11,0);
// btVector3 toA(-15,11,0);
// btQuaternion ornFromA(0.f,0.f,0.f,1.f);
// btQuaternion ornToA(0.f,0.f,0.f,1.f);
// btTransform rayFromWorld(ornFromA,fromA);
// btTransform rayToWorld(ornToA,toA);
btTransform rayFromWorld = fromTrans[0];
btTransform rayToWorld = toTrans[0];
if (drawLine)
{
glBegin(GL_LINES);
glColor3f(0, 0, 1);
glVertex3d(rayFromWorld.getOrigin().x(), rayFromWorld.getOrigin().y(),rayFromWorld.getOrigin().z());
glVertex3d(rayToWorld.getOrigin().x(),rayToWorld.getOrigin().y(),rayToWorld.getOrigin().z());
glEnd();
}
//now perform a raycast on the shapes, in local (shape) space
gGjkSimplexSolver.reset();
//choose one of the following lines
for (i=0;i<numObjects;i++)
{
fromTrans[i].getOpenGLMatrix(m);
m_shapeDrawer->drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode(),worldBoundsMin,worldBoundsMax);
}
btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0],m_shapeDrawer);
for (i=1;i<numObjects;i++)
{
btConvexCast::CastResult rayResult2;
btConvexCast::CastResult* rayResultPtr;
if (btIDebugDraw::DBG_DrawAabb)
{
rayResultPtr = &rayResult1;
} else
{
rayResultPtr = &rayResult2;
}
//GjkConvexCast convexCaster(&gGjkSimplexSolver);
//SubsimplexConvexCast convexCaster(&gGjkSimplexSolver);
//optional
btConvexPenetrationDepthSolver* penetrationDepthSolver = 0;
btContinuousConvexCollision convexCaster(shapePtr[0],shapePtr[i],&gGjkSimplexSolver,penetrationDepthSolver );
gGjkSimplexSolver.reset();
if (convexCaster.calcTimeOfImpact(fromTrans[0],toTrans[0],fromTrans[i] ,toTrans[i] ,*rayResultPtr))
{
glDisable(GL_DEPTH_TEST);
btTransform hitTrans;
btTransformUtil::integrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
hitTrans.getOpenGLMatrix(m);
m_shapeDrawer->drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode(),worldBoundsMin,worldBoundsMax);
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
hitTrans.getOpenGLMatrix(m);
m_shapeDrawer->drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode(),worldBoundsMin,worldBoundsMax);
}
}
swapBuffers();
}

View File

@ -1,83 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
${BULLET_PHYSICS_SOURCE_DIR}/Extras/HACD
${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexDecomposition
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader HACD ConvexDecomposition ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConvexDecompositionDemo
main.cpp
ConvexDecompositionDemo.cpp
ConvexDecompositionDemo.h
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConvexDecompositionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConvexDecompositionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletWorldImporter BulletDynamics BulletCollision LinearMath BulletFileLoader HACD ConvexDecomposition ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConvexDecompositionDemo
WIN32
../OpenGL/Win32AppMain.cpp
ConvexDecompositionDemo.cpp
ConvexDecompositionDemo.h
Win32ConvexDecompositionDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ADD_CUSTOM_COMMAND(
TARGET AppConvexDecompositionDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFile.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/file.obj ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConvexDecompositionDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConvexDecompositionDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConvexDecompositionDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@ -1,779 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "hacdCircularList.h"
#include "hacdVector.h"
#include "hacdICHull.h"
#include "hacdGraph.h"
#include "hacdHACD.h"
#include "cd_wavefront.h"
#include "ConvexBuilder.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btQuickprof.h"
#include "LinearMath/btIDebugDraw.h"
#include "LinearMath/btGeometryUtil.h"
#include "BulletCollision/CollisionShapes/btShapeHull.h"
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
//#define TEST_SERIALIZATION
//#define NO_OBJ_TO_BULLET
#ifdef TEST_SERIALIZATION
#include "LinearMath/btSerializer.h"
#include "btBulletFile.h"
#include "btBulletWorldImporter.h"
#endif
//#define USE_PARALLEL_DISPATCHER 1
#ifdef USE_PARALLEL_DISPATCHER
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif//USE_PARALLEL_DISPATCHER
#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"//for the callback
bool MyCompoundChildShapeCallback(const btCollisionShape* pShape0, const btCollisionShape* pShape1)
{
return true;
}
#include "GLDebugFont.h"
#include <stdio.h> //printf debugging
#include "ConvexDecompositionDemo.h"
#include "GL_ShapeDrawer.h"
#include "GlutStuff.h"
btVector3 centroid=btVector3(0,0,0);
btVector3 convexDecompositionObjectOffset(10,0,0);
#define CUBE_HALF_EXTENTS 4
////////////////////////////////////
unsigned int tcount = 0;
//sEnableSAT creates the data structures required for performing SAT tests between convex polyhedra, as alternative to GJK
bool sEnableSAT = false;
void ConvexDecompositionDemo::initPhysics()
{
initPhysics("file.obj");
}
///MyContactCallback is just an example to show how to get access to the child shape that collided
bool MyContactCallback (
btManifoldPoint& cp,
const btCollisionObjectWrapper* colObj0Wrap,
int partId0,
int index0,
const btCollisionObjectWrapper* colObj1Wrap,
int partId1,
int index1)
{
if (colObj0Wrap->getCollisionObject()->getCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
{
btCompoundShape* compound = (btCompoundShape*)colObj0Wrap->getCollisionObject()->getCollisionShape();
btCollisionShape* childShape;
childShape = compound->getChildShape(index0);
}
if (colObj1Wrap->getCollisionObject()->getCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
{
btCompoundShape* compound = (btCompoundShape*)colObj1Wrap->getCollisionObject()->getCollisionShape();
btCollisionShape* childShape;
childShape = compound->getChildShape(index1);
}
return true;
}
void ConvexDecompositionDemo::setupEmptyDynamicsWorld()
{
m_collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
#ifdef USE_WIN32_THREADING
int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"collision",
processCollisionTask,
createCollisionLocalStoreMemory,
maxNumOutstandingTasks));
#else
///@todo other platform threading
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
///Libspe2 SPU support will be available soon
///pthreads version
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
#endif
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,m_collisionConfiguration);
#else
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
#endif//USE_PARALLEL_DISPATCHER
gCompoundChildShapePairCallback = MyCompoundChildShapeCallback;
convexDecompositionObjectOffset.setValue(10,0,0);
btVector3 worldAabbMin(-10000,-10000,-10000);
btVector3 worldAabbMax(10000,10000,10000);
m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
//m_broadphase = new btSimpleBroadphase();
m_solver = new btSequentialImpulseConstraintSolver();
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
#ifdef USE_PARALLEL_DISPATCHER
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
#endif //USE_PARALLEL_DISPATCHER
}
void ConvexDecompositionDemo::initPhysics(const char* filename)
{
gContactAddedCallback = &MyContactCallback;
setupEmptyDynamicsWorld();
getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
setTexturing(true);
setShadows(true);
setCameraDistance(26.f);
#ifndef NO_OBJ_TO_BULLET
ConvexDecomposition::WavefrontObj wo;
tcount = wo.loadObj(filename);
if (!tcount)
{
//when running this app from visual studio, the default starting folder is different, so make a second attempt...
tcount = wo.loadObj("../../file.obj");
}
if (!tcount)
{
//cmake generated msvc files need 4 levels deep back... so make a 3rd attempt...
tcount = wo.loadObj("../../../../file.obj");
}
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-4.5,0));
btCollisionShape* boxShape = new btBoxShape(btVector3(30,2,30));
m_collisionShapes.push_back(boxShape);
localCreateRigidBody(0.f,startTransform,boxShape);
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
{
ConvexDecompositionDemo* m_convexDemo;
public:
btAlignedObjectArray<btConvexHullShape*> m_convexShapes;
btAlignedObjectArray<btVector3> m_convexCentroids;
MyConvexDecomposition (FILE* outputFile,ConvexDecompositionDemo* demo)
:m_convexDemo(demo),
mBaseCount(0),
mHullCount(0),
mOutputFile(outputFile)
{
}
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
{
btTriangleMesh* trimesh = new btTriangleMesh();
m_convexDemo->m_trimeshes.push_back(trimesh);
btVector3 localScaling(6.f,6.f,6.f);
//export data to .obj
printf("ConvexResult. ");
if (mOutputFile)
{
fprintf(mOutputFile,"## Hull Piece %d with %d vertices and %d triangles.\r\n", mHullCount, result.mHullVcount, result.mHullTcount );
fprintf(mOutputFile,"usemtl Material%i\r\n",mBaseCount);
fprintf(mOutputFile,"o Object%i\r\n",mBaseCount);
for (unsigned int i=0; i<result.mHullVcount; i++)
{
const float *p = &result.mHullVertices[i*3];
fprintf(mOutputFile,"v %0.9f %0.9f %0.9f\r\n", p[0], p[1], p[2] );
}
//calc centroid, to shift vertices around center of mass
centroid.setValue(0,0,0);
btAlignedObjectArray<btVector3> vertices;
if ( 1 )
{
//const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullVcount; i++)
{
btVector3 vertex(result.mHullVertices[i*3],result.mHullVertices[i*3+1],result.mHullVertices[i*3+2]);
vertex *= localScaling;
centroid += vertex;
}
}
centroid *= 1.f/(float(result.mHullVcount) );
if ( 1 )
{
//const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullVcount; i++)
{
btVector3 vertex(result.mHullVertices[i*3],result.mHullVertices[i*3+1],result.mHullVertices[i*3+2]);
vertex *= localScaling;
vertex -= centroid ;
vertices.push_back(vertex);
}
}
if ( 1 )
{
const unsigned int *src = result.mHullIndices;
for (unsigned int i=0; i<result.mHullTcount; i++)
{
unsigned int index0 = *src++;
unsigned int index1 = *src++;
unsigned int index2 = *src++;
btVector3 vertex0(result.mHullVertices[index0*3], result.mHullVertices[index0*3+1],result.mHullVertices[index0*3+2]);
btVector3 vertex1(result.mHullVertices[index1*3], result.mHullVertices[index1*3+1],result.mHullVertices[index1*3+2]);
btVector3 vertex2(result.mHullVertices[index2*3], result.mHullVertices[index2*3+1],result.mHullVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
vertex0 -= centroid;
vertex1 -= centroid;
vertex2 -= centroid;
trimesh->addTriangle(vertex0,vertex1,vertex2);
index0+=mBaseCount;
index1+=mBaseCount;
index2+=mBaseCount;
fprintf(mOutputFile,"f %d %d %d\r\n", index0+1, index1+1, index2+1 );
}
}
// float mass = 1.f;
//this is a tools issue: due to collision margin, convex objects overlap, compensate for it here:
//#define SHRINK_OBJECT_INWARDS 1
#ifdef SHRINK_OBJECT_INWARDS
float collisionMargin = 0.01f;
btAlignedObjectArray<btVector3> planeEquations;
btGeometryUtil::getPlaneEquationsFromVertices(vertices,planeEquations);
btAlignedObjectArray<btVector3> shiftedPlaneEquations;
for (int p=0;p<planeEquations.size();p++)
{
btVector3 plane = planeEquations[p];
plane[3] += collisionMargin;
shiftedPlaneEquations.push_back(plane);
}
btAlignedObjectArray<btVector3> shiftedVertices;
btGeometryUtil::getVerticesFromPlaneEquations(shiftedPlaneEquations,shiftedVertices);
btConvexHullShape* convexShape = new btConvexHullShape(&(shiftedVertices[0].getX()),shiftedVertices.size());
#else //SHRINK_OBJECT_INWARDS
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
#endif
if (sEnableSAT)
convexShape->initializePolyhedralFeatures();
convexShape->setMargin(0.01f);
m_convexShapes.push_back(convexShape);
m_convexCentroids.push_back(centroid);
m_convexDemo->m_collisionShapes.push_back(convexShape);
mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
}
}
int mBaseCount;
int mHullCount;
FILE* mOutputFile;
};
if (tcount)
{
btTriangleMesh* trimesh = new btTriangleMesh();
m_trimeshes.push_back(trimesh);
btVector3 localScaling(6.f,6.f,6.f);
int i;
for ( i=0;i<wo.mTriCount;i++)
{
int index0 = wo.mIndices[i*3];
int index1 = wo.mIndices[i*3+1];
int index2 = wo.mIndices[i*3+2];
btVector3 vertex0(wo.mVertices[index0*3], wo.mVertices[index0*3+1],wo.mVertices[index0*3+2]);
btVector3 vertex1(wo.mVertices[index1*3], wo.mVertices[index1*3+1],wo.mVertices[index1*3+2]);
btVector3 vertex2(wo.mVertices[index2*3], wo.mVertices[index2*3+1],wo.mVertices[index2*3+2]);
vertex0 *= localScaling;
vertex1 *= localScaling;
vertex2 *= localScaling;
trimesh->addTriangle(vertex0,vertex1,vertex2);
}
btConvexShape* tmpConvexShape = new btConvexTriangleMeshShape(trimesh);
printf("old numTriangles= %d\n",wo.mTriCount);
printf("old numIndices = %d\n",wo.mTriCount*3);
printf("old numVertices = %d\n",wo.mVertexCount);
printf("reducing vertices by creating a convex hull\n");
//create a hull approximation
btShapeHull* hull = new btShapeHull(tmpConvexShape);
btScalar margin = tmpConvexShape->getMargin();
hull->buildHull(margin);
tmpConvexShape->setUserPointer(hull);
printf("new numTriangles = %d\n", hull->numTriangles ());
printf("new numIndices = %d\n", hull->numIndices ());
printf("new numVertices = %d\n", hull->numVertices ());
btConvexHullShape* convexShape = new btConvexHullShape();
bool updateLocalAabb = false;
for (i=0;i<hull->numVertices();i++)
{
convexShape->addPoint(hull->getVertexPointer()[i],updateLocalAabb);
}
convexShape->recalcLocalAabb();
if (sEnableSAT)
convexShape->initializePolyhedralFeatures();
delete tmpConvexShape;
delete hull;
m_collisionShapes.push_back(convexShape);
float mass = 1.f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,2,14));
localCreateRigidBody(mass, startTransform,convexShape);
bool useQuantization = true;
btCollisionShape* concaveShape = new btBvhTriangleMeshShape(trimesh,useQuantization);
startTransform.setOrigin(convexDecompositionObjectOffset);
localCreateRigidBody(0.f,startTransform,concaveShape);
m_collisionShapes.push_back (concaveShape);
}
if (tcount)
{
//-----------------------------------
// Bullet Convex Decomposition
//-----------------------------------
char outputFileName[512];
strcpy(outputFileName,filename);
char *dot = strstr(outputFileName,".");
if ( dot )
*dot = 0;
strcat(outputFileName,"_convex.obj");
FILE* outputFile = fopen(outputFileName,"wb");
unsigned int depth = 5;
float cpercent = 5;
float ppercent = 15;
unsigned int maxv = 16;
float skinWidth = 0.0;
printf("WavefrontObj num triangles read %i\n",tcount);
ConvexDecomposition::DecompDesc desc;
desc.mVcount = wo.mVertexCount;
desc.mVertices = wo.mVertices;
desc.mTcount = wo.mTriCount;
desc.mIndices = (unsigned int *)wo.mIndices;
desc.mDepth = depth;
desc.mCpercent = cpercent;
desc.mPpercent = ppercent;
desc.mMaxVertices = maxv;
desc.mSkinWidth = skinWidth;
MyConvexDecomposition convexDecomposition(outputFile,this);
desc.mCallback = &convexDecomposition;
//-----------------------------------------------
// HACD
//-----------------------------------------------
std::vector< HACD::Vec3<HACD::Real> > points;
std::vector< HACD::Vec3<long> > triangles;
for(int i=0; i<wo.mVertexCount; i++ )
{
int index = i*3;
HACD::Vec3<HACD::Real> vertex(wo.mVertices[index], wo.mVertices[index+1],wo.mVertices[index+2]);
points.push_back(vertex);
}
for(int i=0;i<wo.mTriCount;i++)
{
int index = i*3;
HACD::Vec3<long> triangle(wo.mIndices[index], wo.mIndices[index+1], wo.mIndices[index+2]);
triangles.push_back(triangle);
}
HACD::HACD myHACD;
myHACD.SetPoints(&points[0]);
myHACD.SetNPoints(points.size());
myHACD.SetTriangles(&triangles[0]);
myHACD.SetNTriangles(triangles.size());
myHACD.SetCompacityWeight(0.1);
myHACD.SetVolumeWeight(0.0);
// HACD parameters
// Recommended parameters: 2 100 0 0 0 0
size_t nClusters = 2;
double concavity = 100;
bool invert = false;
bool addExtraDistPoints = false;
bool addNeighboursDistPoints = false;
bool addFacesPoints = false;
myHACD.SetNClusters(nClusters); // minimum number of clusters
myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull
myHACD.SetConcavity(concavity); // maximum concavity
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
myHACD.SetAddFacesPoints(addFacesPoints);
myHACD.Compute();
nClusters = myHACD.GetNClusters();
myHACD.Save("output.wrl", false);
//convexDecomposition.performConvexDecomposition(desc);
// ConvexBuilder cb(desc.mCallback);
// cb.process(desc);
//now create some bodies
if (1)
{
btCompoundShape* compound = new btCompoundShape();
m_collisionShapes.push_back (compound);
btTransform trans;
trans.setIdentity();
for (int c=0;c<nClusters;c++)
{
//generate convex result
size_t nPoints = myHACD.GetNPointsCH(c);
size_t nTriangles = myHACD.GetNTrianglesCH(c);
float* vertices = new float[nPoints*3];
unsigned int* triangles = new unsigned int[nTriangles*3];
HACD::Vec3<HACD::Real> * pointsCH = new HACD::Vec3<HACD::Real>[nPoints];
HACD::Vec3<long> * trianglesCH = new HACD::Vec3<long>[nTriangles];
myHACD.GetCH(c, pointsCH, trianglesCH);
// points
for(size_t v = 0; v < nPoints; v++)
{
vertices[3*v] = pointsCH[v].X();
vertices[3*v+1] = pointsCH[v].Y();
vertices[3*v+2] = pointsCH[v].Z();
}
// triangles
for(size_t f = 0; f < nTriangles; f++)
{
triangles[3*f] = trianglesCH[f].X();
triangles[3*f+1] = trianglesCH[f].Y();
triangles[3*f+2] = trianglesCH[f].Z();
}
delete [] pointsCH;
delete [] trianglesCH;
ConvexResult r(nPoints, vertices, nTriangles, triangles);
convexDecomposition.ConvexDecompResult(r);
}
for (int i=0;i<convexDecomposition.m_convexShapes.size();i++)
{
btVector3 centroid = convexDecomposition.m_convexCentroids[i];
trans.setOrigin(centroid);
btConvexHullShape* convexShape = convexDecomposition.m_convexShapes[i];
compound->addChildShape(trans,convexShape);
btRigidBody* body;
body = localCreateRigidBody( 1.0, trans,convexShape);
}
/* for (int i=0;i<convexDecomposition.m_convexShapes.size();i++)
{
btVector3 centroid = convexDecomposition.m_convexCentroids[i];
trans.setOrigin(centroid);
btConvexHullShape* convexShape = convexDecomposition.m_convexShapes[i];
compound->addChildShape(trans,convexShape);
btRigidBody* body;
body = localCreateRigidBody( 1.0, trans,convexShape);
}*/
#if 1
btScalar mass=10.f;
trans.setOrigin(-convexDecompositionObjectOffset);
btRigidBody* body = localCreateRigidBody( mass, trans,compound);
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
convexDecompositionObjectOffset.setZ(6);
trans.setOrigin(-convexDecompositionObjectOffset);
body = localCreateRigidBody( mass, trans,compound);
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
convexDecompositionObjectOffset.setZ(-6);
trans.setOrigin(-convexDecompositionObjectOffset);
body = localCreateRigidBody( mass, trans,compound);
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
#endif
}
if (outputFile)
fclose(outputFile);
}
#ifdef TEST_SERIALIZATION
//test serializing this
int maxSerializeBufferSize = 1024*1024*5;
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
m_dynamicsWorld->serialize(serializer);
FILE* f2 = fopen("testFile.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2);
fclose(f2);
exitPhysics();
//now try again from the loaded file
setupEmptyDynamicsWorld();
#endif //TEST_SERIALIZATION
#endif //NO_OBJ_TO_BULLET
#ifdef TEST_SERIALIZATION
btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
//fileLoader->setVerboseMode(true);
fileLoader->loadFile("testFile.bullet");
//fileLoader->loadFile("testFile64Double.bullet");
//fileLoader->loadFile("testFile64Single.bullet");
//fileLoader->loadFile("testFile32Single.bullet");
#endif //TEST_SERIALIZATION
}
void ConvexDecompositionDemo::clientMoveAndDisplay()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float dt = getDeltaTimeMicroseconds() * 0.000001f;
m_dynamicsWorld->stepSimulation(dt);
//optional but useful: debug drawing
m_dynamicsWorld->debugDrawWorld();
renderme();
glFlush();
swapBuffers();
}
void ConvexDecompositionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (m_dynamicsWorld)
m_dynamicsWorld->debugDrawWorld();
renderme();
glFlush();
swapBuffers();
}
void ConvexDecompositionDemo::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
//delete collision shapes
for (i=0;i<m_collisionShapes.size();i++)
{
btCollisionShape* shape = m_collisionShapes[i];
delete shape;
}
m_collisionShapes.clear();
for (i=0;i<m_trimeshes.size();i++)
{
btTriangleMesh* mesh = m_trimeshes[i];
delete mesh;
}
m_trimeshes.clear();
//delete dynamics world
delete m_dynamicsWorld;
//delete solver
delete m_solver;
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
delete m_collisionConfiguration;
}
void ConvexDecompositionDemo::clientResetScene()
{
exitPhysics();
initPhysics("file.obj");
}
void ConvexDecompositionDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key=='S')
{
sEnableSAT= !sEnableSAT;
if (sEnableSAT)
{
printf("SAT enabled after the next restart of the demo\n");
} else
{
printf("SAT disabled after the next restart of the demo\n");
}
} else
{
PlatformDemoApplication::keyboardCallback(key,x,y);
}
}

View File

@ -1,93 +0,0 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONVEX_DECOMPOSITION_DEMO_H
#define CONVEX_DECOMPOSITION_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
class btCollisionShape;
class btOverlappingPairCache;
class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class btTriangleMesh;
///ConvexDecompositionDemo shows automatic convex decomposition of a concave mesh
ATTRIBUTE_ALIGNED16(class) ConvexDecompositionDemo : public PlatformDemoApplication
{
void setupEmptyDynamicsWorld();
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btAlignedObjectArray<btTriangleMesh*> m_trimeshes;
btBroadphaseInterface* m_broadphase;
btCollisionDispatcher* m_dispatcher;
btConstraintSolver* m_solver;
btDefaultCollisionConfiguration* m_collisionConfiguration;
virtual void initPhysics();
void initPhysics(const char* filename);
void exitPhysics();
virtual void clientResetScene();
virtual ~ConvexDecompositionDemo()
{
exitPhysics();
}
virtual void clientMoveAndDisplay();
virtual void displayCallback();
virtual void keyboardCallback(unsigned char key, int x, int y);
static DemoApplication* Create()
{
ConvexDecompositionDemo* demo = new ConvexDecompositionDemo();
demo->myinit();
demo->initPhysics("file.obj");
return demo;
}
};
#endif //CONVEX_DECOMPOSITION_DEMO_H

View File

@ -1,25 +0,0 @@
#ifdef _WINDOWS
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2010 Erwin Coumans http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "ConvexDecompositionDemo.h"
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
DemoApplication* createDemo()
{
return new ConvexDecompositionDemo();
}
#endif

View File

@ -1,27 +0,0 @@
#include "ConvexDecompositionDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
int main(int argc,char** argv)
{
const char* filename = "file.obj";
ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo();
convexDecompDemo->initPhysics(filename);
glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",convexDecompDemo);
delete convexDecompDemo;
return 0;
}

View File

@ -1,82 +0,0 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
IF (WIN32)
ADD_EXECUTABLE(AppConvexHullDistanceDemo
ConvexHullDistanceDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConvexHullDistanceDemo
ConvexHullDistanceDemo.cpp
)
ENDIF()
IF (WIN32)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConvexHullDistanceDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppConvexHullDistanceDemo
POST_BUILD
# COMMAND copy /Y ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF(WIN32)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppConvexHullDistanceDemo
WIN32
../OpenGL/Win32AppMain.cpp
ConvexHullDistanceDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppConvexHullDistanceDemo PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppConvexHullDistanceDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppConvexHullDistanceDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

Some files were not shown because too many files have changed in this diff Show More