This commit is contained in:
Erwin Coumans
2016-08-18 13:42:18 -07:00
270 changed files with 47897 additions and 1835 deletions

View File

@@ -87,6 +87,8 @@ IF(MSVC)
IF (USE_MSVC_FAST_FLOATINGPOINT) IF (USE_MSVC_FAST_FLOATINGPOINT)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
ENDIF() ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /wd4267")
ENDIF(MSVC) ENDIF(MSVC)

View File

@@ -44,7 +44,7 @@ int DillCreator::getNumBodies(int* num_bodies) const {
return 0; return 0;
} }
int DillCreator::getBody(int body_index, int* parent_index, JointType* joint_type, int DillCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com, vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
mat33* body_I_body, int* user_int, void** user_ptr) const { mat33* body_I_body, int* user_int, void** user_ptr) const {

View File

@@ -22,7 +22,7 @@ public:
///\copydoc MultiBodyTreeCreator::getNumBodies ///\copydoc MultiBodyTreeCreator::getNumBodies
int getNumBodies(int* num_bodies) const; int getNumBodies(int* num_bodies) const;
///\copydoc MultiBodyTreeCreator::getBody ///\copydoc MultiBodyTreeCreator::getBody
int getBody(int body_index, int* parent_index, JointType* joint_type, int getBody(const int body_index, int* parent_index, JointType* joint_type,
vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* body_axis_of_motion, vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref, vec3* body_axis_of_motion,
idScalar* mass, vec3* body_r_body_com, mat33* body_I_body, int* user_int, idScalar* mass, vec3* body_r_body_com, mat33* body_I_body, int* user_int,
void** user_ptr) const; void** user_ptr) const;

View File

@@ -237,7 +237,7 @@ int btMultiBodyTreeCreator::getNumBodies(int *num_bodies) const {
return 0; return 0;
} }
int btMultiBodyTreeCreator::getBody(int body_index, int *parent_index, JointType *joint_type, int btMultiBodyTreeCreator::getBody(const int body_index, int *parent_index, JointType *joint_type,
vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref, vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref,
vec3 *body_axis_of_motion, idScalar *mass, vec3 *body_axis_of_motion, idScalar *mass,
vec3 *body_r_body_com, mat33 *body_I_body, int *user_int, vec3 *body_r_body_com, mat33 *body_I_body, int *user_int,

View File

@@ -25,7 +25,7 @@ public:
/// \copydoc MultiBodyTreeCreator::getNumBodies /// \copydoc MultiBodyTreeCreator::getNumBodies
int getNumBodies(int *num_bodies) const; int getNumBodies(int *num_bodies) const;
///\copydoc MultiBodyTreeCreator::getBody ///\copydoc MultiBodyTreeCreator::getBody
int getBody(int body_index, int *parent_index, JointType *joint_type, int getBody(const int body_index, int *parent_index, JointType *joint_type,
vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref, vec3 *body_axis_of_motion, vec3 *parent_r_parent_body_ref, mat33 *body_T_parent_ref, vec3 *body_axis_of_motion,
idScalar *mass, vec3 *body_r_body_com, mat33 *body_I_body, int *user_int, idScalar *mass, vec3 *body_r_body_com, mat33 *body_I_body, int *user_int,
void **user_ptr) const; void **user_ptr) const;

View File

@@ -389,18 +389,10 @@ void bDNA::init(char *data, int len, bool swap)
cp++; cp++;
} }
cp = btAlignPointer(cp,4);
{
nr= (long)cp;
//long mask=3;
nr= ((nr+3)&~3)-nr;
while (nr--)
{
cp++;
}
}
/* /*
TYPE (4 bytes) TYPE (4 bytes)
<nr> amount of types (int) <nr> amount of types (int)
@@ -426,17 +418,8 @@ void bDNA::init(char *data, int len, bool swap)
cp++; cp++;
} }
{ cp = btAlignPointer(cp,4);
nr= (long)cp;
// long mask=3;
nr= ((nr+3)&~3)-nr;
while (nr--)
{
cp++;
}
}
/* /*
TLEN (4 bytes) TLEN (4 bytes)
<len> (short) the lengths of types <len> (short) the lengths of types

View File

@@ -460,15 +460,7 @@ void bFile::swapDNA(char* ptr)
} }
{ cp = btAlignPointer(cp,4);
nr= (long)cp;
//long mask=3;
nr= ((nr+3)&~3)-nr;
while (nr--)
{
cp++;
}
}
/* /*
@@ -497,16 +489,7 @@ void bFile::swapDNA(char* ptr)
cp++; cp++;
} }
{ cp = btAlignPointer(cp,4);
nr= (long)cp;
// long mask=3;
nr= ((nr+3)&~3)-nr;
while (nr--)
{
cp++;
}
}
/* /*
TLEN (4 bytes) TLEN (4 bytes)

View File

@@ -6,10 +6,15 @@
osversion.majorversion, osversion.minorversion, osversion.revision, osversion.majorversion, osversion.minorversion, osversion.revision,
osversion.description)) osversion.description))
-- Multithreaded compiling
if _ACTION == "vs2010" or _ACTION=="vs2008" then if _ACTION == "vs2010" or _ACTION=="vs2008" then
buildoptions { "/MP" } buildoptions
{
-- Multithreaded compiling
"/MP",
-- Disable a few useless warnings
"/wd4244",
"/wd4267"
}
end end
act = "" act = ""
@@ -29,6 +34,11 @@
description = "Try to link and use the system OpenGL headers version instead of dynamically loading OpenGL (dlopen is default)" description = "Try to link and use the system OpenGL headers version instead of dynamically loading OpenGL (dlopen is default)"
} }
newoption
{
trigger = "enable_openvr",
description = "Enable experimental Virtual Reality examples, using OpenVR for HTC Vive and Oculus Rift"
}
newoption newoption
{ {
trigger = "enable_system_x11", trigger = "enable_system_x11",
@@ -75,12 +85,36 @@
newoption newoption
{ {
trigger = "python", trigger = "enable_pybullet",
description = "Enable Python scripting (experimental, use Physics Server in Example Browser). " description = "Enable high-level Python scripting of Bullet with URDF/SDF import and synthetic camera."
} }
if os.is("Linux") then
default_python_include_dir = "/usr/include/python2.7"
default_python_lib_dir = "/usr/local/lib/"
end
if os.is("Windows") then
default_python_include_dir = "C:\Python-3.5.2/include"
default_python_lib_dir = "C:/Python-3.5.2/libs"
end
newoption
{
trigger = "python_include_dir",
value = default_python_include_dir,
description = "Python (2.x or 3.x) include directory"
}
newoption
{
trigger = "python_lib_dir",
value = default_python_lib_dir,
description = "Python (2.x or 3.x) library directory "
}
newoption { newoption {
trigger = "targetdir", trigger = "targetdir",
value = "path such as ../bin", value = "path such as ../bin",
@@ -130,7 +164,7 @@
platforms {"x32"} platforms {"x32"}
end end
else else
platforms {"x32", "x64"} platforms {"x32","x64"}
end end
configuration {"x32"} configuration {"x32"}
@@ -181,6 +215,14 @@
targetdir( _OPTIONS["targetdir"] or "../bin" ) targetdir( _OPTIONS["targetdir"] or "../bin" )
location("./" .. act .. postfix) location("./" .. act .. postfix)
if not _OPTIONS["python_include_dir"] then
_OPTIONS["python_include_dir"] = default_python_include_dir
end
if not _OPTIONS["python_lib_dir"] then
_OPTIONS["python_lib_dir"] = default_python_lib_dir
end
projectRootDir = os.getcwd() .. "/../" projectRootDir = os.getcwd() .. "/../"
print("Project root directory: " .. projectRootDir); print("Project root directory: " .. projectRootDir);
@@ -212,7 +254,7 @@
if _OPTIONS["lua"] then if _OPTIONS["lua"] then
include "../examples/ThirdPartyLibs/lua-5.2.3" include "../examples/ThirdPartyLibs/lua-5.2.3"
end end
if _OPTIONS["python"] then if _OPTIONS["enable_pybullet"] then
include "../examples/pybullet" include "../examples/pybullet"
end end

View File

@@ -2,6 +2,6 @@
rm CMakeCache.txt rm CMakeCache.txt
mkdir build_cmake mkdir build_cmake
cd build_cmake cd build_cmake
cmake -DBUILD_PYTHON=OFF -CMAKE_BUILD_TYPE=Release .. cmake -DBUILD_PYBULLET=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j12 make -j12
examples/ExampleBrowser/App_ExampleBrowser examples/ExampleBrowser/App_ExampleBrowser

View File

@@ -2,7 +2,8 @@
rem premake4 --with-pe vs2010 rem premake4 --with-pe vs2010
rem premake4 --bullet2demos vs2010 rem premake4 --bullet2demos vs2010
cd build3 cd build3
premake4 --targetdir="../bin" vs2010 premake4 --enable_openvr --targetdir="../bin" vs2010
rem premake4 --enable_openvr --enable_pybullet --targetdir="../bin" vs2010
rem premake4 --targetdir="../server2bin" vs2010 rem premake4 --targetdir="../server2bin" vs2010
rem cd vs2010 rem cd vs2010
rem rename 0_Bullet3Solution.sln 0_server.sln rem rename 0_Bullet3Solution.sln 0_server.sln
@@ -14,6 +15,6 @@ rem cd vs2010
rem rename 0_Bullet3Solution.sln 0_client.sln rem rename 0_Bullet3Solution.sln 0_client.sln
rem cd .. rem cd ..
rem rename vs2010 vs2010_client rem rename vs2010 vs2010_client
start vs2010/0_Bullet3Solution.sln rem start vs2010/0_Bullet3Solution.sln
pause pause

View File

@@ -3,4 +3,4 @@ Description: Bullet Continuous Collision Detection and Physics Library
Requires: Requires:
Version: @BULLET_VERSION@ Version: @BULLET_VERSION@
Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath Libs: -L@CMAKE_INSTALL_PREFIX@/@LIB_DESTINATION@ -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath
Cflags: @BULLET_DOUBLE_DEF@ -I@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include Cflags: @BULLET_DOUBLE_DEF@ -I@CMAKE_INSTALL_PREFIX@/@INCLUDE_INSTALL_DIR@ -I@CMAKE_INSTALL_PREFIX@/include

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" ?>
<!-- adapted from Daniel Mellinger, Nathan Michael, Vijay Kumar, "Trajectory Generation and Control for Precise Aggressive Maneuvers with Quadrotors" -->
<robot xmlns="http://drake.mit.edu"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://drake.mit.edu ../../../../pods/drake/doc/drakeURDF.xsd" name="quadrotor">
<link name="base_link">
<inertial>
<mass value="0.5"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.0023" ixy="0.0" ixz="0.0" iyy="0.0023" iyz="0.0" izz="0.004"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="quadrotor_base.obj" scale=".1 .1 .1"/>
</geometry>
</visual>
<!-- note: the original hector quadrotor urdf had a (simplified, but still complex) collision mesh, too -->
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<cylinder radius=".3" length=".1"/>
</geometry>
</collision>
</link>
<frame link="base_link" name="body" rpy="0 0 0" xyz="0 0 0" />
<force_element name="prop1">
<propellor lower_limit="0" upper_limit="10" scale_factor_thrust="1.0" scale_factor_moment="0.0245">
<parent link="base_link"/>
<origin xyz=".1750 0 0"/>
<axis xyz="0 0 1"/>
</propellor>
</force_element>
<force_element name="prop2">
<propellor lower_limit="0" upper_limit="10" scale_factor_thrust="1.0" scale_factor_moment="-0.0245">
<parent link="base_link"/>
<origin xyz="0 .1750 0 "/>
<axis xyz="0 0 1"/>
</propellor>
</force_element>
<force_element name="prop3">
<propellor lower_limit="0" upper_limit="10" scale_factor_thrust="1.0" scale_factor_moment="0.0245">
<parent link="base_link"/>
<origin xyz="-.1750 0 0"/>
<axis xyz="0 0 1"/>
</propellor>
</force_element>
<force_element name="prop4">
<propellor lower_limit="0" upper_limit="10" scale_factor_thrust="1.0" scale_factor_moment="-0.0245">
<parent link="base_link"/>
<origin xyz="0 -.1750 0"/>
<axis xyz="0 0 1"/>
</propellor>
</force_element>
</robot>

File diff suppressed because it is too large Load Diff

BIN
data/checker_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -11,4 +11,6 @@ newmtl cube
Ke 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000
map_Ka cube.tga map_Ka cube.tga
map_Kd cube.png map_Kd cube.png

32
data/cube.urdf Normal file
View File

@@ -0,0 +1,32 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<contact>
<lateral_friction value="1.0"/>
<rolling_friction value="0.0"/>
<contact_cfm value="0.0"/>
<contact_erp value="1.0"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="1.0"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="cube.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<box size="1 1 1"/>
</geometry>
</collision>
</link>
</robot>

View File

@@ -0,0 +1,32 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<contact>
<lateral_friction value="0.0"/>
<rolling_friction value="0.0"/>
<contact_cfm value="0.0"/>
<contact_erp value="1.0"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="1.0"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="cube.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<box size="1 1 1"/>
</geometry>
</collision>
</link>
</robot>

35
data/cube_small.sdf Normal file
View File

@@ -0,0 +1,35 @@
<sdf version='1.6'>
<world name='default'>
<model name='unit_box_0'>
<pose frame=''>0 0 0.107 0 0 0</pose>
<link name='unit_box_0::link'>
<inertial>
<mass>0.1</mass>
<inertia>
<ixx>1.0</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1.0</iyy>
<iyz>0</iyz>
<izz>1.0</izz>
</inertia>
</inertial>
<collision name='collision'>
<geometry>
<box>
<size>0.05 0.05 0.05</size>
</box>
</geometry>
</collision>
<visual name='visual'>
<geometry>
<mesh>
<scale>0.05 0.05 0.05</scale>
<uri>cube.obj</uri>
</mesh>
</geometry>
</visual>
</link>
</model>
</world>
</sdf>

33
data/cube_small.urdf Normal file
View File

@@ -0,0 +1,33 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<contact>
<lateral_friction value="1.0"/>
<rolling_friction value="0.0"/>
<inertia_scaling value="3.0"/>
<contact_cfm value="0.0"/>
<contact_erp value="1.0"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".1"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="cube.obj" scale=".05 .05 .05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<box size=".05 .05 .05"/>
</geometry>
</collision>
</link>
</robot>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,298 @@
<?xml version="1.0" ?>
<sdf version='1.6'>
<world name='default'>
<model name='wsg50_with_gripper'>
<pose frame=''>0 0 0.27 3.14 0 0</pose>
<link name='world'>
</link>
<joint name='base_joint' type='prismatic'>
<parent>world</parent>
<child>base_link</child>
<axis>
<xyz>0 0 1</xyz>
<limit>
<lower>-0.5</lower>
<upper>10</upper>
<effort>1</effort>
<velocity>1</velocity>
</limit>
<dynamics>
<damping>100</damping>
<friction>100</friction>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='base_link'>
<pose frame=''>0 0 0 0 -0 0</pose>
<inertial>
<pose frame=''>0 0 0 0 -0 0</pose>
<mass>1.2</mass>
<inertia>
<ixx>1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>1</iyy>
<iyz>0</iyz>
<izz>1</izz>
</inertia>
</inertial>
<collision name='base_link_collision'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<box>
<size>0.2 0.05 0.05 </size>
</box>
</geometry>
</collision>
<visual name='base_link_visual'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>meshes/WSG50_110.stl</uri>
</mesh>
</geometry>
<material>
</material>
</visual>
<gravity>1</gravity>
<velocity_decay/>
<self_collide>0</self_collide>
</link>
<link name='gripper_left'>
<pose frame=''>-0.055 0 0 0 -0 0</pose>
<inertial>
<pose frame=''>0 0 0.0115 0 -0 0</pose>
<mass>0.2</mass>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
</inertial>
<collision name='gripper_left_collision'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/GUIDE_WSG50_110.stl</uri>
</mesh>
</geometry>
</collision>
<collision name='gripper_left_fixed_joint_lump__finger_left_collision_1'>
<pose frame=''>0 0 0.023 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/WSG-FMF.stl</uri>
</mesh>
</geometry>
</collision>
<visual name='gripper_left_visual'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/GUIDE_WSG50_110.stl</uri>
</mesh>
</geometry>
</visual>
<visual name='gripper_left_fixed_joint_lump__finger_left_visual_1'>
<pose frame=''>0 0 0.023 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/WSG-FMF.stl</uri>
</mesh>
</geometry>
</visual>
</link>
<joint name='base_joint_gripper_left' type='prismatic'>
<child>gripper_left</child>
<parent>base_link</parent>
<axis>
<xyz>1 0 0</xyz>
<limit>
<lower>-0.001</lower>
<upper>0.055</upper>
<effort>1</effort>
<velocity>1</velocity>
</limit>
<dynamics>
<damping>100</damping>
<friction>100</friction>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='gripper_right'>
<pose frame=''>0.055 0 0 0 -0 3.14159</pose>
<inertial>
<pose frame=''>0 0 0.0115 0 -0 0</pose>
<mass>0.2</mass>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
</inertial>
<collision name='gripper_right_collision'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/GUIDE_WSG50_110.stl</uri>
</mesh>
</geometry>
</collision>
<collision name='gripper_right_fixed_joint_lump__finger_right_collision_1'>
<pose frame=''>0 0 0.023 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/WSG-FMF.stl</uri>
</mesh>
</geometry>
</collision>
<visual name='gripper_right_visual'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/GUIDE_WSG50_110.stl</uri>
</mesh>
</geometry>
</visual>
<visual name='gripper_right_fixed_joint_lump__finger_right_visual_1'>
<pose frame=''>0 0 0.023 0 -0 0</pose>
<geometry>
<mesh>
<scale>0.001 0.001 0.001</scale>
<uri>meshes/WSG-FMF.stl</uri>
</mesh>
</geometry>
</visual>
</link>
<joint name='base_joint_gripper_right' type='prismatic'>
<child>gripper_right</child>
<parent>base_link</parent>
<axis>
<xyz>-1 0 0</xyz>
<limit>
<lower>-0.055</lower>
<upper>0.001</upper>
<effort>1</effort>
<velocity>1</velocity>
</limit>
<dynamics>
<damping>100</damping>
<friction>100</friction>
<spring_reference>0</spring_reference>
<spring_stiffness>0</spring_stiffness>
</dynamics>
</axis>
</joint>
<link name='finger_right'>
<pose frame=''>0.062 0 0.145 0 0 1.5708</pose>
<inertial>
<mass>0.2</mass>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
</inertial>
<collision name='finger_right_collision'>
<pose frame=''>0 0 0.042 0 0 0 </pose>
<geometry>
<box>
<size>0.02 0.02 0.15 </size>
</box>
</geometry>
</collision>
<visual name='finger_right_visual'>
<pose frame=''>0 0 0 0 0 0 </pose>
<geometry>
<mesh>
<scale>1 1 1 </scale>
<uri>meshes/l_gripper_tip_scaled.stl</uri>
</mesh>
</geometry>
</visual>
</link>
<joint name='gripper_finger_right' type='fixed'>
<parent>gripper_right</parent>
<child>finger_right</child>
</joint>
<link name='finger_left'>
<pose frame=''>-0.062 0 0.145 0 0 4.71239</pose>
<inertial>
<mass>0.2</mass>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
</inertial>
<collision name='finger_left_collision'>
<pose frame=''>0 0 0.042 0 0 0 </pose>
<geometry>
<box>
<size>0.02 0.02 0.15 </size>
</box>
</geometry>
</collision>
<visual name='finger_left_visual'>
<pose frame=''>0 0 0 0 0 0 </pose>
<geometry>
<mesh>
<scale>1 1 1 </scale>
<uri>meshes/l_gripper_tip_scaled.stl</uri>
</mesh>
</geometry>
</visual>
</link>
<joint name='gripper_finger_left' type='fixed'>
<parent>gripper_left</parent>
<child>finger_left</child>
</joint>
</model>
</world>
</sdf>

345
data/husky/husky.urdf Normal file
View File

@@ -0,0 +1,345 @@
<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from ../urdf/husky.urdf.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<!--
Software License Agreement (BSD)
\file husky.urdf.xacro
\authors Paul Bovbel <pbovbel@clearpathrobotics.com>
\copyright Copyright (c) 2015, Clearpath Robotics, Inc., All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Clearpath Robotics nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WAR-
RANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, IN-
DIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<robot name="husky_robot" xmlns:xacro="http://ros.org/wiki/xacro">
<!-- Included URDF/XACRO Files -->
<material name="Black">
<color rgba="0.1 0.1 0.1 1.0"/>
</material>
<material name="Blue">
<color rgba="0.0 0.0 0.8 1.0"/>
</material>
<material name="Green">
<color rgba="0.0 0.8 0.0 1.0"/>
</material>
<material name="Grey">
<color rgba="0.7 0.7 0.7 1.0"/>
</material>
<material name="DarkGrey">
<color rgba="0.3 0.3 0.3 1.0"/>
</material>
<material name="Red">
<color rgba="0.8 0.0 0.0 1.0"/>
</material>
<material name="White">
<color rgba="1.0 1.0 1.0 1.0"/>
</material>
<material name="Yellow">
<color rgba="0.8 0.8 0.0 1.0"/>
</material>
<!-- Base Size -->
<!-- Wheel Mounting Positions -->
<!-- Wheel Properties -->
<!-- Base link is on the ground under the robot -->
<link name="base_footprint"/>
<gazebo reference="base_footprint">
<material>Gazebo/DarkGrey</material>
</gazebo>
<joint name="chassis_joint" type="fixed">
<origin rpy="0 0 0" xyz="0 0 0.14493"/>
<parent link="base_footprint"/>
<child link="base_link"/>
</joint>
<!-- Chassis link is the center of the robot's bottom plate -->
<link name="base_link">
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/base_link.stl"/>
</geometry>
<material name="Black"/>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0.12498"/>
<geometry>
<!-- Make collision box slightly bigger in x and z directions. -->
<box size="1.0074 0.5709 0.2675"/>
</geometry>
</collision>
<inertial>
<mass value="33.455"/>
<origin xyz="-0.08748 -0.00085 0.09947"/>
<inertia ixx="0.6022" ixy="-0.02364" ixz="-0.1197" iyy="1.7386" iyz="-0.001544" izz="2.0296"/>
</inertial>
</link>
<gazebo reference="base_link">
</gazebo>
<!-- IMU Link is the standard mounting position for the UM6 IMU.-->
<!-- Can be modified with environment variables in /etc/ros/setup.bash -->
<link name="imu_link"/>
<joint name="imu_joint" type="fixed">
<origin rpy="$(optenv HUSKY_IMU_RPY 0 -1.5708 3.1416)" xyz="$(optenv HUSKY_IMU_XYZ 0.19 0 0.149)"/>
<parent link="base_link"/>
<child link="imu_link"/>
</joint>
<gazebo reference="imu_link">
</gazebo>
<!-- Husky wheel macros -->
<link name="front_left_wheel_link">
<inertial>
<mass value="2.637"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.02467" ixy="0" ixz="0" iyy="0.02467" iyz="0" izz="0.04411"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/wheel.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.1143" radius="0.17775"/>
</geometry>
</collision>
</link>
<gazebo reference="front_left_wheel_link">
<mu1 value="1.0"/>
<mu2 value="1.0"/>
<kp value="10000000.0"/>
<kd value="1.0"/>
<fdir1 value="1 0 0"/>
<material>Gazebo/Grey</material>
<turnGravityOff>false</turnGravityOff>
</gazebo>
<joint name="front_left_wheel" type="continuous">
<parent link="base_link"/>
<child link="front_left_wheel_link"/>
<origin rpy="0 0 0" xyz="0.256 0.2854 0.03282"/>
<axis rpy="0 0 0" xyz="0 1 0"/>
</joint>
<transmission name="front_left_wheel_trans" type="SimpleTransmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="front_left_wheel_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="front_left_wheel">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
</joint>
</transmission>
<link name="front_right_wheel_link">
<inertial>
<mass value="2.637"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.02467" ixy="0" ixz="0" iyy="0.02467" iyz="0" izz="0.04411"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/wheel.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.1143" radius="0.17775"/>
</geometry>
</collision>
</link>
<gazebo reference="front_right_wheel_link">
<mu1 value="1.0"/>
<mu2 value="1.0"/>
<kp value="10000000.0"/>
<kd value="1.0"/>
<fdir1 value="1 0 0"/>
<material>Gazebo/Grey</material>
<turnGravityOff>false</turnGravityOff>
</gazebo>
<joint name="front_right_wheel" type="continuous">
<parent link="base_link"/>
<child link="front_right_wheel_link"/>
<origin rpy="0 0 0" xyz="0.256 -0.2854 0.03282"/>
<axis rpy="0 0 0" xyz="0 1 0"/>
</joint>
<transmission name="front_right_wheel_trans" type="SimpleTransmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="front_right_wheel_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="front_right_wheel">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
</joint>
</transmission>
<link name="rear_left_wheel_link">
<inertial>
<mass value="2.637"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.02467" ixy="0" ixz="0" iyy="0.02467" iyz="0" izz="0.04411"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/wheel.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.1143" radius="0.17775"/>
</geometry>
</collision>
</link>
<gazebo reference="rear_left_wheel_link">
<mu1 value="1.0"/>
<mu2 value="1.0"/>
<kp value="10000000.0"/>
<kd value="1.0"/>
<fdir1 value="1 0 0"/>
<material>Gazebo/Grey</material>
<turnGravityOff>false</turnGravityOff>
</gazebo>
<joint name="rear_left_wheel" type="continuous">
<parent link="base_link"/>
<child link="rear_left_wheel_link"/>
<origin rpy="0 0 0" xyz="-0.256 0.2854 0.03282"/>
<axis rpy="0 0 0" xyz="0 1 0"/>
</joint>
<transmission name="rear_left_wheel_trans" type="SimpleTransmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="rear_left_wheel_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="rear_left_wheel">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
</joint>
</transmission>
<link name="rear_right_wheel_link">
<inertial>
<mass value="2.637"/>
<origin xyz="0 0 0"/>
<inertia ixx="0.02467" ixy="0" ixz="0" iyy="0.02467" iyz="0" izz="0.04411"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/wheel.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.1143" radius="0.17775"/>
</geometry>
</collision>
</link>
<gazebo reference="rear_right_wheel_link">
<mu1 value="1.0"/>
<mu2 value="1.0"/>
<kp value="10000000.0"/>
<kd value="1.0"/>
<fdir1 value="1 0 0"/>
<material>Gazebo/Grey</material>
<turnGravityOff>false</turnGravityOff>
</gazebo>
<joint name="rear_right_wheel" type="continuous">
<parent link="base_link"/>
<child link="rear_right_wheel_link"/>
<origin rpy="0 0 0" xyz="-0.256 -0.2854 0.03282"/>
<axis rpy="0 0 0" xyz="0 1 0"/>
</joint>
<transmission name="rear_right_wheel_trans" type="SimpleTransmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="rear_right_wheel_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="rear_right_wheel">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
</joint>
</transmission>
<link name="top_plate_link">
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="meshes/top_plate.stl"/>
</geometry>
<material name="Yellow"/>
</visual>
</link>
<joint name="top_plate" type="fixed">
<parent link="base_link"/>
<child link="top_plate_link"/>
</joint>
<gazebo reference="top_plate_link">
<material>Gazebo/Yellow</material>
</gazebo>
<link name="user_rail_link">
<visual>
<geometry>
<mesh filename="meshes/user_rail.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
</link>
<joint name="user_rail" type="fixed">
<origin rpy="0 0 0" xyz="0.272 0 0.245"/>
<parent link="base_link"/>
<child link="user_rail_link"/>
</joint>
<gazebo reference="user_rail_link">
<material>Gazebo/DarkGrey</material>
</gazebo>
<link name="front_bumper_link">
<visual>
<geometry>
<mesh filename="meshes/bumper.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
</link>
<joint name="front_bumper" type="fixed">
<origin rpy="0 0 0" xyz="0.48 0 0.091"/>
<parent link="base_link"/>
<child link="front_bumper_link"/>
</joint>
<gazebo reference="front_bumper_link">
<material>Gazebo/DarkGrey</material>
</gazebo>
<link name="rear_bumper_link">
<visual>
<geometry>
<mesh filename="meshes/bumper.stl"/>
</geometry>
<material name="DarkGrey"/>
</visual>
</link>
<joint name="rear_bumper" type="fixed">
<origin rpy="0 0 3.14159" xyz="-0.48 0 0.091"/>
<parent link="base_link"/>
<child link="rear_bumper_link"/>
</joint>
<gazebo reference="rear_bumper_link">
<material>Gazebo/DarkGrey</material>
</gazebo>
</robot>

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/husky/meshes/wheel.stl Normal file

Binary file not shown.

View File

@@ -0,0 +1,7 @@
--start_demo_name=R2D2 Grasp
--mouse_move_multiplier=0.400000
--mouse_wheel_multiplier=0.010000
--background_color_red= 0.900000
--background_color_green= 0.900000
--background_color_blue= 1.000000
--fixed_timestep= 0.000000

Binary file not shown.

55
data/kiva_shelf/model.sdf Normal file
View File

@@ -0,0 +1,55 @@
<?xml version="1.0" ?>
<sdf version="1.4">
<model name="Amazon Pod">
<static>1</static>
<pose>0 2 1.21 0 0 0</pose>
<link name="pod_link">
<inertial>
<pose>0.0 0.0 1.2045 0 0 0</pose>
<mass>76.26</mass>
<inertia>
<ixx>47</ixx>
<ixy>-0.003456</ixy>
<ixz>0.001474</ixz>
<izz>13.075</izz>
<iyz>-0.014439</iyz>
<iyy>47</iyy>
</inertia>
</inertial>
<visual name="pod_visual">
<pose>0 0 0 1.5707 0 0 </pose>
<geometry>
<mesh>
<uri>meshes/pod_lowres.stl</uri>
</mesh>
</geometry>
<material>
<diffuse>0.9 0.8 0.5 1</diffuse>
</material>
</visual>
<collision name="pod_collision">
<pose>0 0 0 1.5707 0 0</pose>
<geometry>
<mesh>
<uri>meshes/pod_lowres.stl</uri>
</mesh>
</geometry>
<surface>
<friction>
<ode>
<mu>0.8</mu>
<mu2>0.8</mu2>
<fdir1>0.0 0.0 0.0</fdir1>
<slip1>1.0</slip1>
<slip2>1.0</slip2>
</ode>
</friction>
</surface>
</collision>
</link>
</model>
</sdf>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,7 @@
<sdf version='1.6'> <sdf version='1.6'>
<world name='default'> <world name='default'>
<model name='lbr_iiwa'> <model name='lbr_iiwa'>
<static>1</static>
<link name='lbr_iiwa_link_0'> <link name='lbr_iiwa_link_0'>
<pose frame=''>0 0 0 0 -0 0</pose> <pose frame=''>0 0 0 0 -0 0</pose>
<inertial> <inertial>
@@ -34,7 +35,7 @@
</geometry> </geometry>
<material> <material>
<ambient>1 0 0 1</ambient> <ambient>1 0 0 1</ambient>
<diffuse>0 0 1 1</diffuse> <diffuse>0.2 0.2 0.2 1</diffuse>
<specular>0.1 0.1 0.1 1</specular> <specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive> <emissive>0 0 0 0</emissive>
</material> </material>
@@ -71,6 +72,12 @@
<uri>meshes/link_1.stl</uri> <uri>meshes/link_1.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>0.5 0.7 1.0 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_1' type='revolute'> <joint name='lbr_iiwa_joint_1' type='revolute'>
@@ -124,6 +131,12 @@
<uri>meshes/link_2.stl</uri> <uri>meshes/link_2.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>0.5 0.7 1.0 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_2' type='revolute'> <joint name='lbr_iiwa_joint_2' type='revolute'>
@@ -177,6 +190,12 @@
<uri>meshes/link_3.stl</uri> <uri>meshes/link_3.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>1.0 0.42 0.04 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_3' type='revolute'> <joint name='lbr_iiwa_joint_3' type='revolute'>
@@ -230,6 +249,12 @@
<uri>meshes/link_4.stl</uri> <uri>meshes/link_4.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>0.5 0.7 1.0 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_4' type='revolute'> <joint name='lbr_iiwa_joint_4' type='revolute'>
@@ -283,6 +308,12 @@
<uri>meshes/link_5.stl</uri> <uri>meshes/link_5.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>0.5 0.7 1.0 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_5' type='revolute'> <joint name='lbr_iiwa_joint_5' type='revolute'>
@@ -336,6 +367,12 @@
<uri>meshes/link_6.stl</uri> <uri>meshes/link_6.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>1.0 0.42 0.04 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_6' type='revolute'> <joint name='lbr_iiwa_joint_6' type='revolute'>
@@ -389,6 +426,12 @@
<uri>meshes/link_7.stl</uri> <uri>meshes/link_7.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material>
<ambient>1 0 0 1</ambient>
<diffuse>0.2 0.2 0.2 1</diffuse>
<specular>0.1 0.1 0.1 1</specular>
<emissive>0 0 0 0</emissive>
</material>
</visual> </visual>
</link> </link>
<joint name='lbr_iiwa_joint_7' type='revolute'> <joint name='lbr_iiwa_joint_7' type='revolute'>

View File

@@ -77,7 +77,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_0.stl"/> <mesh filename="meshes/link_0.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -106,7 +106,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_1.stl"/> <mesh filename="meshes/link_1.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -135,7 +135,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_2.stl"/> <mesh filename="meshes/link_2.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -164,7 +164,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_3.stl"/> <mesh filename="meshes/link_3.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -193,7 +193,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_4.stl"/> <mesh filename="meshes/link_4.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -222,7 +222,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_5.stl"/> <mesh filename="meshes/link_5.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -251,7 +251,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_6.stl"/> <mesh filename="meshes/link_6.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>
@@ -280,7 +280,7 @@
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="meshes/coarse/link_7.stl"/> <mesh filename="meshes/link_7.stl"/>
</geometry> </geometry>
</collision> </collision>
</link> </link>

Binary file not shown.

View File

@@ -1,11 +1,15 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material newmtl Material
Ns 96.078431 Ns 10.0000
Ka 0.000000 0.000000 0.000000 Ni 1.5000
Kd 0.640000 0.640000 0.640000 d 1.0000
Ks 0.500000 0.500000 0.500000 Tr 0.0000
Ni 1.000000 Tf 1.0000 1.0000 1.0000
d 1.000000 illum 2
illum 2 Ka 0.0000 0.0000 0.0000
Kd 0.5880 0.5880 0.5880
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Ka cube.tga
map_Kd checker_blue.png

View File

@@ -2,11 +2,17 @@
# www.blender.org # www.blender.org
mtllib plane.mtl mtllib plane.mtl
o Plane o Plane
v 1.000000 0.000000 -1.000000 v 5.000000 -5.000000 0.000000
v 1.000000 0.000000 1.000000 v 5.000000 5.000000 0.000000
v -1.000000 0.000000 1.000000 v -5.000000 5.000000 0.000000
v -1.000000 0.000000 -1.000000 v -5.000000 -5.000000 0.000000
vt 5.000000 0.000000
vt 5.000000 5.000000
vt 0.000000 5.000000
vt 0.000000 0.000000
usemtl Material usemtl Material
s off s off
f 1 2 3 f 1/1 2/2 3/3
f 1 3 4 f 1/1 3/3 4/4

26
data/plane.urdf Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="plane.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<box size="10 10 0.001"/>
</geometry>
</collision>
</link>
</robot>

View File

@@ -2,11 +2,21 @@
# www.blender.org # www.blender.org
mtllib plane.mtl mtllib plane.mtl
o Plane o Plane
v 100.000000 0.000000 -100.000000 v 100.000000 -100.000000 0.000000
v 100.000000 0.000000 100.000000 v 100.000000 100.000000 0.000000
v -100.000000 0.000000 100.000000 v -100.000000 100.000000 0.000000
v -100.000000 0.000000 -100.000000 v -100.000000 -100.000000 0.000000
vt 100.000000 0.000000
vt 100.000000 100.000000
vt 0.000000 100.000000
vt 0.000000 0.000000
usemtl Material usemtl Material
s off s off
f 3 2 1 f 1/1 2/2 3/3
f 4 3 1 f 1/1 3/3 4/4

26
data/plane100.urdf Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="plane100.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<box size="10 10 0.001"/>
</geometry>
</collision>
</link>
</robot>

View File

@@ -79,7 +79,7 @@
<cylinder length=".1" radius="0.035"/> <cylinder length=".1" radius="0.035"/>
</geometry> </geometry>
<material name="black"> <material name="black">
<color rgba="0 0 0 1"/> <color rgba="0.5 0.5 0.5 1"/>
</material> </material>
</visual> </visual>
<collision> <collision>

View File

@@ -9,8 +9,11 @@
<visual> <visual>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
<geometry> <geometry>
<mesh filename="textured_sphere_smooth.obj" scale="0.5 0.5 0.5"/> <mesh filename="textured_sphere_smooth.obj" scale="0.5 0.5 0.5"/>
</geometry> </geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual> </visual>
<collision> <collision>
<origin rpy="0 0 0" xyz="0 0 0"/> <origin rpy="0 0 0" xyz="0 0 0"/>
@@ -19,55 +22,5 @@
</geometry> </geometry>
</collision> </collision>
</link> </link>
<link name="childA">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="10.0"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<sphere radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<sphere radius="0.5"/>
</geometry>
</collision>
</link>
<joint name="joint_baseLink_childA" type="fixed">
<parent link="baseLink"/>
<child link="childA"/>
<origin xyz="0 0 1.0"/>
</joint>
<link name="childB">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0.5"/>
<mass value="10.0"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0.5"/>
<geometry>
<sphere radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0.5"/>
<geometry>
<sphere radius="0.5"/>
</geometry>
</collision>
</link>
<joint name="joint_childA_childB" type="continuous">
<parent link="childA"/>
<child link="childB"/>
<axis xyz="0 1 0"/>
<origin xyz="0 0 0.5"/>
</joint>
</robot> </robot>

View File

@@ -39,7 +39,7 @@ struct BasicExample : public CommonRigidBodyBase
virtual void renderScene(); virtual void renderScene();
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 4;
float pitch = 52; float pitch = 52;
float yaw = 35; float yaw = 35;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
@@ -81,7 +81,7 @@ void BasicExample::initPhysics()
//create a few dynamic rigidbodies //create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance // Re-using the same collision is better for memory usage and performance
btBoxShape* colShape = createBoxShape(btVector3(1,1,1)); btBoxShape* colShape = createBoxShape(btVector3(.1,.1,.1));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.)); //btCollisionShape* colShape = new btSphereShape(btScalar(1.));
@@ -108,9 +108,9 @@ void BasicExample::initPhysics()
for(int j = 0;j<ARRAY_SIZE_Z;j++) for(int j = 0;j<ARRAY_SIZE_Z;j++)
{ {
startTransform.setOrigin(btVector3( startTransform.setOrigin(btVector3(
btScalar(2.0*i), btScalar(0.2*i),
btScalar(20+2.0*k), btScalar(2+.2*k),
btScalar(2.0*j))); btScalar(0.2*j)));
createRigidBody(mass,startTransform,colShape); createRigidBody(mass,startTransform,colShape);
@@ -121,7 +121,9 @@ void BasicExample::initPhysics()
} }
} }
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld); m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
} }

View File

@@ -53,6 +53,7 @@ SET(AppBasicExampleGui_SRCS
../ExampleBrowser/OpenGLGuiHelper.cpp ../ExampleBrowser/OpenGLGuiHelper.cpp
../ExampleBrowser/GL_ShapeDrawer.cpp ../ExampleBrowser/GL_ShapeDrawer.cpp
../ExampleBrowser/CollisionShape2TriangleMesh.cpp ../ExampleBrowser/CollisionShape2TriangleMesh.cpp
../Utils/b3Clock.cpp
) )
#this define maps StandaloneExampleCreateFunc to the right 'CreateFunc' #this define maps StandaloneExampleCreateFunc to the right 'CreateFunc'

View File

@@ -49,6 +49,8 @@ files {
"../ExampleBrowser/OpenGLGuiHelper.cpp", "../ExampleBrowser/OpenGLGuiHelper.cpp",
"../ExampleBrowser/GL_ShapeDrawer.cpp", "../ExampleBrowser/GL_ShapeDrawer.cpp",
"../ExampleBrowser/CollisionShape2TriangleMesh.cpp", "../ExampleBrowser/CollisionShape2TriangleMesh.cpp",
"../Utils/b3Clock.cpp",
"../Utils/b3Clock.h",
} }
if os.is("Linux") then initX11() end if os.is("Linux") then initX11() end
@@ -59,6 +61,7 @@ end
project "App_BasicExampleGuiWithSoftwareRenderer" project "App_BasicExampleGuiWithSoftwareRenderer"
if _OPTIONS["ios"] then if _OPTIONS["ios"] then
@@ -92,7 +95,9 @@ files {
"../TinyRenderer/tgaimage.cpp", "../TinyRenderer/tgaimage.cpp",
"../TinyRenderer/our_gl.cpp", "../TinyRenderer/our_gl.cpp",
"../TinyRenderer/TinyRenderer.cpp", "../TinyRenderer/TinyRenderer.cpp",
"../Utils/b3ResourcePath.cpp" "../Utils/b3ResourcePath.cpp",
"../Utils/b3Clock.cpp",
"../Utils/b3Clock.h",
} }
if os.is("Linux") then initX11() end if os.is("Linux") then initX11() end
@@ -131,5 +136,68 @@ files {
"../TinyRenderer/tgaimage.cpp", "../TinyRenderer/tgaimage.cpp",
"../TinyRenderer/our_gl.cpp", "../TinyRenderer/our_gl.cpp",
"../TinyRenderer/TinyRenderer.cpp", "../TinyRenderer/TinyRenderer.cpp",
"../Utils/b3ResourcePath.cpp" "../Utils/b3ResourcePath.cpp",
"../Utils/b3Clock.cpp",
"../Utils/b3Clock.h",
} }
if _OPTIONS["enable_openvr"] then
project "App_BasicExampleVR"
if _OPTIONS["ios"] then
kind "WindowedApp"
else
kind "ConsoleApp"
end
defines {"B3_USE_STANDALONE_EXAMPLE","BT_ENABLE_VR"}
includedirs {"../../src",
"../ThirdPartyLibs/openvr/headers",
"../ThirdPartyLibs/openvr/samples/shared"}
links {
"BulletDynamics","BulletCollision", "LinearMath", "OpenGL_Window","Bullet3Common", "openvr_api"
}
initOpenGL()
initGlew()
language "C++"
files {
"BasicExample.cpp",
"*.h",
"../StandaloneMain/hellovr_opengl_main.cpp",
"../ExampleBrowser/OpenGLGuiHelper.cpp",
"../ExampleBrowser/GL_ShapeDrawer.cpp",
"../ExampleBrowser/CollisionShape2TriangleMesh.cpp",
"../ThirdPartyLibs/openvr/samples/shared/lodepng.cpp",
"../ThirdPartyLibs/openvr/samples/shared/lodepng.h",
"../ThirdPartyLibs/openvr/samples/shared/Matrices.cpp",
"../ThirdPartyLibs/openvr/samples/shared/Matrices.h",
"../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp",
"../ThirdPartyLibs/openvr/samples/shared/pathtools.h",
"../ThirdPartyLibs/openvr/samples/shared/Vectors.h",
"../Utils/b3Clock.cpp",
"../Utils/b3Clock.h",
}
if os.is("Windows") then
libdirs {"../ThirdPartyLibs/openvr/lib/win32"}
end
if os.is("Linux") then initX11() end
if os.is("MacOSX") then
links{"Cocoa.framework"}
end
end

View File

@@ -1273,7 +1273,7 @@ void BenchmarkDemo::exitPhysics()
struct CommonExampleInterface* BenchmarkCreateFunc(struct CommonExampleOptions& options) CommonExampleInterface* BenchmarkCreateFunc(struct CommonExampleOptions& options)
{ {
return new BenchmarkDemo(options.m_guiHelper,options.m_option); return new BenchmarkDemo(options.m_guiHelper,options.m_option);
} }

View File

@@ -265,8 +265,9 @@ public:
virtual void stepSimulation(float deltaTime) virtual void stepSimulation(float deltaTime)
{ {
#ifndef BT_NO_PROFILE
CProfileManager::Reset(); CProfileManager::Reset();
#endif
@@ -314,7 +315,9 @@ public:
m_app->m_renderer->writeTransforms(); m_app->m_renderer->writeTransforms();
#ifndef BT_NO_PROFILE
CProfileManager::Increment_Frame_Counter(); CProfileManager::Increment_Frame_Counter();
#endif
} }
virtual void renderScene() virtual void renderScene()
{ {

View File

@@ -6,7 +6,9 @@ struct CommonCameraInterface
virtual void getCameraProjectionMatrix(float m[16])const = 0; virtual void getCameraProjectionMatrix(float m[16])const = 0;
virtual void getCameraViewMatrix(float m[16]) const = 0; virtual void getCameraViewMatrix(float m[16]) const = 0;
virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16])=0; virtual void setVRCamera(const float viewMat[16], const float projectionMatrix[16])=0;
virtual void disableVRCamera()=0;
virtual bool isVRCamera() const =0;
virtual void getCameraTargetPosition(float pos[3]) const = 0; virtual void getCameraTargetPosition(float pos[3]) const = 0;
virtual void getCameraPosition(float pos[3]) const = 0; virtual void getCameraPosition(float pos[3]) const = 0;

View File

@@ -46,6 +46,8 @@ public:
virtual bool mouseButtonCallback(int button, int state, float x, float y)=0; virtual bool mouseButtonCallback(int button, int state, float x, float y)=0;
virtual bool keyboardCallback(int key, int state)=0; virtual bool keyboardCallback(int key, int state)=0;
virtual void vrControllerMoveCallback(int controllerId, float pos[4], float orientation[4]) {}
virtual void vrControllerButtonCallback(int controllerId, int button, int state, float pos[4], float orientation[4]){}
}; };
class ExampleEntries class ExampleEntries

View File

@@ -29,10 +29,11 @@ struct GUIHelperInterface
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld)=0; virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld)=0;
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices) =0; virtual int registerTexture(const unsigned char* texels, int width, int height)=0;
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId) = 0;
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) =0; virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) =0;
virtual void removeAllGraphicsInstances()=0;
virtual Common2dCanvasInterface* get2dCanvasInterface()=0; virtual Common2dCanvasInterface* get2dCanvasInterface()=0;
virtual CommonParameterInterface* getParameterInterface()=0; virtual CommonParameterInterface* getParameterInterface()=0;
@@ -45,7 +46,23 @@ struct GUIHelperInterface
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)=0; virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)=0;
virtual void copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels, int startPixelIndex, int* width, int* height, int* numPixelsCopied)=0; virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied)
{
copyCameraImageData(viewMatrix,projectionMatrix,pixelsRGBA,rgbaBufferSizeInPixels,
depthBuffer,depthBufferSizeInPixels,
0,0,
startPixelIndex,destinationWidth,
destinationHeight,numPixelsCopied);
}
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied)=0;
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0; virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
@@ -73,10 +90,11 @@ struct DummyGUIHelper : public GUIHelperInterface
virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld){} virtual void createPhysicsDebugDrawer( btDiscreteDynamicsWorld* rbWorld){}
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices) { return -1; } virtual int registerTexture(const unsigned char* texels, int width, int height){return -1;}
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId){return -1;}
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) { return -1;} virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) {return -1;}
virtual void removeAllGraphicsInstances(){}
virtual Common2dCanvasInterface* get2dCanvasInterface() virtual Common2dCanvasInterface* get2dCanvasInterface()
{ {
return 0; return 0;
@@ -105,12 +123,13 @@ struct DummyGUIHelper : public GUIHelperInterface
{ {
} }
virtual void copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels, int startPixelIndex, int* width, int* height, int* numPixelsCopied) virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int width, int height, int* numPixelsCopied)
{ {
if (width)
*width = 0;
if (height)
*height = 0;
if (numPixelsCopied) if (numPixelsCopied)
*numPixelsCopied = 0; *numPixelsCopied = 0;
} }

View File

@@ -77,7 +77,7 @@ struct CommonGraphicsApp
virtual void dumpNextFrameToPng(const char* pngFilename){} virtual void dumpNextFrameToPng(const char* pngFilename){}
virtual void dumpFramesToVideo(const char* mp4Filename){} virtual void dumpFramesToVideo(const char* mp4Filename){}
virtual void getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes){}; virtual void getScreenPixels(unsigned char* rgbaBuffer, int bufferSizeInBytes, float* depthBuffer, int depthBufferSizeInBytes){}
virtual void getBackgroundColor(float* red, float* green, float* blue) const virtual void getBackgroundColor(float* red, float* green, float* blue) const
{ {

View File

@@ -63,7 +63,7 @@ struct CommonMultiBodyBase : public CommonExampleInterface
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) ///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 = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase(); m_broadphase = new btDbvtBroadphase();//btSimpleBroadphase();
m_solver = new btMultiBodyConstraintSolver; m_solver = new btMultiBodyConstraintSolver;
@@ -97,6 +97,20 @@ struct CommonMultiBodyBase : public CommonExampleInterface
{ {
m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i)); m_dynamicsWorld->removeConstraint(m_dynamicsWorld->getConstraint(i));
} }
for (i = m_dynamicsWorld->getNumMultiBodyConstraints() - 1; i >= 0; i--)
{
btMultiBodyConstraint* mbc = m_dynamicsWorld->getMultiBodyConstraint(i);
m_dynamicsWorld->removeMultiBodyConstraint(mbc);
delete mbc;
}
for (i = m_dynamicsWorld->getNumMultibodies() - 1; i >= 0; i--)
{
btMultiBody* mb = m_dynamicsWorld->getMultiBody(i);
m_dynamicsWorld->removeMultiBody(mb);
delete mb;
}
for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--) for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)
{ {
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i]; btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];

View File

@@ -22,7 +22,7 @@ struct CommonRenderInterface
virtual void init()=0; virtual void init()=0;
virtual void updateCamera(int upAxis)=0; virtual void updateCamera(int upAxis)=0;
virtual void removeAllInstances() = 0; virtual void removeAllInstances() = 0;
virtual const CommonCameraInterface* getActiveCamera() const =0; virtual const CommonCameraInterface* getActiveCamera() const =0;
virtual CommonCameraInterface* getActiveCamera()=0; virtual CommonCameraInterface* getActiveCamera()=0;
virtual void setActiveCamera(CommonCameraInterface* cam)=0; virtual void setActiveCamera(CommonCameraInterface* cam)=0;
@@ -52,6 +52,10 @@ struct CommonRenderInterface
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0; virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0;
virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex)=0; virtual void writeSingleInstanceColorToCPU(float* color, int srcIndex)=0;
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex)=0; virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex)=0;
virtual void writeSingleInstanceScaleToCPU(float* scale, int srcIndex)=0;
virtual void writeSingleInstanceScaleToCPU(double* scale, int srcIndex)=0;
virtual int getTotalNumInstances() const = 0;
virtual void writeTransforms()=0; virtual void writeTransforms()=0;
virtual void enableBlend(bool blend)=0; virtual void enableBlend(bool blend)=0;

View File

@@ -114,7 +114,10 @@ SET(ExtendedTutorialsSources
../ExtendedTutorials/SimpleCloth.cpp ../ExtendedTutorials/SimpleCloth.cpp
../ExtendedTutorials/Chain.cpp ../ExtendedTutorials/Chain.cpp
../ExtendedTutorials/Bridge.cpp ../ExtendedTutorials/Bridge.cpp
../ExtendedTutorials/RigidBodyFromObj.cpp ../ExtendedTutorials/RigidBodyFromObj.cpp
../ExtendedTutorials/InclinedPlane.cpp
../ExtendedTutorials/InclinedPlane.h
../ExtendedTutorials/NewtonsCradle.cpp
) )
SET(BulletExampleBrowser_SRCS SET(BulletExampleBrowser_SRCS
@@ -152,12 +155,30 @@ SET(BulletExampleBrowser_SRCS
../BasicDemo/BasicExample.h ../BasicDemo/BasicExample.h
../InverseDynamics/InverseDynamicsExample.cpp ../InverseDynamics/InverseDynamicsExample.cpp
../InverseDynamics/InverseDynamicsExample.h ../InverseDynamics/InverseDynamicsExample.h
../InverseKinematics/InverseKinematicsExample.cpp
../InverseKinematics/InverseKinematicsExample.h
../ForkLift/ForkLiftDemo.cpp ../ForkLift/ForkLiftDemo.cpp
../ForkLift/ForkLiftDemo.h ../ForkLift/ForkLiftDemo.h
../Tutorial/Tutorial.cpp ../Tutorial/Tutorial.cpp
../Tutorial/Tutorial.h ../Tutorial/Tutorial.h
../Tutorial/Dof6ConstraintTutorial.cpp ../Tutorial/Dof6ConstraintTutorial.cpp
../Tutorial/Dof6ConstraintTutorial.h ../Tutorial/Dof6ConstraintTutorial.h
../ExtendedTutorials/SimpleBox.cpp
../ExtendedTutorials/SimpleBox.h
../ExtendedTutorials/MultipleBoxes.cpp
../ExtendedTutorials/MultipleBoxes.h
../ExtendedTutorials/SimpleCloth.cpp
../ExtendedTutorials/SimpleCloth.h
../ExtendedTutorials/SimpleJoint.cpp
../ExtendedTutorials/SimpleJoint.h
../ExtendedTutorials/NewtonsCradle.cpp
../ExtendedTutorials/NewtonsCradle.h
../ExtendedTutorials/NewtonsRopeCradle.cpp
../ExtendedTutorials/NewtonsRopeCradle.h
../ExtendedTutorials/InclinedPlane.cpp
../ExtendedTutorials/InclinedPlane.h
../ExtendedTutorials/MultiPendulum.cpp
../ExtendedTutorials/MultiPendulum.h
../Collision/CollisionSdkC_Api.cpp ../Collision/CollisionSdkC_Api.cpp
../Collision/CollisionSdkC_Api.h ../Collision/CollisionSdkC_Api.h
../Collision/CollisionTutorialBullet2.cpp ../Collision/CollisionTutorialBullet2.cpp
@@ -189,7 +210,12 @@ SET(BulletExampleBrowser_SRCS
../RenderingExamples/TimeSeriesCanvas.h ../RenderingExamples/TimeSeriesCanvas.h
../RenderingExamples/TimeSeriesFontData.cpp ../RenderingExamples/TimeSeriesFontData.cpp
../RenderingExamples/TimeSeriesFontData.h ../RenderingExamples/TimeSeriesFontData.h
../RoboticsLearning/GripperGraspExample.cpp
../RoboticsLearning/GripperGraspExample.h
../RoboticsLearning/b3RobotSimAPI.cpp
../RoboticsLearning/b3RobotSimAPI.h
../RoboticsLearning/R2D2GraspExample.cpp
../RoboticsLearning/R2D2GraspExample.h
../RenderingExamples/CoordinateSystemDemo.cpp ../RenderingExamples/CoordinateSystemDemo.cpp
../RenderingExamples/CoordinateSystemDemo.h ../RenderingExamples/CoordinateSystemDemo.h
../RenderingExamples/RaytracerSetup.cpp ../RenderingExamples/RaytracerSetup.cpp
@@ -276,6 +302,17 @@ SET(BulletExampleBrowser_SRCS
../ThirdPartyLibs/stb_image/stb_image.cpp ../ThirdPartyLibs/stb_image/stb_image.cpp
../ThirdPartyLibs/stb_image/stb_image.h ../ThirdPartyLibs/stb_image/stb_image.h
../ThirdPartyLibs/BussIK/Jacobian.cpp
../ThirdPartyLibs/BussIK/Tree.cpp
../ThirdPartyLibs/BussIK/Node.cpp
../ThirdPartyLibs/BussIK/LinearR2.cpp
../ThirdPartyLibs/BussIK/LinearR3.cpp
../ThirdPartyLibs/BussIK/LinearR4.cpp
../ThirdPartyLibs/BussIK/MatrixRmn.cpp
../ThirdPartyLibs/BussIK/VectorRn.cpp
../ThirdPartyLibs/BussIK/Misc.cpp
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../ThirdPartyLibs/tinyxml/tinystr.cpp ../ThirdPartyLibs/tinyxml/tinystr.cpp

View File

@@ -45,6 +45,9 @@
#include "../Tutorial/Dof6ConstraintTutorial.h" #include "../Tutorial/Dof6ConstraintTutorial.h"
#include "../MultiThreading/MultiThreadingExample.h" #include "../MultiThreading/MultiThreadingExample.h"
#include "../InverseDynamics/InverseDynamicsExample.h" #include "../InverseDynamics/InverseDynamicsExample.h"
#include "../RoboticsLearning/R2D2GraspExample.h"
#include "../RoboticsLearning/GripperGraspExample.h"
#include "../InverseKinematics/InverseKinematicsExample.h"
#ifdef ENABLE_LUA #ifdef ENABLE_LUA
#include "../LuaDemo/LuaPhysicsSetup.h" #include "../LuaDemo/LuaPhysicsSetup.h"
@@ -57,7 +60,7 @@
#endif #endif
#endif //B3_USE_CLEW #endif //B3_USE_CLEW
//Extended Tutorial Includes Added by Mobeen //Extended Tutorial Includes Added by Mobeen and Benelot
#include "../ExtendedTutorials/SimpleBox.h" #include "../ExtendedTutorials/SimpleBox.h"
#include "../ExtendedTutorials/MultipleBoxes.h" #include "../ExtendedTutorials/MultipleBoxes.h"
#include "../ExtendedTutorials/SimpleJoint.h" #include "../ExtendedTutorials/SimpleJoint.h"
@@ -65,6 +68,10 @@
#include "../ExtendedTutorials/Chain.h" #include "../ExtendedTutorials/Chain.h"
#include "../ExtendedTutorials/Bridge.h" #include "../ExtendedTutorials/Bridge.h"
#include "../ExtendedTutorials/RigidBodyFromObj.h" #include "../ExtendedTutorials/RigidBodyFromObj.h"
#include "../ExtendedTutorials/InclinedPlane.h"
#include "../ExtendedTutorials/NewtonsCradle.h"
#include "../ExtendedTutorials/NewtonsRopeCradle.h"
#include "../ExtendedTutorials/MultiPendulum.h"
struct ExampleEntry struct ExampleEntry
{ {
@@ -94,7 +101,6 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application. Press W for wireframe, A to show AABBs, I to suspend/restart physics simulation. Press D to toggle auto-deactivation of the simulation. ", BasicExampleCreateFunc), ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application. Press W for wireframe, A to show AABBs, I to suspend/restart physics simulation. Press D to toggle auto-deactivation of the simulation. ", BasicExampleCreateFunc),
ExampleEntry(1,"Rolling Friction", "Damping is often not good enough to keep rounded objects from rolling down a sloped surface. Instead, you can set the rolling friction of a rigid body. Generally it is best to leave the rolling friction to zero, to avoid artifacts.", RollingFrictionCreateFunc), ExampleEntry(1,"Rolling Friction", "Damping is often not good enough to keep rounded objects from rolling down a sloped surface. Instead, you can set the rolling friction of a rigid body. Generally it is best to leave the rolling friction to zero, to avoid artifacts.", RollingFrictionCreateFunc),
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet. Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.", ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet. Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.",
@@ -114,21 +120,30 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(1,"Soft Contact", "Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.",RigidBodySoftContactCreateFunc), ExampleEntry(1,"Soft Contact", "Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.",RigidBodySoftContactCreateFunc),
ExampleEntry(0,"MultiBody"), ExampleEntry(0,"MultiBody"),
ExampleEntry(1,"MultiDofCreateFunc","Create a basic btMultiBody with 3-DOF spherical joints (mobilizers). The demo uses a fixed base or a floating base at restart.", MultiDofCreateFunc), ExampleEntry(1,"MultiDofCreateFunc","Create a basic btMultiBody with 3-DOF spherical joints (mobilizers). The demo uses a fixed base or a floating base at restart.", MultiDofCreateFunc),
ExampleEntry(1,"TestJointTorque","Apply a torque to a btMultiBody with 1-DOF joints (mobilizers). This setup is similar to API/TestHingeTorque.", TestJointTorqueCreateFunc), ExampleEntry(1,"TestJointTorque","Apply a torque to a btMultiBody with 1-DOF joints (mobilizers). This setup is similar to API/TestHingeTorque.", TestJointTorqueCreateFunc),
ExampleEntry(1,"TestPendulum","Simulate a pendulum using btMultiBody with a constant joint torque applied. The same code is also used as a unit test comparing Bullet with the numerical solution of second-order non-linear differential equation stored in pendulum_gold.h", TestPendulumCreateFunc), ExampleEntry(1,"TestPendulum","Simulate a pendulum using btMultiBody with a constant joint torque applied. The same code is also used as a unit test comparing Bullet with the numerical solution of second-order non-linear differential equation stored in pendulum_gold.h", TestPendulumCreateFunc),
ExampleEntry(1,"Constraint Feedback", "The example shows how to receive joint reaction forces in a btMultiBody. Also the applied impulse is available for a btMultiBodyJointMotor", MultiBodyConstraintFeedbackCreateFunc), ExampleEntry(1,"Constraint Feedback", "The example shows how to receive joint reaction forces in a btMultiBody. Also the applied impulse is available for a btMultiBodyJointMotor", MultiBodyConstraintFeedbackCreateFunc),
ExampleEntry(1,"Inverted Pendulum PD","Keep an inverted pendulum up using open loop PD control", InvertedPendulumPDControlCreateFunc), ExampleEntry(1,"Inverted Pendulum PD","Keep an inverted pendulum up using open loop PD control", InvertedPendulumPDControlCreateFunc),
ExampleEntry(1,"MultiBody Soft Contact", "Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.",MultiBodySoftContactCreateFunc,0), ExampleEntry(1,"MultiBody Soft Contact", "Using the error correction parameter (ERP) and constraint force mixing (CFM) values for contacts to simulate compliant contact.",MultiBodySoftContactCreateFunc,0),
ExampleEntry(0,"Inverse Dynamics"), ExampleEntry(0,"Inverse Dynamics"),
ExampleEntry(1,"Inverse Dynamics URDF", "Create a btMultiBody from URDF. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc,BT_ID_LOAD_URDF), ExampleEntry(1,"Inverse Dynamics URDF", "Create a btMultiBody from URDF. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc,BT_ID_LOAD_URDF),
ExampleEntry(1,"Inverse Dynamics Prog", "Create a btMultiBody programatically. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc,BT_ID_PROGRAMMATICALLY), ExampleEntry(1,"Inverse Dynamics Prog", "Create a btMultiBody programatically. Create an inverse MultiBodyTree model from that. Use either decoupled PD control or computed torque control using the inverse model to track joint position targets", InverseDynamicsExampleCreateFunc,BT_ID_PROGRAMMATICALLY),
ExampleEntry(0, "Inverse Kinematics"),
ExampleEntry(1, "SDLS", "Selectively Damped Least Squares by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_SDLS),
ExampleEntry(1, "DLS", "Damped Least Squares by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_DLS),
ExampleEntry(1, "DLS-SVD", "Damped Least Squares with Singular Value Decomposition by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_DLS_SVD),
ExampleEntry(1, "Jacobi Transpose", "Jacobi Transpose by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_JACOB_TRANS),
ExampleEntry(1, "Jacobi Pseudo Inv", "Jacobi Pseudo Inverse Method by Sam Buss. Example configures the IK tree of a Kuka IIWA", InverseKinematicsExampleCreateFunc, IK_PURE_PSEUDO),
ExampleEntry(0,"Tutorial"), ExampleEntry(0,"Tutorial"),
ExampleEntry(1,"Constant Velocity","Free moving rigid body, without external or constraint forces", TutorialCreateFunc,TUT_VELOCITY), ExampleEntry(1,"Constant Velocity","Free moving rigid body, without external or constraint forces", TutorialCreateFunc,TUT_VELOCITY),
@@ -184,7 +199,7 @@ static ExampleEntry gDefaultExamples[]=
#endif //INCLUDE_CLOTH_DEMOS #endif //INCLUDE_CLOTH_DEMOS
///we disable the benchmarks in debug mode, they are way too slow and benchmarking in debug mode is not recommended ///we disable the benchmarks in debug mode, they are way too slow and benchmarking in debug mode is not recommended
#ifndef _DEBUG //#ifndef _DEBUG
ExampleEntry(0,"Benchmarks"), ExampleEntry(0,"Benchmarks"),
ExampleEntry(1,"3000 boxes", "Benchmark a stack of 3000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver. ", BenchmarkCreateFunc, 1), ExampleEntry(1,"3000 boxes", "Benchmark a stack of 3000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver. ", BenchmarkCreateFunc, 1),
ExampleEntry(1,"1000 stack", "Benchmark a stack of 3000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver. ", ExampleEntry(1,"1000 stack", "Benchmark a stack of 3000 boxes. It will stress the collision detection, a specialized box-box implementation based on the separating axis test, and the constraint solver. ",
@@ -194,7 +209,7 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(1,"Prim vs Mesh", "Benchmark the performance and stability of rigid bodies using primitive collision shapes (btSphereShape, btBoxShape), resting on a triangle mesh, btBvhTriangleMeshShape.", BenchmarkCreateFunc, 5), ExampleEntry(1,"Prim vs Mesh", "Benchmark the performance and stability of rigid bodies using primitive collision shapes (btSphereShape, btBoxShape), resting on a triangle mesh, btBvhTriangleMeshShape.", BenchmarkCreateFunc, 5),
ExampleEntry(1,"Convex vs Mesh", "Benchmark the performance and stability of rigid bodies using convex hull collision shapes (btConvexHullShape), resting on a triangle mesh, btBvhTriangleMeshShape.", BenchmarkCreateFunc, 6), ExampleEntry(1,"Convex vs Mesh", "Benchmark the performance and stability of rigid bodies using convex hull collision shapes (btConvexHullShape), resting on a triangle mesh, btBvhTriangleMeshShape.", BenchmarkCreateFunc, 6),
ExampleEntry(1,"Raycast", "Benchmark the performance of the btCollisionWorld::rayTest. Note that currently the rays are not rendered.", BenchmarkCreateFunc, 7), ExampleEntry(1,"Raycast", "Benchmark the performance of the btCollisionWorld::rayTest. Note that currently the rays are not rendered.", BenchmarkCreateFunc, 7),
#endif //#endif
@@ -241,11 +256,13 @@ static ExampleEntry gDefaultExamples[]=
PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING), PhysicsServerCreateFunc,PHYSICS_SERVER_ENABLE_COMMAND_LOGGING),
ExampleEntry(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.", ExampleEntry(1,"Physics Server (Replay Log)", "Create a physics server that replay a command log from disk.",
PhysicsServerCreateFunc,PHYSICS_SERVER_REPLAY_FROM_COMMAND_LOG), PhysicsServerCreateFunc,PHYSICS_SERVER_REPLAY_FROM_COMMAND_LOG),
ExampleEntry(1, "Physics Client (Shared Mem)", "Create a physics client that can communicate with a physics server over shared memory.", PhysicsClientCreateFunc), ExampleEntry(1, "Physics Client (Shared Mem)", "Create a physics client that can communicate with a physics server over shared memory.", PhysicsClientCreateFunc),
ExampleEntry(1, "Physics Client (Direct)", "Create a physics client that can communicate with a physics server directly in-process.", PhysicsClientCreateFunc,eCLIENTEXAMPLE_DIRECT), ExampleEntry(1, "Physics Client (Direct)", "Create a physics client that can communicate with a physics server directly in-process.", PhysicsClientCreateFunc,eCLIENTEXAMPLE_DIRECT),
ExampleEntry(1,"R2D2 Grasp","Load the R2D2 robot from URDF file and control it to grasp objects", R2D2GraspExampleCreateFunc, eROBOTIC_LEARN_GRASP),
ExampleEntry(1,"URDF Compliant Contact","Work-in-progress, experiment/improve compliant rigid contact using parameters from URDF file (contact_cfm, contact_erp, lateral_friction, rolling_friction)", R2D2GraspExampleCreateFunc,eROBOTIC_LEARN_COMPLIANT_CONTACT),
ExampleEntry(1,"Contact for Grasp","Grasp experiment to improve contact model", GripperGraspExampleCreateFunc),
#ifdef ENABLE_LUA #ifdef ENABLE_LUA
@@ -273,11 +290,16 @@ static ExampleEntry gDefaultExamples[]=
//Extended Tutorials Added by Mobeen //Extended Tutorials Added by Mobeen
ExampleEntry(0,"Extended Tutorials"), ExampleEntry(0,"Extended Tutorials"),
ExampleEntry(1,"Simple Box", "Simplest possible demo creating a single box rigid body that falls under gravity", ET_SimpleBoxCreateFunc), ExampleEntry(1,"Simple Box", "Simplest possible demo creating a single box rigid body that falls under gravity", ET_SimpleBoxCreateFunc),
ExampleEntry(1,"Multiple Boxes", "Adding multiple box rigid bodies that fall under gravity", ET_MultipleBoxesCreateFunc), ExampleEntry(1,"Multiple Boxes", "Add multiple box rigid bodies that fall under gravity", ET_MultipleBoxesCreateFunc),
ExampleEntry(1,"Simple Joint", "Creating a single distance constraint between two box rigid bodies", ET_SimpleJointCreateFunc), ExampleEntry(1,"Simple Joint", "Create a single distance constraint between two box rigid bodies", ET_SimpleJointCreateFunc),
ExampleEntry(1,"Simple Cloth", "Creating a simple piece of cloth", ET_SimpleClothCreateFunc), ExampleEntry(1,"Simple Cloth", "Create a simple piece of cloth", ET_SimpleClothCreateFunc),
ExampleEntry(1,"Simple Chain", "Creating a simple chain using a pair of point2point/distance constraints. You may click and drag any box to see the chain respond.", ET_ChainCreateFunc), ExampleEntry(1,"Simple Chain", "Create a simple chain using a pair of point2point/distance constraints. You may click and drag any box to see the chain respond.", ET_ChainCreateFunc),
ExampleEntry(1,"Simple Bridge", "Creating a simple bridge using a pair of point2point/distance constraints. You may click and drag any plank to see the bridge respond.", ET_BridgeCreateFunc), ExampleEntry(1,"Simple Bridge", "Create a simple bridge using a pair of point2point/distance constraints. You may click and drag any plank to see the bridge respond.", ET_BridgeCreateFunc),
ExampleEntry(1,"Inclined Plane", "Create an inclined plane to show restitution and different types of friction. Use the sliders to vary restitution and friction and press space to reset the scene.", ET_InclinedPlaneCreateFunc),
ExampleEntry(1,"Newton's Cradle", "Create a Newton's Cradle using a pair of point2point/slider constraints. Press 1/2 to lengthen/shorten the pendula, press 3 to displace pendula. Use the sliders to select the number (reset simulation), length and restitution of pendula, the number of displaced pendula and apply the displacement force.", ET_NewtonsCradleCreateFunc),
ExampleEntry(1,"Newton's Rope Cradle", "Create a Newton's Cradle using ropes. Press 3 to displace pendula. Use the sliders to select the number (reset simulation), length and restitution of pendula and the number of displaced pendula and apply the displacement force.",ET_NewtonsRopeCradleCreateFunc),
ExampleEntry(1,"Multi-Pendulum", "Create a Multi-Pendulum using point2point/slider constraints. Press 1/2 to lengthen/shorten the pendula, press 3 to displace pendula. Use the sliders to select the number (reset simulation), length and restitution of pendula, the number of displaced pendula and apply the displacement force.",ET_MultiPendulumCreateFunc),
//todo: create a category/tutorial about advanced topics, such as optimizations, using different collision detection algorithm, different constraint solvers etc. //todo: create a category/tutorial about advanced topics, such as optimizations, using different collision detection algorithm, different constraint solvers etc.
//ExampleEntry(0,"Advanced"), //ExampleEntry(0,"Advanced"),

View File

@@ -21,6 +21,7 @@ void GraphingTexture::destroy()
m_height=0; m_height=0;
glDeleteTextures(1,(GLuint*)&m_textureId); glDeleteTextures(1,(GLuint*)&m_textureId);
m_textureId=0; m_textureId=0;
} }
bool GraphingTexture::create(int texWidth, int texHeight) bool GraphingTexture::create(int texWidth, int texHeight)

View File

@@ -4,7 +4,7 @@
#include "LinearMath/btQuickprof.h" #include "LinearMath/btQuickprof.h"
#ifndef BT_NO_PROFILE
class MyProfileWindow : public Gwen::Controls::WindowControl class MyProfileWindow : public Gwen::Controls::WindowControl
@@ -42,9 +42,10 @@ protected:
} }
public: public:
CProfileIterator* profIter; CProfileIterator* profIter;
class MyMenuItems* m_menuItems;
MyProfileWindow ( Gwen::Controls::Base* pParent) MyProfileWindow ( Gwen::Controls::Base* pParent)
: Gwen::Controls::WindowControl( pParent ), : Gwen::Controls::WindowControl( pParent ),
profIter(0) profIter(0)
@@ -83,6 +84,12 @@ public:
} }
virtual ~MyProfileWindow()
{
delete m_node;
delete m_ctrl;
}
float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode) float dumpRecursive(CProfileIterator* profileIterator, Gwen::Controls::TreeNode* parentNode)
{ {
@@ -266,11 +273,16 @@ public:
MyProfileWindow* setupProfileWindow(GwenInternalData* data) MyProfileWindow* setupProfileWindow(GwenInternalData* data)
{ {
MyMenuItems* menuItems = new MyMenuItems; MyMenuItems* menuItems = new MyMenuItems;
MyProfileWindow* profWindow = new MyProfileWindow(data->pCanvas); MyProfileWindow* profWindow = new MyProfileWindow(data->pCanvas);
//profWindow->SetHidden(true); //profWindow->SetHidden(true);
profWindow->profIter = CProfileManager::Get_Iterator();
profWindow->m_menuItems = menuItems;
//profWindow->profIter = CProfileManager::Get_Iterator();
data->m_viewMenu->GetMenu()->AddItem( L"Profiler", menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::MenuItemSelect); data->m_viewMenu->GetMenu()->AddItem( L"Profiler", menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::MenuItemSelect);
menuItems->m_profWindow = profWindow; menuItems->m_profWindow = profWindow;
return profWindow; return profWindow;
} }
@@ -290,5 +302,8 @@ void profileWindowSetVisible(MyProfileWindow* window, bool visible)
} }
void destroyProfileWindow(MyProfileWindow* window) void destroyProfileWindow(MyProfileWindow* window)
{ {
CProfileManager::Release_Iterator(window->profIter);
delete window; delete window;
} }
#endif //BT_NO_PROFILE

View File

@@ -45,7 +45,10 @@ struct GwenInternalData
Gwen::Controls::ListBox* m_TextOutput; Gwen::Controls::ListBox* m_TextOutput;
Gwen::Controls::Label* m_exampleInfoGroupBox; Gwen::Controls::Label* m_exampleInfoGroupBox;
Gwen::Controls::ListBox* m_exampleInfoTextOutput; Gwen::Controls::ListBox* m_exampleInfoTextOutput;
struct MyTestMenuBar* m_menubar;
Gwen::Controls::StatusBar* m_bar;
Gwen::Controls::ScrollControl* m_windowRight;
Gwen::Controls::TabControl* m_tab;
int m_curYposition; int m_curYposition;

View File

@@ -17,6 +17,83 @@ GwenUserInterface::GwenUserInterface()
} }
class MyMenuItems : public Gwen::Controls::Base
{
public:
b3FileOpenCallback m_fileOpenCallback;
b3QuitCallback m_quitCallback;
MyMenuItems() :Gwen::Controls::Base(0), m_fileOpenCallback(0)
{
}
void myQuitApp(Gwen::Controls::Base* pControl)
{
if (m_quitCallback)
{
(*m_quitCallback)();
}
}
void fileOpen(Gwen::Controls::Base* pControl)
{
if (m_fileOpenCallback)
{
(*m_fileOpenCallback)();
}
}
};
struct MyTestMenuBar : public Gwen::Controls::MenuStrip
{
Gwen::Controls::MenuItem* m_fileMenu;
Gwen::Controls::MenuItem* m_viewMenu;
MyMenuItems* m_menuItems;
MyTestMenuBar(Gwen::Controls::Base* pParent)
:Gwen::Controls::MenuStrip(pParent)
{
// Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip( pParent );
{
m_menuItems = new MyMenuItems();
m_menuItems->m_fileOpenCallback = 0;
m_menuItems->m_quitCallback = 0;
m_fileMenu = AddItem(L"File");
m_fileMenu->GetMenu()->AddItem(L"Open", m_menuItems, (Gwen::Event::Handler::Function)&MyMenuItems::fileOpen);
m_fileMenu->GetMenu()->AddItem(L"Quit", m_menuItems, (Gwen::Event::Handler::Function)&MyMenuItems::myQuitApp);
m_viewMenu = AddItem(L"View");
}
}
virtual ~MyTestMenuBar()
{
delete m_menuItems;
}
};
void GwenUserInterface::exit()
{
//m_data->m_menubar->RemoveAllChildren();
delete m_data->m_tab;
delete m_data->m_windowRight;
delete m_data->m_leftStatusBar;
delete m_data->m_TextOutput;
delete m_data->m_rightStatusBar;
delete m_data->m_bar;
delete m_data->m_menubar;
m_data->m_menubar = 0;
delete m_data->pCanvas;
m_data->pCanvas = 0;
}
GwenUserInterface::~GwenUserInterface() GwenUserInterface::~GwenUserInterface()
{ {
for (int i=0;i<m_data->m_handlers.size();i++) for (int i=0;i<m_data->m_handlers.size();i++)
@@ -26,72 +103,15 @@ GwenUserInterface::~GwenUserInterface()
m_data->m_handlers.clear(); m_data->m_handlers.clear();
delete m_data->pCanvas;
delete m_data; delete m_data;
} }
class MyMenuItems : public Gwen::Controls::Base
{
public:
b3FileOpenCallback m_fileOpenCallback;
b3QuitCallback m_quitCallback;
MyMenuItems() :Gwen::Controls::Base(0),m_fileOpenCallback(0)
{
}
void myQuitApp( Gwen::Controls::Base* pControl )
{
if (m_quitCallback)
{
(*m_quitCallback)();
}
}
void fileOpen( Gwen::Controls::Base* pControl )
{
if (m_fileOpenCallback)
{
(*m_fileOpenCallback)();
}
}
};
struct MyTestMenuBar : public Gwen::Controls::MenuStrip
{
Gwen::Controls::MenuItem* m_fileMenu;
Gwen::Controls::MenuItem* m_viewMenu;
MyMenuItems* m_menuItems;
MyTestMenuBar(Gwen::Controls::Base* pParent)
:Gwen::Controls::MenuStrip(pParent)
{
// Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip( pParent );
{
m_menuItems = new MyMenuItems();
m_menuItems->m_fileOpenCallback = 0;
m_menuItems->m_quitCallback = 0;
m_fileMenu = AddItem( L"File" );
m_fileMenu->GetMenu()->AddItem(L"Open",m_menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::fileOpen);
m_fileMenu->GetMenu()->AddItem(L"Quit",m_menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::myQuitApp);
m_viewMenu = AddItem( L"View" );
}
}
};
void GwenUserInterface::resize(int width, int height) void GwenUserInterface::resize(int width, int height)
{ {
@@ -232,6 +252,7 @@ void GwenUserInterface::setStatusBarMessage(const char* message, bool isLeft)
} }
} }
void GwenUserInterface::registerFileOpenCallback(b3FileOpenCallback callback) void GwenUserInterface::registerFileOpenCallback(b3FileOpenCallback callback)
{ {
m_data->m_menuItems->m_fileOpenCallback = callback; m_data->m_menuItems->m_fileOpenCallback = callback;
@@ -249,35 +270,43 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
m_data->pRenderer = renderer;//new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale); m_data->pRenderer = renderer;//new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);
m_data->skin.SetRender( m_data->pRenderer ); m_data->skin.SetRender( m_data->pRenderer );
m_data->pCanvas= new Gwen::Controls::Canvas( &m_data->skin ); m_data->pCanvas= new Gwen::Controls::Canvas( &m_data->skin );
m_data->pCanvas->SetSize( width,height); m_data->pCanvas->SetSize( width,height);
m_data->pCanvas->SetDrawBackground( false); m_data->pCanvas->SetDrawBackground( false);
m_data->pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) ); m_data->pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
MyTestMenuBar* menubar = new MyTestMenuBar(m_data->pCanvas); MyTestMenuBar* menubar = new MyTestMenuBar(m_data->pCanvas);
m_data->m_viewMenu = menubar->m_viewMenu; m_data->m_viewMenu = menubar->m_viewMenu;
m_data->m_menuItems = menubar->m_menuItems; m_data->m_menuItems = menubar->m_menuItems;
m_data->m_menubar = menubar;
Gwen::Controls::StatusBar* bar = new Gwen::Controls::StatusBar(m_data->pCanvas); Gwen::Controls::StatusBar* bar = new Gwen::Controls::StatusBar(m_data->pCanvas);
m_data->m_bar = bar;
m_data->m_rightStatusBar = new Gwen::Controls::Label( bar ); m_data->m_rightStatusBar = new Gwen::Controls::Label( bar );
m_data->m_rightStatusBar->SetWidth(width/2); m_data->m_rightStatusBar->SetWidth(width/2);
//m_data->m_rightStatusBar->SetText( L"Label Added to Right" ); //m_data->m_rightStatusBar->SetText( L"Label Added to Right" );
bar->AddControl( m_data->m_rightStatusBar, true ); bar->AddControl( m_data->m_rightStatusBar, true );
m_data->m_TextOutput = new Gwen::Controls::ListBox( m_data->pCanvas ); m_data->m_TextOutput = new Gwen::Controls::ListBox( m_data->pCanvas );
m_data->m_TextOutput->Dock( Gwen::Pos::Bottom ); m_data->m_TextOutput->Dock( Gwen::Pos::Bottom );
m_data->m_TextOutput->SetHeight( 100 ); m_data->m_TextOutput->SetHeight( 100 );
m_data->m_leftStatusBar = new Gwen::Controls::Label( bar ); m_data->m_leftStatusBar = new Gwen::Controls::Label( bar );
//m_data->m_leftStatusBar->SetText( L"Label Added to Left" ); //m_data->m_leftStatusBar->SetText( L"Label Added to Left" );
m_data->m_leftStatusBar->SetWidth(width/2); m_data->m_leftStatusBar->SetWidth(width/2);
bar->AddControl( m_data->m_leftStatusBar,false); bar->AddControl( m_data->m_leftStatusBar,false);
//Gwen::KeyboardFocus //Gwen::KeyboardFocus
/*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas); /*Gwen::Controls::GroupBox* box = new Gwen::Controls::GroupBox(m_data->pCanvas);
box->SetText("text"); box->SetText("text");
@@ -289,11 +318,14 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
windowRight->SetWidth(250); windowRight->SetWidth(250);
windowRight->SetHeight(250); windowRight->SetHeight(250);
windowRight->SetScroll(false,true); windowRight->SetScroll(false,true);
m_data->m_windowRight = windowRight;
//windowLeft->SetSkin( //windowLeft->SetSkin(
Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight); Gwen::Controls::TabControl* tab = new Gwen::Controls::TabControl(windowRight);
m_data->m_tab = tab;
//tab->SetHeight(300); //tab->SetHeight(300);
tab->SetWidth(240); tab->SetWidth(240);
@@ -304,7 +336,8 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
Gwen::UnicodeString str1(L"Params"); Gwen::UnicodeString str1(L"Params");
m_data->m_demoPage = tab->AddPage(str1); m_data->m_demoPage = tab->AddPage(str1);
@@ -348,7 +381,7 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
//windowLeft->SetClosable(false); //windowLeft->SetClosable(false);
// windowLeft->SetShouldDrawBackground(true); // windowLeft->SetShouldDrawBackground(true);
windowLeft->SetTabable(true); windowLeft->SetTabable(true);
Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft); Gwen::Controls::TabControl* explorerTab = new Gwen::Controls::TabControl(windowLeft);
//tab->SetHeight(300); //tab->SetHeight(300);
@@ -388,7 +421,6 @@ void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* rendere
m_data->m_exampleInfoGroupBox->SetText("Example Description"); m_data->m_exampleInfoGroupBox->SetText("Example Description");
m_data->m_exampleInfoTextOutput = new Gwen::Controls::ListBox(m_data->m_explorerPage->GetPage()); m_data->m_exampleInfoTextOutput = new Gwen::Controls::ListBox(m_data->m_explorerPage->GetPage());
//m_data->m_exampleInfoTextOutput->Dock( Gwen::Pos::Bottom ); //m_data->m_exampleInfoTextOutput->Dock( Gwen::Pos::Bottom );
m_data->m_exampleInfoTextOutput->SetPos(2, 332); m_data->m_exampleInfoTextOutput->SetPos(2, 332);

View File

@@ -26,6 +26,7 @@ class GwenUserInterface
virtual ~GwenUserInterface(); virtual ~GwenUserInterface();
void init(int width, int height,Gwen::Renderer::Base* gwenRenderer,float retinaScale); void init(int width, int height,Gwen::Renderer::Base* gwenRenderer,float retinaScale);
void exit();
void setFocus(); void setFocus();
void forceUpdateScrollBars(); void forceUpdateScrollBars();

View File

@@ -226,7 +226,7 @@ enum TestExampleBrowserCommunicationEnums
void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory) void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory)
{ {
printf("thread started\n"); printf("ExampleBrowserThreadFunc started\n");
ExampleBrowserThreadLocalStorage* localStorage = (ExampleBrowserThreadLocalStorage*) lsMemory; ExampleBrowserThreadLocalStorage* localStorage = (ExampleBrowserThreadLocalStorage*) lsMemory;
@@ -332,6 +332,7 @@ btInProcessExampleBrowserInternalData* btCreateInProcessExampleBrowser(int argc,
while (data->m_args.m_cs->getSharedParam(0)==eExampleBrowserIsUnInitialized) while (data->m_args.m_cs->getSharedParam(0)==eExampleBrowserIsUnInitialized)
{ {
b3Clock::usleep(1000);
} }
return data; return data;
@@ -366,10 +367,11 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data)
} else } else
{ {
// printf("polling.."); // printf("polling..");
b3Clock::usleep(1000);
} }
}; };
printf("stopping threads\n"); printf("btShutDownExampleBrowser stopping threads\n");
delete data->m_threadSupport; delete data->m_threadSupport;
delete data->m_sharedMem; delete data->m_sharedMem;
delete data; delete data;

View File

@@ -42,26 +42,72 @@
#include "../Importers/ImportURDFDemo/ImportURDFSetup.h" #include "../Importers/ImportURDFDemo/ImportURDFSetup.h"
#include "../Importers/ImportBullet/SerializeSetup.h" #include "../Importers/ImportBullet/SerializeSetup.h"
#include "Bullet3Common/b3HashMap.h"
struct GL3TexLoader : public MyTextureLoader
{
b3HashMap<b3HashString, GLint> m_hashMap;
virtual void LoadTexture(Gwen::Texture* pTexture)
{
Gwen::String namestr = pTexture->name.Get();
const char* n = namestr.c_str();
GLint* texIdPtr = m_hashMap[n];
if (texIdPtr)
{
pTexture->m_intData = *texIdPtr;
}
}
virtual void FreeTexture(Gwen::Texture* pTexture)
{
}
};
struct OpenGLExampleBrowserInternalData
{
Gwen::Renderer::Base* m_gwenRenderer;
CommonGraphicsApp* m_app;
// MyProfileWindow* m_profWindow;
btAlignedObjectArray<Gwen::Controls::TreeNode*> m_nodes;
GwenUserInterface* m_gui;
GL3TexLoader* m_myTexLoader;
struct MyMenuItemHander* m_handler2;
btAlignedObjectArray<MyMenuItemHander*> m_handlers;
OpenGLExampleBrowserInternalData()
: m_gwenRenderer(0),
m_app(0),
// m_profWindow(0),
m_gui(0),
m_myTexLoader(0),
m_handler2(0)
{
}
};
static CommonGraphicsApp* s_app=0; static CommonGraphicsApp* s_app=0;
static CommonWindowInterface* s_window = 0; static CommonWindowInterface* s_window = 0;
static CommonParameterInterface* s_parameterInterface=0; static CommonParameterInterface* s_parameterInterface=0;
static CommonRenderInterface* s_instancingRenderer=0; static CommonRenderInterface* s_instancingRenderer=0;
static OpenGLGuiHelper* s_guiHelper=0; static OpenGLGuiHelper* s_guiHelper=0;
static MyProfileWindow* s_profWindow =0; //static MyProfileWindow* s_profWindow =0;
static SharedMemoryInterface* sSharedMem = 0; static SharedMemoryInterface* sSharedMem = 0;
#define DEMO_SELECTION_COMBOBOX 13 #define DEMO_SELECTION_COMBOBOX 13
const char* startFileName = "0_Bullet3Demo.txt"; const char* startFileName = "0_Bullet3Demo.txt";
char staticPngFileName[1024]; char staticPngFileName[1024];
static GwenUserInterface* gui = 0; //static GwenUserInterface* gui = 0;
static GwenUserInterface* gui2 = 0;
static int sCurrentDemoIndex = -1; static int sCurrentDemoIndex = -1;
static int sCurrentHightlighted = 0; static int sCurrentHightlighted = 0;
static CommonExampleInterface* sCurrentDemo = 0; static CommonExampleInterface* sCurrentDemo = 0;
static b3AlignedObjectArray<const char*> allNames; static b3AlignedObjectArray<const char*> allNames;
static float gFixedTimeStep = 0; static float gFixedTimeStep = 0;
bool gAllowRetina = true; bool gAllowRetina = true;
bool gDisableDemoSelection = false;
static class ExampleEntries* gAllExamples=0; static class ExampleEntries* gAllExamples=0;
bool sUseOpenGL2 = false; bool sUseOpenGL2 = false;
bool drawGUI=true; bool drawGUI=true;
@@ -111,6 +157,7 @@ void deleteDemo()
} }
const char* gPngFileName = 0; const char* gPngFileName = 0;
int gPngSkipFrames = 0;
@@ -123,9 +170,9 @@ void MyKeyboardCallback(int key, int state)
//b3Printf("key=%d, state=%d", key, state); //b3Printf("key=%d, state=%d", key, state);
bool handled = false; bool handled = false;
if (gui && !handled ) if (gui2 && !handled )
{ {
handled = gui->keyboardCallback(key, state); handled = gui2->keyboardCallback(key, state);
} }
if (!handled && sCurrentDemo) if (!handled && sCurrentDemo)
@@ -223,11 +270,11 @@ void MyKeyboardCallback(int key, int state)
b3MouseMoveCallback prevMouseMoveCallback = 0; b3MouseMoveCallback prevMouseMoveCallback = 0;
static void MyMouseMoveCallback( float x, float y) static void MyMouseMoveCallback( float x, float y)
{ {
bool handled = false; bool handled = false;
if (sCurrentDemo) if (sCurrentDemo)
handled = sCurrentDemo->mouseMoveCallback(x,y); handled = sCurrentDemo->mouseMoveCallback(x,y);
if (!handled && gui) if (!handled && gui2)
handled = gui->mouseMoveCallback(x,y); handled = gui2->mouseMoveCallback(x,y);
if (!handled) if (!handled)
{ {
if (prevMouseMoveCallback) if (prevMouseMoveCallback)
@@ -244,8 +291,8 @@ static void MyMouseButtonCallback(int button, int state, float x, float y)
if (sCurrentDemo) if (sCurrentDemo)
handled = sCurrentDemo->mouseButtonCallback(button,state,x,y); handled = sCurrentDemo->mouseButtonCallback(button,state,x,y);
if (!handled && gui) if (!handled && gui2)
handled = gui->mouseButtonCallback(button,state,x,y); handled = gui2->mouseButtonCallback(button,state,x,y);
if (!handled) if (!handled)
{ {
@@ -333,7 +380,10 @@ void selectDemo(int demoIndex)
CommonExampleInterface::CreateFunc* func = gAllExamples->getExampleCreateFunc(demoIndex); CommonExampleInterface::CreateFunc* func = gAllExamples->getExampleCreateFunc(demoIndex);
if (func) if (func)
{ {
s_parameterInterface->removeAllParameters(); if (s_parameterInterface)
{
s_parameterInterface->removeAllParameters();
}
int option = gAllExamples->getExampleOption(demoIndex); int option = gAllExamples->getExampleOption(demoIndex);
s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2); s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2);
CommonExampleOptions options(s_guiHelper, option); CommonExampleOptions options(s_guiHelper, option);
@@ -341,12 +391,15 @@ void selectDemo(int demoIndex)
sCurrentDemo = (*func)(options); sCurrentDemo = (*func)(options);
if (sCurrentDemo) if (sCurrentDemo)
{ {
if (gui) if (gui2)
{ {
gui->setStatusBarMessage("Status: OK", false); gui2->setStatusBarMessage("Status: OK", false);
} }
b3Printf("Selected demo: %s",gAllExamples->getExampleName(demoIndex)); b3Printf("Selected demo: %s",gAllExamples->getExampleName(demoIndex));
gui->setExampleDescription(gAllExamples->getExampleDescription(demoIndex)); if (gui2)
{
gui2->setExampleDescription(gAllExamples->getExampleDescription(demoIndex));
}
sCurrentDemo->initPhysics(); sCurrentDemo->initPhysics();
if(resetCamera) if(resetCamera)
@@ -399,7 +452,6 @@ static void loadCurrentSettings(const char* startFileName, b3CommandLineArgs& ar
FILE* f = fopen(startFileName,"r"); FILE* f = fopen(startFileName,"r");
if (f) if (f)
{ {
int result;
char oneline[1024]; char oneline[1024];
char* argv[] = {0,&oneline[0]}; char* argv[] = {0,&oneline[0]};
@@ -438,10 +490,10 @@ void MyComboBoxCallback(int comboId, const char* item)
void MyGuiPrintf(const char* msg) void MyGuiPrintf(const char* msg)
{ {
printf("b3Printf: %s\n",msg); printf("b3Printf: %s\n",msg);
if (gui) if (gui2)
{ {
gui->textOutput(msg); gui2->textOutput(msg);
gui->forceUpdateScrollBars(); gui2->forceUpdateScrollBars();
} }
} }
@@ -450,10 +502,10 @@ void MyGuiPrintf(const char* msg)
void MyStatusBarPrintf(const char* msg) void MyStatusBarPrintf(const char* msg)
{ {
printf("b3Printf: %s\n", msg); printf("b3Printf: %s\n", msg);
if (gui) if (gui2)
{ {
bool isLeft = true; bool isLeft = true;
gui->setStatusBarMessage(msg,isLeft); gui2->setStatusBarMessage(msg,isLeft);
} }
} }
@@ -461,13 +513,15 @@ void MyStatusBarPrintf(const char* msg)
void MyStatusBarError(const char* msg) void MyStatusBarError(const char* msg)
{ {
printf("Warning: %s\n", msg); printf("Warning: %s\n", msg);
if (gui) if (gui2)
{ {
bool isLeft = false; bool isLeft = false;
gui->setStatusBarMessage(msg,isLeft); gui2->setStatusBarMessage(msg,isLeft);
gui->textOutput(msg); gui2->textOutput(msg);
gui->forceUpdateScrollBars(); gui2->forceUpdateScrollBars();
} }
btAssert(0);
} }
struct MyMenuItemHander :public Gwen::Event::Handler struct MyMenuItemHander :public Gwen::Event::Handler
@@ -502,9 +556,11 @@ struct MyMenuItemHander :public Gwen::Event::Handler
Gwen::String laa = Gwen::Utility::UnicodeToString(la); Gwen::String laa = Gwen::Utility::UnicodeToString(la);
//const char* ha = laa.c_str(); //const char* ha = laa.c_str();
if (!gDisableDemoSelection )
selectDemo(sCurrentHightlighted); {
saveCurrentSettings(sCurrentDemoIndex, startFileName); selectDemo(sCurrentHightlighted);
saveCurrentSettings(sCurrentDemoIndex, startFileName);
}
} }
void onButtonC(Gwen::Controls::Base* pControl) void onButtonC(Gwen::Controls::Base* pControl)
{ {
@@ -526,8 +582,11 @@ struct MyMenuItemHander :public Gwen::Event::Handler
*/ */
// printf("onKeyReturn ! \n"); // printf("onKeyReturn ! \n");
selectDemo(sCurrentHightlighted); if (!gDisableDemoSelection )
saveCurrentSettings(sCurrentDemoIndex, startFileName); {
selectDemo(sCurrentHightlighted);
saveCurrentSettings(sCurrentDemoIndex, startFileName);
}
} }
@@ -535,7 +594,7 @@ struct MyMenuItemHander :public Gwen::Event::Handler
{ {
// printf("select %d\n",m_buttonId); // printf("select %d\n",m_buttonId);
sCurrentHightlighted = m_buttonId; sCurrentHightlighted = m_buttonId;
gui->setExampleDescription(gAllExamples->getExampleDescription(sCurrentHightlighted)); gui2->setExampleDescription(gAllExamples->getExampleDescription(sCurrentHightlighted));
} }
void onButtonF(Gwen::Controls::Base* pControl) void onButtonF(Gwen::Controls::Base* pControl)
@@ -550,26 +609,6 @@ struct MyMenuItemHander :public Gwen::Event::Handler
};
#include "Bullet3Common/b3HashMap.h"
struct GL3TexLoader : public MyTextureLoader
{
b3HashMap<b3HashString,GLint> m_hashMap;
virtual void LoadTexture( Gwen::Texture* pTexture )
{
Gwen::String namestr = pTexture->name.Get();
const char* n = namestr.c_str();
GLint* texIdPtr = m_hashMap[n];
if (texIdPtr)
{
pTexture->m_intData = *texIdPtr;
}
}
virtual void FreeTexture( Gwen::Texture* pTexture )
{
}
}; };
void quitCallback() void quitCallback()
@@ -600,10 +639,12 @@ struct QuickCanvas : public Common2dCanvasInterface
MyGraphWindow* m_gw[MAX_GRAPH_WINDOWS]; MyGraphWindow* m_gw[MAX_GRAPH_WINDOWS];
GraphingTexture* m_gt[MAX_GRAPH_WINDOWS]; GraphingTexture* m_gt[MAX_GRAPH_WINDOWS];
int m_curNumGraphWindows; int m_curNumGraphWindows;
int m_curXpos;
QuickCanvas(GL3TexLoader* myTexLoader) QuickCanvas(GL3TexLoader* myTexLoader)
:m_myTexLoader(myTexLoader), :m_myTexLoader(myTexLoader),
m_curNumGraphWindows(0) m_curNumGraphWindows(0),
m_curXpos(0)
{ {
for (int i=0;i<MAX_GRAPH_WINDOWS;i++) for (int i=0;i<MAX_GRAPH_WINDOWS;i++)
{ {
@@ -624,10 +665,11 @@ struct QuickCanvas : public Common2dCanvasInterface
m_curNumGraphWindows++; m_curNumGraphWindows++;
MyGraphInput input(gui->getInternalData()); MyGraphInput input(gui2->getInternalData());
input.m_width=width; input.m_width=width;
input.m_height=height; input.m_height=height;
input.m_xPos = 10000;//GUI will clamp it to the right//300; input.m_xPos = m_curXpos;//GUI will clamp it to the right//300;
m_curXpos+=width+20;
input.m_yPos = 10000;//GUI will clamp it to bottom input.m_yPos = 10000;//GUI will clamp it to bottom
input.m_name=canvasName; input.m_name=canvasName;
input.m_texName = canvasName; input.m_texName = canvasName;
@@ -643,8 +685,12 @@ struct QuickCanvas : public Common2dCanvasInterface
} }
virtual void destroyCanvas(int canvasId) virtual void destroyCanvas(int canvasId)
{ {
m_curXpos = 0;
btAssert(canvasId>=0); btAssert(canvasId>=0);
delete m_gt[canvasId];
m_gt[canvasId] = 0;
destroyTextureWindow(m_gw[canvasId]); destroyTextureWindow(m_gw[canvasId]);
m_gw[canvasId] = 0;
m_curNumGraphWindows--; m_curNumGraphWindows--;
} }
virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green,unsigned char blue, unsigned char alpha) virtual void setPixel(int canvasId, int x, int y, unsigned char red, unsigned char green,unsigned char blue, unsigned char alpha)
@@ -670,12 +716,51 @@ struct QuickCanvas : public Common2dCanvasInterface
OpenGLExampleBrowser::OpenGLExampleBrowser(class ExampleEntries* examples) OpenGLExampleBrowser::OpenGLExampleBrowser(class ExampleEntries* examples)
{ {
m_internalData = new OpenGLExampleBrowserInternalData;
gAllExamples = examples; gAllExamples = examples;
} }
OpenGLExampleBrowser::~OpenGLExampleBrowser() OpenGLExampleBrowser::~OpenGLExampleBrowser()
{ {
deleteDemo(); deleteDemo();
for (int i = 0; i < m_internalData->m_nodes.size(); i++)
{
delete m_internalData->m_nodes[i];
}
delete m_internalData->m_handler2;
for (int i = 0; i < m_internalData->m_handlers.size(); i++)
{
delete m_internalData->m_handlers[i];
}
m_internalData->m_handlers.clear();
m_internalData->m_nodes.clear();
delete s_parameterInterface;
s_parameterInterface = 0;
delete s_app->m_2dCanvasInterface;
s_app->m_2dCanvasInterface = 0;
m_internalData->m_gui->exit();
delete m_internalData->m_gui;
delete m_internalData->m_gwenRenderer;
delete m_internalData->m_myTexLoader;
delete m_internalData->m_app;
s_app = 0;
// delete m_internalData->m_profWindow;
delete m_internalData;
gFileImporterByExtension.clear();
gAllExamples = 0; gAllExamples = 0;
} }
@@ -688,7 +773,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
loadCurrentSettings(startFileName, args); loadCurrentSettings(startFileName, args);
args.GetCmdLineArgument("fixed_timestep",gFixedTimeStep); args.GetCmdLineArgument("fixed_timestep",gFixedTimeStep);
args.GetCmdLineArgument("png_skip_frames", gPngSkipFrames);
///The OpenCL rigid body pipeline is experimental and ///The OpenCL rigid body pipeline is experimental and
///most OpenCL drivers and OpenCL compilers have issues with our kernels. ///most OpenCL drivers and OpenCL compilers have issues with our kernels.
///If you have a high-end desktop GPU such as AMD 7970 or better, or NVIDIA GTX 680 with up-to-date drivers ///If you have a high-end desktop GPU such as AMD 7970 or better, or NVIDIA GTX 680 with up-to-date drivers
@@ -727,17 +812,17 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
s_app = new SimpleOpenGL2App(title,width,height); s_app = new SimpleOpenGL2App(title,width,height);
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height); s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
} }
#ifndef NO_OPENGL3 #ifndef NO_OPENGL3
else else
{ {
char title[1024]; char title[1024];
sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode); sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina); simpleApp = new SimpleOpenGL3App(title,width,height, gAllowRetina);
s_app = simpleApp; s_app = simpleApp;
} }
#endif #endif
m_internalData->m_app = s_app;
char* gVideoFileName = 0; char* gVideoFileName = 0;
args.GetCmdLineArgument("mp4",gVideoFileName); args.GetCmdLineArgument("mp4",gVideoFileName);
#ifndef NO_OPENGL3 #ifndef NO_OPENGL3
@@ -793,43 +878,67 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
assert(glGetError()==GL_NO_ERROR); assert(glGetError()==GL_NO_ERROR);
{
GL3TexLoader* myTexLoader = new GL3TexLoader;
m_internalData->m_myTexLoader = myTexLoader;
gui = new GwenUserInterface; sth_stash* fontstash = simpleApp->getFontStash();
GL3TexLoader* myTexLoader = new GL3TexLoader;
if (sUseOpenGL2)
Gwen::Renderer::Base* gwenRenderer = 0; {
if (sUseOpenGL2 ) m_internalData->m_gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
{ }
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
}
#ifndef NO_OPENGL3 #ifndef NO_OPENGL3
else else
{ {
sth_stash* fontstash=simpleApp->getFontStash(); sth_stash* fontstash = simpleApp->getFontStash();
gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer,fontstash,width,height,s_window->getRetinaScale(),myTexLoader); m_internalData->m_gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer, fontstash, width, height, s_window->getRetinaScale(), myTexLoader);
} }
#endif #endif
gui2 = new GwenUserInterface;
m_internalData->m_gui = gui2;
m_internalData->m_myTexLoader = myTexLoader;
gui2->init(width, height, m_internalData->m_gwenRenderer, s_window->getRetinaScale());
}
//gui = 0;// new GwenUserInterface;
GL3TexLoader* myTexLoader = m_internalData->m_myTexLoader;
// = myTexLoader;
// //
gui->init(width,height,gwenRenderer,s_window->getRetinaScale()); if (gui2)
{
// gui->getInternalData()->m_explorerPage
Gwen::Controls::TreeControl* tree = gui->getInternalData()->m_explorerTreeCtrl;
// gui->getInternalData()->m_explorerPage
Gwen::Controls::TreeControl* tree = gui2->getInternalData()->m_explorerTreeCtrl;
//gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);
// s_profWindow= setupProfileWindow(gui2->getInternalData());
//m_internalData->m_profWindow = s_profWindow;
// profileWindowSetVisible(s_profWindow,false);
gui2->setFocus();
s_parameterInterface = s_app->m_parameterInterface = new GwenParameterInterface(gui2->getInternalData());
s_app->m_2dCanvasInterface = new QuickCanvas(myTexLoader);
//gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);
s_profWindow= setupProfileWindow(gui->getInternalData());
profileWindowSetVisible(s_profWindow,false);
gui->setFocus();
s_parameterInterface = s_app->m_parameterInterface = new GwenParameterInterface(gui->getInternalData());
s_app->m_2dCanvasInterface = new QuickCanvas(myTexLoader);
///add some demos to the gAllExamples ///add some demos to the gAllExamples
@@ -840,7 +949,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
//int curDemo = 0; //int curDemo = 0;
int selectedDemo = 0; int selectedDemo = 0;
Gwen::Controls::TreeNode* curNode = tree; Gwen::Controls::TreeNode* curNode = tree;
MyMenuItemHander* handler2 = new MyMenuItemHander(-1); m_internalData->m_handler2 = new MyMenuItemHander(-1);
char* demoNameFromCommandOption = 0; char* demoNameFromCommandOption = 0;
args.GetCmdLineArgument("start_demo_name", demoNameFromCommandOption); args.GetCmdLineArgument("start_demo_name", demoNameFromCommandOption);
@@ -848,7 +957,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
selectedDemo = -1; selectedDemo = -1;
} }
tree->onReturnKeyDown.Add(handler2, &MyMenuItemHander::onButtonD); tree->onReturnKeyDown.Add(m_internalData->m_handler2, &MyMenuItemHander::onButtonD);
int firstAvailableDemoIndex=-1; int firstAvailableDemoIndex=-1;
Gwen::Controls::TreeNode* firstNode=0; Gwen::Controls::TreeNode* firstNode=0;
@@ -895,13 +1004,18 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
} }
} }
#if 1
MyMenuItemHander* handler = new MyMenuItemHander(d); MyMenuItemHander* handler = new MyMenuItemHander(d);
m_internalData->m_handlers.push_back(handler);
pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA); pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB); pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB);
pNode->GetButton()->onDown.Add(handler, &MyMenuItemHander::onButtonC); pNode->GetButton()->onDown.Add(handler, &MyMenuItemHander::onButtonC);
pNode->onSelect.Add(handler, &MyMenuItemHander::onButtonE); pNode->onSelect.Add(handler, &MyMenuItemHander::onButtonE);
pNode->onReturnKeyDown.Add(handler, &MyMenuItemHander::onButtonG); pNode->onReturnKeyDown.Add(handler, &MyMenuItemHander::onButtonG);
pNode->onSelectChange.Add(handler, &MyMenuItemHander::onButtonF); pNode->onSelectChange.Add(handler, &MyMenuItemHander::onButtonF);
#endif
// pNode->onKeyReturn.Add(handler, &MyMenuItemHander::onButtonD); // pNode->onKeyReturn.Add(handler, &MyMenuItemHander::onButtonD);
// pNode->GetButton()->onKeyboardReturn.Add(handler, &MyMenuItemHander::onButtonD); // pNode->GetButton()->onKeyboardReturn.Add(handler, &MyMenuItemHander::onButtonD);
// pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonD); // pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonD);
@@ -911,6 +1025,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
else else
{ {
curNode = tree->AddNode(nodeUText); curNode = tree->AddNode(nodeUText);
m_internalData->m_nodes.push_back(curNode);
} }
} }
@@ -929,6 +1044,9 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
} }
} }
free(demoNameFromCommandOption);
demoNameFromCommandOption = 0;
btAssert(sCurrentDemo!=0); btAssert(sCurrentDemo!=0);
if (sCurrentDemo==0) if (sCurrentDemo==0)
{ {
@@ -936,9 +1054,11 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
exit(0); exit(0);
} }
gui->registerFileOpenCallback(fileOpenCallback); gui2->registerFileOpenCallback(fileOpenCallback);
gui->registerQuitCallback(quitCallback); gui2->registerQuitCallback(quitCallback);
}
return true; return true;
} }
@@ -971,14 +1091,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
s_instancingRenderer->updateCamera(dg.upAxis); s_instancingRenderer->updateCamera(dg.upAxis);
} }
if (renderGrid)
{
BT_PROFILE("Draw Grid");
glPolygonOffset(3.0, 3);
glEnable(GL_POLYGON_OFFSET_FILL);
s_app->drawGrid(dg);
}
static int frameCount = 0; static int frameCount = 0;
frameCount++; frameCount++;
@@ -990,6 +1103,24 @@ void OpenGLExampleBrowser::update(float deltaTime)
s_app->drawText(bla,10,10); s_app->drawText(bla,10,10);
} }
if (gPngFileName)
{
static int skip = 0;
skip--;
if (skip<0)
{
skip=gPngSkipFrames;
//printf("gPngFileName=%s\n",gPngFileName);
static int s_frameCount = 100;
sprintf(staticPngFileName,"%s%d.png",gPngFileName,s_frameCount++);
//b3Printf("Made screenshot %s",staticPngFileName);
s_app->dumpNextFrameToPng(staticPngFileName);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
}
if (sCurrentDemo) if (sCurrentDemo)
{ {
@@ -998,24 +1129,6 @@ void OpenGLExampleBrowser::update(float deltaTime)
//printf("---------------------------------------------------\n"); //printf("---------------------------------------------------\n");
//printf("Framecount = %d\n",frameCount); //printf("Framecount = %d\n",frameCount);
if (gPngFileName)
{
static int skip = 0;
skip++;
if (skip>4)
{
skip=0;
//printf("gPngFileName=%s\n",gPngFileName);
static int s_frameCount = 100;
sprintf(staticPngFileName,"%s%d.png",gPngFileName,s_frameCount++);
//b3Printf("Made screenshot %s",staticPngFileName);
s_app->dumpNextFrameToPng(staticPngFileName);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
}
if (gFixedTimeStep>0) if (gFixedTimeStep>0)
{ {
@@ -1026,6 +1139,14 @@ void OpenGLExampleBrowser::update(float deltaTime)
} }
} }
if (renderGrid)
{
BT_PROFILE("Draw Grid");
glPolygonOffset(3.0, 3);
glEnable(GL_POLYGON_OFFSET_FILL);
s_app->drawGrid(dg);
}
if (renderVisualGeometry && ((gDebugDrawFlags&btIDebugDraw::DBG_DrawWireframe)==0)) if (renderVisualGeometry && ((gDebugDrawFlags&btIDebugDraw::DBG_DrawWireframe)==0))
{ {
if (visualWireframe) if (visualWireframe)
@@ -1042,9 +1163,11 @@ void OpenGLExampleBrowser::update(float deltaTime)
} }
} }
{ {
if (s_guiHelper && s_guiHelper->getRenderInterface() && s_guiHelper->getRenderInterface()->getActiveCamera()) if (gui2 && s_guiHelper && s_guiHelper->getRenderInterface() && s_guiHelper->getRenderInterface()->getActiveCamera())
{ {
char msg[1024]; char msg[1024];
float camDist = s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraDistance(); float camDist = s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraDistance();
@@ -1053,7 +1176,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
float camTarget[3]; float camTarget[3];
s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraTargetPosition(camTarget); s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraTargetPosition(camTarget);
sprintf(msg,"dist=%f, pitch=%f, yaw=%f,target=%f,%f,%f", camDist,pitch,yaw,camTarget[0],camTarget[1],camTarget[2]); sprintf(msg,"dist=%f, pitch=%f, yaw=%f,target=%f,%f,%f", camDist,pitch,yaw,camTarget[0],camTarget[1],camTarget[2]);
gui->setStatusBarMessage(msg, true); gui2->setStatusBarMessage(msg, true);
} }
} }
@@ -1061,16 +1184,24 @@ void OpenGLExampleBrowser::update(float deltaTime)
static int toggle = 1; static int toggle = 1;
if (renderGui) if (renderGui)
{ {
if (!pauseSimulation) // if (!pauseSimulation)
processProfileData(s_profWindow,false); // processProfileData(s_profWindow,false);
if (sUseOpenGL2) if (sUseOpenGL2)
{ {
saveOpenGLState(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight()); saveOpenGLState(s_instancingRenderer->getScreenWidth(), s_instancingRenderer->getScreenHeight());
} }
BT_PROFILE("Draw Gwen GUI"); BT_PROFILE("Draw Gwen GUI");
gui->draw(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight()); if (m_internalData->m_gui)
{
m_internalData->m_gui->draw(s_instancingRenderer->getScreenWidth(), s_instancingRenderer->getScreenHeight());
}
if (gui2)
{
gui2->draw(s_instancingRenderer->getScreenWidth(), s_instancingRenderer->getScreenHeight());
}
if (sUseOpenGL2) if (sUseOpenGL2)
{ {
restoreOpenGLState(); restoreOpenGLState();
@@ -1084,18 +1215,25 @@ void OpenGLExampleBrowser::update(float deltaTime)
toggle=1-toggle; toggle=1-toggle;
{ {
BT_PROFILE("Sync Parameters"); BT_PROFILE("Sync Parameters");
s_parameterInterface->syncParameters(); if (s_parameterInterface)
{
s_parameterInterface->syncParameters();
}
} }
{ {
BT_PROFILE("Swap Buffers"); BT_PROFILE("Swap Buffers");
s_app->swapBuffer(); s_app->swapBuffer();
} }
gui->forceUpdateScrollBars(); if (gui2)
{
gui2->forceUpdateScrollBars();
}
} }
void OpenGLExampleBrowser::setSharedMemoryInterface(class SharedMemoryInterface* sharedMem) void OpenGLExampleBrowser::setSharedMemoryInterface(class SharedMemoryInterface* sharedMem)
{ {
gDisableDemoSelection = true;
sSharedMem = sharedMem; sSharedMem = sharedMem;
} }

View File

@@ -5,6 +5,9 @@
class OpenGLExampleBrowser : public ExampleBrowserInterface class OpenGLExampleBrowser : public ExampleBrowserInterface
{ {
struct OpenGLExampleBrowserInternalData* m_internalData;
public: public:
OpenGLExampleBrowser(class ExampleEntries* examples); OpenGLExampleBrowser(class ExampleEntries* examples);

View File

@@ -8,7 +8,7 @@
#include "CollisionShape2TriangleMesh.h" #include "CollisionShape2TriangleMesh.h"
#include "../OpenGLWindow/SimpleCamera.h"
#include "../OpenGLWindow/GLInstanceGraphicsShape.h" #include "../OpenGLWindow/GLInstanceGraphicsShape.h"
//backwards compatibility //backwards compatibility
#include "GL_ShapeDrawer.h" #include "GL_ShapeDrawer.h"
@@ -144,8 +144,8 @@ struct OpenGLGuiHelperInternalData
class MyDebugDrawer* m_debugDraw; class MyDebugDrawer* m_debugDraw;
GL_ShapeDrawer* m_gl2ShapeDrawer; GL_ShapeDrawer* m_gl2ShapeDrawer;
btAlignedObjectArray<unsigned char> m_rgbaPixelBuffer; btAlignedObjectArray<unsigned char> m_rgbaPixelBuffer1;
btAlignedObjectArray<float> m_depthBuffer; btAlignedObjectArray<float> m_depthBuffer1;
}; };
@@ -167,6 +167,7 @@ OpenGLGuiHelper::OpenGLGuiHelper(CommonGraphicsApp* glApp, bool useOpenGL2)
OpenGLGuiHelper::~OpenGLGuiHelper() OpenGLGuiHelper::~OpenGLGuiHelper()
{ {
delete m_data->m_debugDraw;
delete m_data->m_gl2ShapeDrawer; delete m_data->m_gl2ShapeDrawer;
delete m_data; delete m_data;
} }
@@ -199,9 +200,16 @@ void OpenGLGuiHelper::createCollisionObjectGraphicsObject(btCollisionObject* bod
} }
} }
int OpenGLGuiHelper::registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices) int OpenGLGuiHelper::registerTexture(const unsigned char* texels, int width, int height)
{ {
int shapeId = m_data->m_glApp->m_renderer->registerShape(vertices, numvertices,indices,numIndices); int textureId = m_data->m_glApp->m_renderer->registerTexture(texels,width,height);
return textureId;
}
int OpenGLGuiHelper::registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId)
{
int shapeId = m_data->m_glApp->m_renderer->registerShape(vertices, numvertices,indices,numIndices,primitiveType, textureId);
return shapeId; return shapeId;
} }
@@ -210,6 +218,10 @@ int OpenGLGuiHelper::registerGraphicsInstance(int shapeIndex, const float* posit
return m_data->m_glApp->m_renderer->registerGraphicsInstance(shapeIndex,position,quaternion,color,scaling); return m_data->m_glApp->m_renderer->registerGraphicsInstance(shapeIndex,position,quaternion,color,scaling);
} }
void OpenGLGuiHelper::removeAllGraphicsInstances()
{
m_data->m_glApp->m_renderer->removeAllInstances();
}
void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* collisionShape) void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)
{ {
@@ -247,7 +259,7 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli
if (gfxVertices.size() && indices.size()) if (gfxVertices.size() && indices.size())
{ {
int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0],gfxVertices.size(),&indices[0],indices.size()); int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0],gfxVertices.size(),&indices[0],indices.size(),B3_GL_TRIANGLES,-1);
collisionShape->setUserIndex(shapeId); collisionShape->setUserIndex(shapeId);
} }
@@ -326,19 +338,20 @@ void OpenGLGuiHelper::resetCamera(float camDist, float pitch, float yaw, float c
} }
void OpenGLGuiHelper::copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels, int startPixelIndex, int* widthPtr, int* heightPtr, int* numPixelsCopied) void OpenGLGuiHelper::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int destinationWidth,
int destinationHeight, int* numPixelsCopied)
{ {
int w = m_data->m_glApp->m_window->getWidth()*m_data->m_glApp->m_window->getRetinaScale(); int sourceWidth = m_data->m_glApp->m_window->getWidth()*m_data->m_glApp->m_window->getRetinaScale();
int h = m_data->m_glApp->m_window->getHeight()*m_data->m_glApp->m_window->getRetinaScale(); int sourceHeight = m_data->m_glApp->m_window->getHeight()*m_data->m_glApp->m_window->getRetinaScale();
if (widthPtr)
*widthPtr = w;
if (heightPtr)
*heightPtr = h;
if (numPixelsCopied) if (numPixelsCopied)
*numPixelsCopied = 0; *numPixelsCopied = 0;
int numTotalPixels = w*h; int numTotalPixels = destinationWidth*destinationHeight;
int numRemainingPixels = numTotalPixels - startPixelIndex; int numRemainingPixels = numTotalPixels - startPixelIndex;
int numBytesPerPixel = 4;//RGBA int numBytesPerPixel = 4;//RGBA
int numRequestedPixels = btMin(rgbaBufferSizeInPixels,numRemainingPixels); int numRequestedPixels = btMin(rgbaBufferSizeInPixels,numRemainingPixels);
@@ -346,22 +359,58 @@ void OpenGLGuiHelper::copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBuf
{ {
if (startPixelIndex==0) if (startPixelIndex==0)
{ {
CommonCameraInterface* oldCam = getRenderInterface()->getActiveCamera();
//quick test: render the scene SimpleCamera tempCam;
getRenderInterface()->setActiveCamera(&tempCam);
getRenderInterface()->getActiveCamera()->setVRCamera(viewMatrix,projectionMatrix);
getRenderInterface()->renderScene(); getRenderInterface()->renderScene();
//copy the image into our local cache getRenderInterface()->setActiveCamera(oldCam);
m_data->m_rgbaPixelBuffer.resize(w*h*numBytesPerPixel);
m_data->m_depthBuffer.resize(w*h); {
m_data->m_glApp->getScreenPixels(&(m_data->m_rgbaPixelBuffer[0]),m_data->m_rgbaPixelBuffer.size()); btAlignedObjectArray<unsigned char> sourceRgbaPixelBuffer;
} btAlignedObjectArray<float> sourceDepthBuffer;
for (int i=0;i<numRequestedPixels*numBytesPerPixel;i++) //copy the image into our local cache
{ sourceRgbaPixelBuffer.resize(sourceWidth*sourceHeight*numBytesPerPixel);
if (pixelsRGBA) sourceDepthBuffer.resize(sourceWidth*sourceHeight);
{ m_data->m_glApp->getScreenPixels(&(sourceRgbaPixelBuffer[0]),sourceRgbaPixelBuffer.size(), &sourceDepthBuffer[0],sizeof(float)*sourceDepthBuffer.size());
pixelsRGBA[i] = m_data->m_rgbaPixelBuffer[i+startPixelIndex*numBytesPerPixel];
m_data->m_rgbaPixelBuffer1.resize(destinationWidth*destinationHeight*numBytesPerPixel);
m_data->m_depthBuffer1.resize(destinationWidth*destinationHeight);
//rescale and flip
for (int i=0;i<destinationWidth;i++)
{
for (int j=0;j<destinationHeight;j++)
{
int xIndex = int(float(i)*(float(sourceWidth)/float(destinationWidth)));
int yIndex = int(float(destinationHeight-1-j)*(float(sourceHeight)/float(destinationHeight)));
btClamp(xIndex,0,sourceWidth);
btClamp(yIndex,0,sourceHeight);
int bytesPerPixel = 4; //RGBA
int sourcePixelIndex = (xIndex+yIndex*sourceWidth)*bytesPerPixel;
m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+0] = sourceRgbaPixelBuffer[sourcePixelIndex+0];
m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+1] = sourceRgbaPixelBuffer[sourcePixelIndex+1];
m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+2] = sourceRgbaPixelBuffer[sourcePixelIndex+2];
m_data->m_rgbaPixelBuffer1[(i+j*destinationWidth)*4+3] = 255;
}
}
}
}
if (pixelsRGBA)
{
for (int i=0;i<numRequestedPixels*numBytesPerPixel;i++)
{
pixelsRGBA[i] = m_data->m_rgbaPixelBuffer1[i+startPixelIndex*numBytesPerPixel];
}
}
if (depthBuffer)
{
for (int i=0;i<numRequestedPixels;i++)
{
depthBuffer[i] = m_data->m_depthBuffer1[i];
} }
} }
if (numPixelsCopied) if (numPixelsCopied)
*numPixelsCopied = numRequestedPixels; *numPixelsCopied = numRequestedPixels;

View File

@@ -20,12 +20,11 @@ struct OpenGLGuiHelper : public GUIHelperInterface
virtual void createCollisionObjectGraphicsObject(btCollisionObject* body, const btVector3& color); virtual void createCollisionObjectGraphicsObject(btCollisionObject* body, const btVector3& color);
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices); virtual int registerTexture(const unsigned char* texels, int width, int height);
virtual int registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType, int textureId);
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling); virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
virtual void removeAllGraphicsInstances();
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape); virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape);
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld); virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
@@ -45,7 +44,12 @@ struct OpenGLGuiHelper : public GUIHelperInterface
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ); virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ);
virtual void copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels, int startPixelIndex, int* width, int* height, int* numPixelsCopied); virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
float* depthBuffer, int depthBufferSizeInPixels,
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int destinationWidth,
int destinationHeight, int* numPixelsCopied);
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ; virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ;

View File

@@ -1,4 +1,5 @@
#include "OpenGLExampleBrowser.h" #include "OpenGLExampleBrowser.h"
#include "Bullet3Common/b3CommandLineArgs.h" #include "Bullet3Common/b3CommandLineArgs.h"
@@ -14,38 +15,45 @@
#include "../Importers/ImportURDFDemo/ImportURDFSetup.h" #include "../Importers/ImportURDFDemo/ImportURDFSetup.h"
#include "../Importers/ImportSDFDemo/ImportSDFSetup.h" #include "../Importers/ImportSDFDemo/ImportSDFSetup.h"
#include "../Importers/ImportSTLDemo/ImportSTLSetup.h" #include "../Importers/ImportSTLDemo/ImportSTLSetup.h"
#include "LinearMath/btAlignedAllocator.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
b3CommandLineArgs args(argc,argv);
b3Clock clock;
ExampleEntriesAll examples;
examples.initExampleEntries();
OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples);
bool init = exampleBrowser->init(argc,argv);
exampleBrowser->registerFileImporter(".urdf",ImportURDFCreateFunc);
exampleBrowser->registerFileImporter(".sdf",ImportSDFCreateFunc);
exampleBrowser->registerFileImporter(".obj",ImportObjCreateFunc);
exampleBrowser->registerFileImporter(".stl",ImportSTLCreateFunc);
clock.reset();
if (init)
{ {
do b3CommandLineArgs args(argc, argv);
{ b3Clock clock;
float deltaTimeInSeconds = clock.getTimeMicroseconds()/1000000.f;
clock.reset();
exampleBrowser->update(deltaTimeInSeconds); ExampleEntriesAll examples;
examples.initExampleEntries();
OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples);
bool init = exampleBrowser->init(argc, argv);
exampleBrowser->registerFileImporter(".urdf", ImportURDFCreateFunc);
exampleBrowser->registerFileImporter(".sdf", ImportSDFCreateFunc);
exampleBrowser->registerFileImporter(".obj", ImportObjCreateFunc);
exampleBrowser->registerFileImporter(".stl", ImportSTLCreateFunc);
clock.reset();
if (init)
{
do
{
float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f;
clock.reset();
exampleBrowser->update(deltaTimeInSeconds);
} while (!exampleBrowser->requestedExit());
}
delete exampleBrowser;
} while (!exampleBrowser->requestedExit());
} }
delete exampleBrowser;
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
int numBytesLeaked = btDumpMemoryLeaks();
btAssert(numBytesLeaked==0);
#endif//BT_DEBUG_MEMORY_ALLOCATIONS
return 0; return 0;
} }

View File

@@ -45,9 +45,10 @@ project "App_BulletExampleBrowser"
defines {"INCLUDE_CLOTH_DEMOS"} defines {"INCLUDE_CLOTH_DEMOS"}
files { files {
"main.cpp", "main.cpp",
"ExampleEntries.cpp", "ExampleEntries.cpp",
"../InverseKinematics/*",
"../TinyRenderer/geometry.cpp", "../TinyRenderer/geometry.cpp",
"../TinyRenderer/model.cpp", "../TinyRenderer/model.cpp",
"../TinyRenderer/tgaimage.cpp", "../TinyRenderer/tgaimage.cpp",
@@ -86,14 +87,9 @@ project "App_BulletExampleBrowser"
"../InverseDynamics/InverseDynamicsExample.h", "../InverseDynamics/InverseDynamicsExample.h",
"../BasicDemo/BasicExample.*", "../BasicDemo/BasicExample.*",
"../Tutorial/*", "../Tutorial/*",
"../ExtendedTutorials/SimpleBox.cpp", "../ExtendedTutorials/*",
"../ExtendedTutorials/MultipleBoxes.cpp",
"../ExtendedTutorials/SimpleJoint.cpp",
"../ExtendedTutorials/SimpleCloth.cpp",
"../ExtendedTutorials/Chain.cpp",
"../ExtendedTutorials/Bridge.cpp",
"../ExtendedTutorials/RigidBodyFromObj.cpp",
"../Collision/*", "../Collision/*",
"../RoboticsLearning/*",
"../Collision/Internal/*", "../Collision/Internal/*",
"../Benchmarks/*", "../Benchmarks/*",
"../CommonInterfaces/*", "../CommonInterfaces/*",
@@ -121,6 +117,7 @@ project "App_BulletExampleBrowser"
"../ThirdPartyLibs/stb_image/*", "../ThirdPartyLibs/stb_image/*",
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
"../ThirdPartyLibs/tinyxml/*", "../ThirdPartyLibs/tinyxml/*",
"../ThirdPartyLibs/BussIK/*",
"../GyroscopicDemo/GyroscopicSetup.cpp", "../GyroscopicDemo/GyroscopicSetup.cpp",
"../GyroscopicDemo/GyroscopicSetup.h", "../GyroscopicDemo/GyroscopicSetup.h",
"../ThirdPartyLibs/tinyxml/tinystr.cpp", "../ThirdPartyLibs/tinyxml/tinystr.cpp",

View File

@@ -0,0 +1,372 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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 "InclinedPlane.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
static btScalar gTilt = 20.0f/180.0f*SIMD_PI; // tilt the ramp 20 degrees
static btScalar gRampFriction = 1; // set ramp friction to 1
static btScalar gRampRestitution = 0; // set ramp restitution to 0 (no restitution)
static btScalar gBoxFriction = 1; // set box friction to 1
static btScalar gBoxRestitution = 0; // set box restitution to 0
static btScalar gSphereFriction = 1; // set sphere friction to 1
static btScalar gSphereRollingFriction = 1; // set sphere rolling friction to 1
static btScalar gSphereRestitution = 0; // set sphere restitution to 0
// handles for changes
static btRigidBody* ramp = NULL;
static btRigidBody* gBox = NULL;
static btRigidBody* gSphere = NULL;
struct InclinedPlaneExample : public CommonRigidBodyBase
{
InclinedPlaneExample(struct GUIHelperInterface* helper)
:CommonRigidBodyBase(helper)
{
}
virtual ~InclinedPlaneExample(){}
virtual void initPhysics();
virtual void resetScene();
virtual void renderScene();
virtual void stepSimulation(float deltaTime);
virtual bool keyboardCallback(int key, int state);
void resetCamera()
{
float dist = 41;
float pitch = 52;
float yaw = 35;
float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
}
};
void onBoxFrictionChanged(float friction);
void onBoxRestitutionChanged(float restitution);
void onSphereFrictionChanged(float friction);
void onSphereRestitutionChanged(float restitution);
void onRampInclinationChanged(float inclination);
void onRampFrictionChanged(float friction);
void onRampRestitutionChanged(float restitution);
void InclinedPlaneExample::initPhysics()
{
{ // create slider to change the ramp tilt
SliderParams slider("Ramp Tilt",&gTilt);
slider.m_minVal=0;
slider.m_maxVal=SIMD_PI/2.0f;
slider.m_clampToNotches = false;
slider.m_callback = onRampInclinationChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp friction
SliderParams slider("Ramp Friction",&gRampFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onRampFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the ramp restitution
SliderParams slider("Ramp Restitution",&gRampRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
slider.m_callback = onRampRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box friction
SliderParams slider("Box Friction",&gBoxFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onBoxFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the box restitution
SliderParams slider("Box Restitution",&gBoxRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
slider.m_callback = onBoxRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere friction
SliderParams slider("Sphere Friction",&gSphereFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereFrictionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere rolling friction
SliderParams slider("Sphere Rolling Friction",&gSphereRollingFriction);
slider.m_minVal=0;
slider.m_maxVal=10;
slider.m_clampToNotches = false;
slider.m_callback = onSphereRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
{ // create slider to change the sphere restitution
SliderParams slider("Sphere Restitution",&gSphereRestitution);
slider.m_minVal=0;
slider.m_maxVal=1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
m_guiHelper->setUpAxis(1); // set Y axis as up axis
createEmptyDynamicsWorld();
// create debug drawer
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
if (m_dynamicsWorld->getDebugDrawer())
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawContactPoints);
{ // create a static ground
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));
btScalar mass(0.);
createRigidBody(mass,groundTransform,groundShape, btVector4(0,0,1,1));
}
{ //create a static inclined plane
btBoxShape* inclinedPlaneShape = createBoxShape(btVector3(btScalar(20.),btScalar(1.),btScalar(10.)));
m_collisionShapes.push_back(inclinedPlaneShape);
btTransform startTransform;
startTransform.setIdentity();
// position the inclined plane above ground
startTransform.setOrigin(btVector3(
btScalar(0),
btScalar(15),
btScalar(0)));
btQuaternion incline;
incline.setRotation(btVector3(0,0,1),gTilt);
startTransform.setRotation(incline);
btScalar mass(0.);
ramp = createRigidBody(mass,startTransform,inclinedPlaneShape);
ramp->setFriction(gRampFriction);
ramp->setRestitution(gRampRestitution);
}
{ //create a cube above the inclined plane
btBoxShape* boxShape = createBoxShape(btVector3(1,1,1));
m_collisionShapes.push_back(boxShape);
btTransform startTransform;
startTransform.setIdentity();
btScalar boxMass(1.f);
startTransform.setOrigin(
btVector3(btScalar(0), btScalar(20), btScalar(2)));
gBox = createRigidBody(boxMass, startTransform, boxShape);
gBox->forceActivationState(DISABLE_DEACTIVATION); // to prevent the box on the ramp from disabling
gBox->setFriction(gBoxFriction);
gBox->setRestitution(gBoxRestitution);
}
{ //create a sphere above the inclined plane
btSphereShape* sphereShape = new btSphereShape(btScalar(1));
m_collisionShapes.push_back(sphereShape);
btTransform startTransform;
startTransform.setIdentity();
btScalar sphereMass(1.f);
startTransform.setOrigin(
btVector3(btScalar(0), btScalar(20), btScalar(4)));
gSphere = createRigidBody(sphereMass, startTransform, sphereShape);
gSphere->forceActivationState(DISABLE_DEACTIVATION); // to prevent the sphere on the ramp from disabling
gSphere->setFriction(gSphereFriction);
gSphere->setRestitution(gSphereRestitution);
gSphere->setRollingFriction(gSphereRollingFriction);
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void InclinedPlaneExample::resetScene() {
{ //reset a cube above the inclined plane
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(
btVector3(btScalar(0), btScalar(20), btScalar(2)));
gBox->setWorldTransform(startTransform);
btVector3 zero(0, 0, 0);
gBox->setAngularVelocity(zero);
gBox->setLinearVelocity(zero);
gBox->clearForces();
}
{ //reset a sphere above the inclined plane
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(
btVector3(btScalar(0), btScalar(20), btScalar(4)));
gSphere->setWorldTransform(startTransform);
btVector3 zero(0, 0, 0);
gSphere->setAngularVelocity(zero);
gSphere->setLinearVelocity(zero);
gSphere->clearForces();
}
}
void InclinedPlaneExample::stepSimulation(float deltaTime)
{
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(deltaTime);
}
}
void InclinedPlaneExample::renderScene()
{
CommonRigidBodyBase::renderScene();
}
bool InclinedPlaneExample::keyboardCallback(int key, int state) {
// b3Printf("Key pressed: %d in state %d \n",key,state);
switch (key) {
case 32 /*ASCII for space*/: {
resetScene();
break;
}
}
return false;
}
// GUI parameter modifiers
void onBoxFrictionChanged(float friction){
if(gBox){
gBox->setFriction(friction);
// b3Printf("Friction of box changed to %f",friction );
}
}
void onBoxRestitutionChanged(float restitution){
if(gBox){
gBox->setRestitution(restitution);
//b3Printf("Restitution of box changed to %f",restitution);
}
}
void onSphereFrictionChanged(float friction){
if(gSphere){
gSphere->setFriction(friction);
//b3Printf("Friction of sphere changed to %f",friction );
}
}
void onSphereRestitutionChanged(float restitution){
if(gSphere){
gSphere->setRestitution(restitution);
//b3Printf("Restitution of sphere changed to %f",restitution);
}
}
void onRampInclinationChanged(float inclination){
if(ramp){
btTransform startTransform;
startTransform.setIdentity();
// position the inclined plane above ground
startTransform.setOrigin(
btVector3(btScalar(0), btScalar(15), btScalar(0)));
btQuaternion incline;
incline.setRotation(btVector3(0,0,1),gTilt);
startTransform.setRotation(incline);
ramp->setWorldTransform(startTransform);
//b3Printf("Inclination of ramp changed to %f",inclination );
}
}
void onRampFrictionChanged(float friction){
if(ramp){
ramp->setFriction(friction);
//b3Printf("Friction of ramp changed to %f \n",friction );
}
}
void onRampRestitutionChanged(float restitution){
if(ramp){
ramp->setRestitution(restitution);
//b3Printf("Restitution of ramp changed to %f \n",restitution);
}
}
CommonExampleInterface* ET_InclinedPlaneCreateFunc(CommonExampleOptions& options)
{
return new InclinedPlaneExample(options.m_guiHelper);
}

View File

@@ -0,0 +1,22 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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.
*/
#ifndef ET_INCLINED_PLANE_EXAMPLE_H
#define ET_INCLINED_PLANE_EXAMPLE_H
class CommonExampleInterface* ET_InclinedPlaneCreateFunc(struct CommonExampleOptions& options);
#endif //ET_INCLINED_PLANE_EXAMPLE_H

View File

@@ -0,0 +1,435 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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 "MultiPendulum.h"
#include <vector> // TODO: Should I use another data structure?
#include <iterator>
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
static btScalar gPendulaQty = 2; //TODO: This would actually be an Integer, but the Slider does not like integers, so I floor it when changed
static btScalar gDisplacedPendula = 1; //TODO: This is an int as well
static btScalar gPendulaRestitution = 1; // Default pendulum restitution is 1 to restore all force
static btScalar gSphereRadius = 1; // The sphere radius
static btScalar gCurrentPendulumLength = 8;
static btScalar gInitialPendulumLength = 8; // Default pendulum length (distance between two spheres)
static btScalar gDisplacementForce = 30; // The default force with which we move the pendulum
static btScalar gForceScalar = 0; // default force scalar to apply a displacement
struct MultiPendulumExample: public CommonRigidBodyBase {
MultiPendulumExample(struct GUIHelperInterface* helper) :
CommonRigidBodyBase(helper) {
}
virtual ~MultiPendulumExample() {
}
virtual void initPhysics(); // build a multi pendulum
virtual void renderScene(); // render the scene to screen
virtual void createMultiPendulum(btSphereShape* colShape, btScalar pendulaQty, const btVector3& position, btScalar length, btScalar mass); // create a multi pendulum at the indicated x and y position, the specified number of pendula formed into a chain, each with indicated length and mass
virtual void changePendulaLength(btScalar length); // change the pendulum length
virtual void changePendulaRestitution(btScalar restitution); // change the pendula restitution
virtual void stepSimulation(float deltaTime); // step the simulation
virtual bool keyboardCallback(int key, int state); // handle keyboard callbacks
virtual void applyPendulumForce(btScalar pendulumForce);
void resetCamera() {
float dist = 41;
float pitch = 52;
float yaw = 35;
float targetPos[3] = { 0, 0.46, 0 };
m_guiHelper->resetCamera(dist, pitch, yaw, targetPos[0], targetPos[1],
targetPos[2]);
}
std::vector<btSliderConstraint*> constraints; // keep a handle to the slider constraints
std::vector<btRigidBody*> pendula; // keep a handle to the pendula
};
static MultiPendulumExample* mex = NULL; // Handle to the example to access it via functions. Do not use this in your simulation!
void onMultiPendulaLengthChanged(float pendulaLength); // Change the pendula length
void onMultiPendulaRestitutionChanged(float pendulaRestitution); // change the pendula restitution
void floorMSliderValue(float notUsed); // floor the slider values which should be integers
void applyMForceWithForceScalar(float forceScalar);
void MultiPendulumExample::initPhysics() { // Setup your physics scene
{ // create a slider to change the number of pendula
SliderParams slider("Number of Pendula", &gPendulaQty);
slider.m_minVal = 1;
slider.m_maxVal = 50;
slider.m_callback = floorMSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the number of displaced pendula
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
slider.m_minVal = 0;
slider.m_maxVal = 49;
slider.m_callback = floorMSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendula restitution
SliderParams slider("Pendula Restitution", &gPendulaRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
slider.m_callback = onMultiPendulaRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendulum length
SliderParams slider("Pendula Length", &gCurrentPendulumLength);
slider.m_minVal = 0;
slider.m_maxVal = 49;
slider.m_clampToNotches = false;
slider.m_callback = onMultiPendulaLengthChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the force to displace the lowest pendulum
SliderParams slider("Displacement force", &gDisplacementForce);
slider.m_minVal = 0.1;
slider.m_maxVal = 200;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to apply the force by slider
SliderParams slider("Apply displacement force", &gForceScalar);
slider.m_minVal = -1;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
m_guiHelper->setUpAxis(1);
createEmptyDynamicsWorld();
// create a debug drawer
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
if (m_dynamicsWorld->getDebugDrawer())
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
btIDebugDraw::DBG_DrawWireframe
+ btIDebugDraw::DBG_DrawContactPoints
+ btIDebugDraw::DBG_DrawConstraints
+ btIDebugDraw::DBG_DrawConstraintLimits);
{ // create the multipendulum starting at the indicated position below and where each pendulum has the following mass
btScalar pendulumMass(1.f);
btVector3 position(0.0f,15.0f,0.0f); // initial top-most pendulum position
// Re-using the same collision is better for memory usage and performance
btSphereShape* pendulumShape = new btSphereShape(gSphereRadius);
m_collisionShapes.push_back(pendulumShape);
// create multi-pendulum
createMultiPendulum(pendulumShape, floor(gPendulaQty), position,
gInitialPendulumLength, pendulumMass);
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void MultiPendulumExample::stepSimulation(float deltaTime) {
applyMForceWithForceScalar(gForceScalar); // apply force defined by apply force slider
if (m_dynamicsWorld) {
m_dynamicsWorld->stepSimulation(deltaTime);
}
}
void MultiPendulumExample::createMultiPendulum(btSphereShape* colShape,
btScalar pendulaQty, const btVector3& position,
btScalar length, btScalar mass) {
// The multi-pendulum looks like this (names when built):
//..........0......./.......1...../.......2......./..etc...:pendulum build iterations
// O parentSphere
// |
// O childSphere / parentSphere
// |
// O ............./ childSphere / parentSphere
// |
// O .........................../ childSphere
// etc.
//create the top element of the pendulum
btTransform startTransform;
startTransform.setIdentity();
// position the top sphere
startTransform.setOrigin(position);
startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation
btRigidBody* topSphere = createRigidBody(mass, startTransform, colShape);
// disable the deactivation when object does not move anymore
topSphere->setActivationState(DISABLE_DEACTIVATION);
//make top sphere position "fixed" in the world by attaching it to a the world with a point to point constraint
// The pivot is defined in the reference frame of topSphere, so the attachment should be exactly at the center of topSphere
btVector3 constraintPivot(0.0f, 0.0f, 0.0f);
btPoint2PointConstraint* p2pconst = new btPoint2PointConstraint(
*topSphere, constraintPivot);
p2pconst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing
// add the constraint to the world
m_dynamicsWorld->addConstraint(p2pconst, true);
btRigidBody* parentSphere = topSphere; // set the top sphere as the parent sphere for the next sphere to be created
for (int i = 0; i < pendulaQty; i++) { // produce the number of pendula
// create joint element to make the pendulum rotate it
// position the joint sphere at the same position as the top sphere
startTransform.setOrigin(position - btVector3(0,length*(i),0));
startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation
btRigidBody* jointSphere = createRigidBody(mass, startTransform,
colShape);
jointSphere->setFriction(0); // we do not need friction here
// disable the deactivation when object does not move anymore
jointSphere->setActivationState(DISABLE_DEACTIVATION);
//create constraint between parentSphere and jointSphere
// this is represented by the constraint pivot in the local frames of reference of both constrained spheres
btTransform constraintPivotInParentSphereRF, constraintPivotInJointSphereRF;
constraintPivotInParentSphereRF.setIdentity();
constraintPivotInJointSphereRF.setIdentity();
// the orientation of a point-to-point constraint does not matter, as is has no rotational limits
//Obtain the position of parentSphere in local reference frame of the jointSphere (the pivot is therefore in the center of parentSphere)
btVector3 parentSphereInJointSphereRF =
(jointSphere->getWorldTransform().inverse()(
parentSphere->getWorldTransform().getOrigin()));
constraintPivotInJointSphereRF.setOrigin(parentSphereInJointSphereRF);
btPoint2PointConstraint* p2pconst = new btPoint2PointConstraint(
*parentSphere,*jointSphere,constraintPivotInParentSphereRF.getOrigin(), constraintPivotInJointSphereRF.getOrigin());
p2pconst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing
// add the constraint to the world
m_dynamicsWorld->addConstraint(p2pconst, true);
// create a slider constraint to change the length of the pendula while it swings
startTransform.setIdentity(); // reset start transform
// position the child sphere below the joint sphere
startTransform.setOrigin(position - btVector3(0,length*(i+1),0));
startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation
btRigidBody* childSphere = createRigidBody(mass, startTransform,
colShape);
childSphere->setFriction(0); // we do not need friction here
pendula.push_back(childSphere);
// disable the deactivation when object does not move anymore
childSphere->setActivationState(DISABLE_DEACTIVATION);
//create slider constraint between jointSphere and childSphere
// this is represented by the constraint pivot in the local frames of reference of both constrained spheres
// furthermore we need to rotate the constraint appropriately to orient it correctly in space
btTransform constraintPivotInChildSphereRF;
constraintPivotInJointSphereRF.setIdentity();
constraintPivotInChildSphereRF.setIdentity();
// the orientation of a point-to-point constraint does not matter, as is has no rotational limits
//Obtain the position of jointSphere in local reference frame of the childSphere (the pivot is therefore in the center of jointSphere)
btVector3 jointSphereInChildSphereRF =
(childSphere->getWorldTransform().inverse()(
jointSphere->getWorldTransform().getOrigin()));
constraintPivotInChildSphereRF.setOrigin(jointSphereInChildSphereRF);
// the slider constraint is x aligned per default, but we want it to be y aligned, therefore we rotate it
btQuaternion qt;
qt.setEuler(0, 0, -SIMD_HALF_PI);
constraintPivotInJointSphereRF.setRotation(qt); //we use Y like up Axis
constraintPivotInChildSphereRF.setRotation(qt); //we use Y like up Axis
btSliderConstraint* sliderConst = new btSliderConstraint(*jointSphere,
*childSphere, constraintPivotInJointSphereRF, constraintPivotInChildSphereRF, true);
sliderConst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing
// set limits
// the initial setup of the constraint defines the origins of the limit dimensions,
// therefore we set both limits directly to the current position of the parentSphere
sliderConst->setLowerLinLimit(btScalar(0));
sliderConst->setUpperLinLimit(btScalar(0));
sliderConst->setLowerAngLimit(btScalar(0));
sliderConst->setUpperAngLimit(btScalar(0));
constraints.push_back(sliderConst);
// add the constraint to the world
m_dynamicsWorld->addConstraint(sliderConst, true);
parentSphere = childSphere;
}
}
void MultiPendulumExample::changePendulaLength(btScalar length) {
btScalar lowerLimit = -gInitialPendulumLength;
for (std::vector<btSliderConstraint*>::iterator sit = constraints.begin();
sit != constraints.end(); sit++) {
btAssert((*sit) && "Null constraint");
// if the pendulum is being shortened beyond it's own length, we don't let the lower sphere to go past the upper one
if (lowerLimit <= length) {
(*sit)->setLowerLinLimit(length + lowerLimit);
(*sit)->setUpperLinLimit(length + lowerLimit);
}
}
}
void MultiPendulumExample::changePendulaRestitution(btScalar restitution) {
for (std::vector<btRigidBody*>::iterator rit = pendula.begin();
rit != pendula.end(); rit++) {
btAssert((*rit) && "Null constraint");
(*rit)->setRestitution(restitution);
}
}
void MultiPendulumExample::renderScene() {
CommonRigidBodyBase::renderScene();
}
bool MultiPendulumExample::keyboardCallback(int key, int state) {
//b3Printf("Key pressed: %d in state %d \n",key,state);
//key 1, key 2, key 3
switch (key) {
case '1' /*ASCII for 1*/: {
//assumption: Sphere are aligned in Z axis
btScalar newLimit = btScalar(gCurrentPendulumLength + 0.1);
changePendulaLength(newLimit);
gCurrentPendulumLength = newLimit;
b3Printf("Increase pendulum length to %f", gCurrentPendulumLength);
return true;
}
case '2' /*ASCII for 2*/: {
//assumption: Sphere are aligned in Z axis
btScalar newLimit = btScalar(gCurrentPendulumLength - 0.1);
//is being shortened beyond it's own length, we don't let the lower sphere to go over the upper one
if (0 <= newLimit) {
changePendulaLength(newLimit);
gCurrentPendulumLength = newLimit;
}
b3Printf("Decrease pendulum length to %f", gCurrentPendulumLength);
return true;
}
case '3' /*ASCII for 3*/: {
applyPendulumForce(gDisplacementForce);
return true;
}
}
return false;
}
void MultiPendulumExample::applyPendulumForce(btScalar pendulumForce){
if(pendulumForce != 0){
b3Printf("Apply %f to pendulum",pendulumForce);
for (int i = 0; i < gDisplacedPendula; i++) {
if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty)
pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0));
}
}
}
// GUI parameter modifiers
void onMultiPendulaLengthChanged(float pendulaLength) { // Change the pendula length
if (mex){
mex->changePendulaLength(pendulaLength);
}
//b3Printf("Pendula length changed to %f \n",sliderValue );
}
void onMultiPendulaRestitutionChanged(float pendulaRestitution) { // change the pendula restitution
if (mex){
mex->changePendulaRestitution(pendulaRestitution);
}
}
void floorMSliderValue(float notUsed) { // floor the slider values which should be integers
gPendulaQty = floor(gPendulaQty);
gDisplacedPendula = floor(gDisplacedPendula);
}
void applyMForceWithForceScalar(float forceScalar) {
if(mex){
btScalar appliedForce = forceScalar * gDisplacementForce;
if(fabs(gForceScalar) < 0.2f)
gForceScalar = 0;
mex->applyPendulumForce(appliedForce);
}
}
CommonExampleInterface* ET_MultiPendulumCreateFunc(
CommonExampleOptions& options) {
mex = new MultiPendulumExample(options.m_guiHelper);
return mex;
}

View File

@@ -0,0 +1,22 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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.
*/
#ifndef ET_MULTI_PENDULUM_EXAMPLE_H
#define ET_MULTI_PENDULUM_EXAMPLE_H
class CommonExampleInterface* ET_MultiPendulumCreateFunc(struct CommonExampleOptions& options);
#endif //ET_MULTI_PENDULUM_EXAMPLE_H

View File

@@ -0,0 +1,380 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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 "NewtonsCradle.h"
#include <vector> // TODO: Should I use another data structure?
#include <iterator>
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
static btScalar gPendulaQty = 5; // Number of pendula in newton's cradle
//TODO: This would actually be an Integer, but the Slider does not like integers, so I floor it when changed
static btScalar gDisplacedPendula = 1; // number of displaced pendula
//TODO: This is an int as well
static btScalar gPendulaRestitution = 1; // pendula restitution when hitting against each other
static btScalar gSphereRadius = 1; // pendula radius
static btScalar gCurrentPendulumLength = 8; // current pendula length
static btScalar gInitialPendulumLength = 8; // default pendula length
static btScalar gDisplacementForce = 30; // default force to displace the pendula
static btScalar gForceScalar = 0; // default force scalar to apply a displacement
struct NewtonsCradleExample: public CommonRigidBodyBase {
NewtonsCradleExample(struct GUIHelperInterface* helper) :
CommonRigidBodyBase(helper) {
}
virtual ~NewtonsCradleExample() {
}
virtual void initPhysics();
virtual void renderScene();
virtual void createPendulum(btSphereShape* colShape, const btVector3& position, btScalar length, btScalar mass);
virtual void changePendulaLength(btScalar length);
virtual void changePendulaRestitution(btScalar restitution);
virtual void stepSimulation(float deltaTime);
virtual bool keyboardCallback(int key, int state);
virtual void applyPendulumForce(btScalar pendulumForce);
void resetCamera() {
float dist = 41;
float pitch = 52;
float yaw = 35;
float targetPos[3] = { 0, 0.46, 0 };
m_guiHelper->resetCamera(dist, pitch, yaw, targetPos[0], targetPos[1],
targetPos[2]);
}
std::vector<btSliderConstraint*> constraints; // keep a handle to the slider constraints
std::vector<btRigidBody*> pendula; // keep a handle to the pendula
};
static NewtonsCradleExample* nex = NULL;
void onPendulaLengthChanged(float pendulaLength); // Change the pendula length
void onPendulaRestitutionChanged(float pendulaRestitution); // change the pendula restitution
void floorSliderValue(float notUsed); // floor the slider values which should be integers
void applyForceWithForceScalar(float forceScalar);
void NewtonsCradleExample::initPhysics() {
{ // create a slider to change the number of pendula
SliderParams slider("Number of Pendula", &gPendulaQty);
slider.m_minVal = 1;
slider.m_maxVal = 50;
slider.m_callback = floorSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the number of displaced pendula
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
slider.m_minVal = 0;
slider.m_maxVal = 49;
slider.m_callback = floorSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendula restitution
SliderParams slider("Pendula Restitution", &gPendulaRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
slider.m_callback = onPendulaRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendulum length
SliderParams slider("Pendula Length", &gCurrentPendulumLength);
slider.m_minVal = 0;
slider.m_maxVal = 49;
slider.m_clampToNotches = false;
slider.m_callback = onPendulaLengthChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the force to displace the lowest pendulum
SliderParams slider("Displacement force", &gDisplacementForce);
slider.m_minVal = 0.1;
slider.m_maxVal = 200;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to apply the force by slider
SliderParams slider("Apply displacement force", &gForceScalar);
slider.m_minVal = -1;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
m_guiHelper->setUpAxis(1);
createEmptyDynamicsWorld();
// create a debug drawer
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
if (m_dynamicsWorld->getDebugDrawer())
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
btIDebugDraw::DBG_DrawWireframe
+ btIDebugDraw::DBG_DrawContactPoints
+ btIDebugDraw::DBG_DrawConstraints
+ btIDebugDraw::DBG_DrawConstraintLimits);
{ // create the pendula starting at the indicated position below and where each pendulum has the following mass
btScalar pendulumMass(1.f);
btVector3 position(0.0f,15.0f,0.0f); // initial left-most pendulum position
btQuaternion orientation(0,0,0,1); // orientation of the pendula
// Re-using the same collision is better for memory usage and performance
btSphereShape* pendulumShape = new btSphereShape(gSphereRadius);
m_collisionShapes.push_back(pendulumShape);
for (int i = 0; i < floor(gPendulaQty); i++) {
// create pendulum
createPendulum(pendulumShape, position, gInitialPendulumLength, pendulumMass);
// displace the pendula 1.05 sphere size, so that they all nearly touch (small spacings in between
position.setX(position.x()-2.1f * gSphereRadius);
}
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void NewtonsCradleExample::stepSimulation(float deltaTime) {
applyForceWithForceScalar(gForceScalar); // apply force defined by apply force slider
if (m_dynamicsWorld) {
m_dynamicsWorld->stepSimulation(deltaTime);
}
}
void NewtonsCradleExample::createPendulum(btSphereShape* colShape, const btVector3& position, btScalar length, btScalar mass) {
// The pendulum looks like this (names when built):
// O topSphere
// |
// O bottomSphere
//create a dynamic pendulum
btTransform startTransform;
startTransform.setIdentity();
// position the top sphere above ground with a moving x position
startTransform.setOrigin(position);
startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation
btRigidBody* topSphere = createRigidBody(mass, startTransform, colShape);
// position the bottom sphere below the top sphere
startTransform.setOrigin(
btVector3(position.x(), btScalar(position.y() - length),
position.z()));
startTransform.setRotation(btQuaternion(0, 0, 0, 1)); // zero rotation
btRigidBody* bottomSphere = createRigidBody(mass, startTransform, colShape);
bottomSphere->setFriction(0); // we do not need friction here
pendula.push_back(bottomSphere);
// disable the deactivation when objects do not move anymore
topSphere->setActivationState(DISABLE_DEACTIVATION);
bottomSphere->setActivationState(DISABLE_DEACTIVATION);
bottomSphere->setRestitution(gPendulaRestitution); // set pendula restitution
//make the top sphere position "fixed" to the world by attaching with a point to point constraint
// The pivot is defined in the reference frame of topSphere, so the attachment is exactly at the center of the topSphere
btVector3 constraintPivot(btVector3(0.0f, 0.0f, 0.0f));
btPoint2PointConstraint* p2pconst = new btPoint2PointConstraint(*topSphere,
constraintPivot);
p2pconst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing
// add the constraint to the world
m_dynamicsWorld->addConstraint(p2pconst, true);
//create constraint between spheres
// this is represented by the constraint pivot in the local frames of reference of both constrained spheres
// furthermore we need to rotate the constraint appropriately to orient it correctly in space
btTransform constraintPivotInTopSphereRF, constraintPivotInBottomSphereRF;
constraintPivotInTopSphereRF.setIdentity();
constraintPivotInBottomSphereRF.setIdentity();
// the slider constraint is x aligned per default, but we want it to be y aligned, therefore we rotate it
btQuaternion qt;
qt.setEuler(0, 0, -SIMD_HALF_PI);
constraintPivotInTopSphereRF.setRotation(qt); //we use Y like up Axis
constraintPivotInBottomSphereRF.setRotation(qt); //we use Y like up Axis
//Obtain the position of topSphere in local reference frame of bottomSphere (the pivot is therefore in the center of topSphere)
btVector3 topSphereInBottomSphereRF =
(bottomSphere->getWorldTransform().inverse()(
topSphere->getWorldTransform().getOrigin()));
constraintPivotInBottomSphereRF.setOrigin(topSphereInBottomSphereRF);
btSliderConstraint* sliderConst = new btSliderConstraint(*topSphere,
*bottomSphere, constraintPivotInTopSphereRF, constraintPivotInBottomSphereRF, true);
sliderConst->setDbgDrawSize(btScalar(5.f)); // set the size of the debug drawing
// set limits
// the initial setup of the constraint defines the origins of the limit dimensions,
// therefore we set both limits directly to the current position of the topSphere
sliderConst->setLowerLinLimit(btScalar(0));
sliderConst->setUpperLinLimit(btScalar(0));
sliderConst->setLowerAngLimit(btScalar(0));
sliderConst->setUpperAngLimit(btScalar(0));
constraints.push_back(sliderConst);
// add the constraint to the world
m_dynamicsWorld->addConstraint(sliderConst, true);
}
void NewtonsCradleExample::changePendulaLength(btScalar length) {
btScalar lowerLimit = -gInitialPendulumLength;
for (std::vector<btSliderConstraint*>::iterator sit = constraints.begin();
sit != constraints.end(); sit++) {
btAssert((*sit) && "Null constraint");
//if the pendulum is being shortened beyond it's own length, we don't let the lower sphere to go past the upper one
if (lowerLimit <= length) {
(*sit)->setLowerLinLimit(length + lowerLimit);
(*sit)->setUpperLinLimit(length + lowerLimit);
}
}
}
void NewtonsCradleExample::changePendulaRestitution(btScalar restitution) {
for (std::vector<btRigidBody*>::iterator rit = pendula.begin();
rit != pendula.end(); rit++) {
btAssert((*rit) && "Null constraint");
(*rit)->setRestitution(restitution);
}
}
void NewtonsCradleExample::renderScene() {
CommonRigidBodyBase::renderScene();
}
bool NewtonsCradleExample::keyboardCallback(int key, int state) {
//b3Printf("Key pressed: %d in state %d \n",key,state);
//key 1, key 2, key 3
switch (key) {
case '1' /*ASCII for 1*/: {
//assumption: Sphere are aligned in Z axis
btScalar newLimit = btScalar(gCurrentPendulumLength + 0.1);
changePendulaLength(newLimit);
gCurrentPendulumLength = newLimit;
b3Printf("Increase pendulum length to %f", gCurrentPendulumLength);
return true;
}
case '2' /*ASCII for 2*/: {
//assumption: Sphere are aligned in Z axis
btScalar newLimit = btScalar(gCurrentPendulumLength - 0.1);
//is being shortened beyond it's own length, we don't let the lower sphere to go over the upper one
if (0 <= newLimit) {
changePendulaLength(newLimit);
gCurrentPendulumLength = newLimit;
}
b3Printf("Decrease pendulum length to %f", gCurrentPendulumLength);
return true;
}
case '3' /*ASCII for 3*/: {
applyPendulumForce(gDisplacementForce);
return true;
}
}
return false;
}
void NewtonsCradleExample::applyPendulumForce(btScalar pendulumForce){
if(pendulumForce != 0){
b3Printf("Apply %f to pendulum",pendulumForce);
for (int i = 0; i < gDisplacedPendula; i++) {
if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty)
pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0));
}
}
}
// GUI parameter modifiers
void onPendulaLengthChanged(float pendulaLength) {
if (nex){
nex->changePendulaLength(pendulaLength);
//b3Printf("Pendula length changed to %f \n",sliderValue );
}
}
void onPendulaRestitutionChanged(float pendulaRestitution) {
if (nex){
nex->changePendulaRestitution(pendulaRestitution);
}
}
void floorSliderValue(float notUsed) {
gPendulaQty = floor(gPendulaQty);
gDisplacedPendula = floor(gDisplacedPendula);
}
void applyForceWithForceScalar(float forceScalar) {
if(nex){
btScalar appliedForce = forceScalar * gDisplacementForce;
if(fabs(gForceScalar) < 0.2f)
gForceScalar = 0;
nex->applyPendulumForce(appliedForce);
}
}
CommonExampleInterface* ET_NewtonsCradleCreateFunc(
CommonExampleOptions& options) {
nex = new NewtonsCradleExample(options.m_guiHelper);
return nex;
}

View File

@@ -0,0 +1,22 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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.
*/
#ifndef ET_NEWTONS_CRADLE_EXAMPLE_H
#define ET_NEWTONS_CRADLE_EXAMPLE_H
class CommonExampleInterface* ET_NewtonsCradleCreateFunc(struct CommonExampleOptions& options);
#endif //ET_NEWTONS_CRADLE_EXAMPLE_H

View File

@@ -0,0 +1,387 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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 "NewtonsRopeCradle.h"
#include <vector> // TODO: Should I use another data structure?
#include <iterator>
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
#include "BulletSoftBody/btSoftBodyHelpers.h"
#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
#include "../CommonInterfaces/CommonParameterInterface.h"
static btScalar gPendulaQty = 5; // Number of pendula in newton's cradle
//TODO: This would actually be an Integer, but the Slider does not like integers, so I floor it when changed
static btScalar gDisplacedPendula = 1; // number of displaced pendula
//TODO: This is an int as well
static btScalar gPendulaRestitution = 1; // pendula restition when hitting against each other
static btScalar gSphereRadius = 1; // pendula radius
static btScalar gInitialPendulumWidth = 4; // default pendula width
static btScalar gInitialPendulumHeight = 8; // default pendula height
static btScalar gRopeResolution = 1; // default rope resolution (number of links as in a chain)
static btScalar gDisplacementForce = 30; // default force to displace the pendula
static btScalar gForceScalar = 0; // default force scalar to apply a displacement
struct NewtonsRopeCradleExample : public CommonRigidBodyBase {
NewtonsRopeCradleExample(struct GUIHelperInterface* helper) :
CommonRigidBodyBase(helper) {
}
virtual ~NewtonsRopeCradleExample(){}
virtual void initPhysics();
virtual void stepSimulation(float deltaTime);
virtual void renderScene();
virtual void applyPendulumForce(btScalar pendulumForce);
void createEmptyDynamicsWorld()
{
m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
m_solver = new btSequentialImpulseConstraintSolver;
m_dynamicsWorld = new btSoftRigidDynamicsWorld(m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration);
m_dynamicsWorld->setGravity(btVector3(0, -10, 0));
softBodyWorldInfo.m_broadphase = m_broadphase;
softBodyWorldInfo.m_dispatcher = m_dispatcher;
softBodyWorldInfo.m_gravity = m_dynamicsWorld->getGravity();
softBodyWorldInfo.m_sparsesdf.Initialize();
}
virtual void createRopePendulum(btSphereShape* colShape,
const btVector3& position, const btQuaternion& pendulumOrientation, btScalar width, btScalar height, btScalar mass);
virtual void changePendulaRestitution(btScalar restitution);
virtual void connectWithRope(btRigidBody* body1, btRigidBody* body2);
virtual bool keyboardCallback(int key, int state);
virtual btSoftRigidDynamicsWorld* getSoftDynamicsWorld()
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btSoftRigidDynamicsWorld*) m_dynamicsWorld;
}
void resetCamera()
{
float dist = 41;
float pitch = 52;
float yaw = 35;
float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
}
std::vector<btSliderConstraint*> constraints;
std::vector<btRigidBody*> pendula;
btSoftBodyWorldInfo softBodyWorldInfo;
};
static NewtonsRopeCradleExample* nex = NULL;
void onRopePendulaRestitutionChanged(float pendulaRestitution);
void floorRSliderValue(float notUsed);
void applyRForceWithForceScalar(float forceScalar);
void NewtonsRopeCradleExample::initPhysics()
{
{ // create a slider to change the number of pendula
SliderParams slider("Number of Pendula", &gPendulaQty);
slider.m_minVal = 1;
slider.m_maxVal = 50;
slider.m_callback = floorRSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the number of displaced pendula
SliderParams slider("Number of Displaced Pendula", &gDisplacedPendula);
slider.m_minVal = 0;
slider.m_maxVal = 49;
slider.m_callback = floorRSliderValue; // hack to get integer values
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendula restitution
SliderParams slider("Pendula Restitution", &gPendulaRestitution);
slider.m_minVal = 0;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
slider.m_callback = onRopePendulaRestitutionChanged;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the rope resolution
SliderParams slider("Rope Resolution", &gRopeResolution);
slider.m_minVal = 1;
slider.m_maxVal = 20;
slider.m_clampToNotches = false;
slider.m_callback = floorRSliderValue;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendulum width
SliderParams slider("Pendulum Width", &gInitialPendulumWidth);
slider.m_minVal = 0;
slider.m_maxVal = 40;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the pendulum height
SliderParams slider("Pendulum Height", &gInitialPendulumHeight);
slider.m_minVal = 0;
slider.m_maxVal = 40;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to change the force to displace the lowest pendulum
SliderParams slider("Displacement force", &gDisplacementForce);
slider.m_minVal = 0.1;
slider.m_maxVal = 200;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
{ // create a slider to apply the force by slider
SliderParams slider("Apply displacement force", &gForceScalar);
slider.m_minVal = -1;
slider.m_maxVal = 1;
slider.m_clampToNotches = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(
slider);
}
m_guiHelper->setUpAxis(1);
createEmptyDynamicsWorld();
// create a debug drawer
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
if (m_dynamicsWorld->getDebugDrawer())
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
btIDebugDraw::DBG_DrawWireframe
+ btIDebugDraw::DBG_DrawContactPoints
+ btIDebugDraw::DBG_DrawConstraints
+ btIDebugDraw::DBG_DrawConstraintLimits);
{ // create the pendula starting at the indicated position below and where each pendulum has the following mass
btScalar pendulumMass(1.0f);
btVector3 position(0.0f,15.0f,0.0f); // initial left-most pendulum position
btQuaternion orientation(0,0,0,1); // orientation of the pendula
// Re-using the same collision is better for memory usage and performance
btSphereShape* pendulumShape = new btSphereShape(gSphereRadius);
m_collisionShapes.push_back(pendulumShape);
for (int i = 0; i < floor(gPendulaQty); i++) {
// create pendulum
createRopePendulum(pendulumShape, position, orientation,gInitialPendulumWidth,
gInitialPendulumHeight, pendulumMass);
// displace the pendula 1.05 sphere size, so that they all nearly touch (small spacings in between)
position.setX(position.x()-2.1f * gSphereRadius);
}
}
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
}
void NewtonsRopeCradleExample::connectWithRope(btRigidBody* body1, btRigidBody* body2)
{
btSoftBody* softBodyRope0 = btSoftBodyHelpers::CreateRope(softBodyWorldInfo,body1->getWorldTransform().getOrigin(),body2->getWorldTransform().getOrigin(),gRopeResolution,0);
softBodyRope0->setTotalMass(0.1f);
softBodyRope0->appendAnchor(0,body1);
softBodyRope0->appendAnchor(softBodyRope0->m_nodes.size()-1,body2);
softBodyRope0->m_cfg.piterations = 5;
softBodyRope0->m_cfg.kDP = 0.005f;
softBodyRope0->m_cfg.kSHR = 1;
softBodyRope0->m_cfg.kCHR = 1;
softBodyRope0->m_cfg.kKHR = 1;
getSoftDynamicsWorld()->addSoftBody(softBodyRope0);
}
void NewtonsRopeCradleExample::stepSimulation(float deltaTime) {
applyRForceWithForceScalar(gForceScalar); // apply force defined by apply force slider
if (m_dynamicsWorld) {
m_dynamicsWorld->stepSimulation(deltaTime);
}
}
void NewtonsRopeCradleExample::createRopePendulum(btSphereShape* colShape,
const btVector3& position, const btQuaternion& pendulumOrientation, btScalar width, btScalar height, btScalar mass) {
// The pendulum looks like this (names when built):
// O O topSphere1 topSphere2
// \ /
// O bottomSphere
//create a dynamic pendulum
btTransform startTransform;
startTransform.setIdentity();
// calculate sphere positions
btVector3 topSphere1RelPosition(0,0,width);
btVector3 topSphere2RelPosition(0,0,-width);
btVector3 bottomSphereRelPosition(0,-height,0);
// position the top sphere above ground with appropriate orientation
startTransform.setOrigin(btVector3(0,0,0)); // no translation intitially
startTransform.setRotation(pendulumOrientation); // pendulum rotation
startTransform.setOrigin(startTransform * topSphere1RelPosition); // rotate this position
startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position
btRigidBody* topSphere1 = createRigidBody(0, startTransform, colShape); // make top sphere static
// position the top sphere above ground with appropriate orientation
startTransform.setOrigin(btVector3(0,0,0)); // no translation intitially
startTransform.setRotation(pendulumOrientation); // pendulum rotation
startTransform.setOrigin(startTransform * topSphere2RelPosition); // rotate this position
startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position
btRigidBody* topSphere2 = createRigidBody(0, startTransform, colShape); // make top sphere static
// position the bottom sphere below the top sphere
startTransform.setOrigin(btVector3(0,0,0)); // no translation intitially
startTransform.setRotation(pendulumOrientation); // pendulum rotation
startTransform.setOrigin(startTransform * bottomSphereRelPosition); // rotate this position
startTransform.setOrigin(position + startTransform.getOrigin()); // add non-rotated position to the relative position
btRigidBody* bottomSphere = createRigidBody(mass, startTransform, colShape);
bottomSphere->setFriction(0); // we do not need friction here
pendula.push_back(bottomSphere);
// disable the deactivation when objects do not move anymore
topSphere1->setActivationState(DISABLE_DEACTIVATION);
topSphere2->setActivationState(DISABLE_DEACTIVATION);
bottomSphere->setActivationState(DISABLE_DEACTIVATION);
bottomSphere->setRestitution(gPendulaRestitution); // set pendula restitution
// add ropes between spheres
connectWithRope(topSphere1, bottomSphere);
connectWithRope(topSphere2, bottomSphere);
}
void NewtonsRopeCradleExample::renderScene()
{
CommonRigidBodyBase::renderScene();
btSoftRigidDynamicsWorld* softWorld = getSoftDynamicsWorld();
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());
}
}
}
void NewtonsRopeCradleExample::changePendulaRestitution(btScalar restitution) {
for (std::vector<btRigidBody*>::iterator rit = pendula.begin();
rit != pendula.end(); rit++) {
btAssert((*rit) && "Null constraint");
(*rit)->setRestitution(restitution);
}
}
bool NewtonsRopeCradleExample::keyboardCallback(int key, int state) {
//b3Printf("Key pressed: %d in state %d \n",key,state);
// key 3
switch (key) {
case '3' /*ASCII for 3*/: {
applyPendulumForce(gDisplacementForce);
return true;
}
}
return false;
}
void NewtonsRopeCradleExample::applyPendulumForce(btScalar pendulumForce){
if(pendulumForce != 0){
b3Printf("Apply %f to pendulum",pendulumForce);
for (int i = 0; i < gDisplacedPendula; i++) {
if (gDisplacedPendula >= 0 && gDisplacedPendula <= gPendulaQty)
pendula[i]->applyCentralForce(btVector3(pendulumForce, 0, 0));
}
}
}
// GUI parameter modifiers
void onRopePendulaRestitutionChanged(float pendulaRestitution) {
if (nex){
nex->changePendulaRestitution(pendulaRestitution);
}
}
void floorRSliderValue(float notUsed) {
gPendulaQty = floor(gPendulaQty);
gDisplacedPendula = floor(gDisplacedPendula);
gRopeResolution = floor(gRopeResolution);
}
void applyRForceWithForceScalar(float forceScalar) {
if(nex){
btScalar appliedForce = forceScalar * gDisplacementForce;
if(fabs(gForceScalar) < 0.2f)
gForceScalar = 0;
nex->applyPendulumForce(appliedForce);
}
}
CommonExampleInterface* ET_NewtonsRopeCradleCreateFunc(
CommonExampleOptions& options) {
nex = new NewtonsRopeCradleExample(options.m_guiHelper);
return nex;
}

View File

@@ -0,0 +1,22 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. 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.
*/
#ifndef ET_NEWTONS_ROPE_CRADLE_EXAMPLE_H
#define ET_NEWTONS_ROPE_CRADLE_EXAMPLE_H
class CommonExampleInterface* ET_NewtonsRopeCradleCreateFunc(struct CommonExampleOptions& options);
#endif //ET_NEWTONS_ROPE_CRADLE_EXAMPLE_H

View File

@@ -134,7 +134,8 @@ void RigidBodyFromObjExample::initPhysics()
int shapeId = m_guiHelper->registerGraphicsShape(&glmesh->m_vertices->at(0).xyzw[0], int shapeId = m_guiHelper->registerGraphicsShape(&glmesh->m_vertices->at(0).xyzw[0],
glmesh->m_numvertices, glmesh->m_numvertices,
&glmesh->m_indices->at(0), &glmesh->m_indices->at(0),
glmesh->m_numIndices); glmesh->m_numIndices,
B3_GL_TRIANGLES, -1);
shape->setUserIndex(shapeId); shape->setUserIndex(shapeId);
int renderInstance = m_guiHelper->registerGraphicsInstance(shapeId,pos,orn,color,scaling); int renderInstance = m_guiHelper->registerGraphicsInstance(shapeId,pos,orn,color,scaling);
body->setUserIndex(renderInstance); body->setUserIndex(renderInstance);

View File

@@ -39,7 +39,7 @@ files {
"../Importers/ImportURDFDemo/UrdfParser.cpp", "../Importers/ImportURDFDemo/UrdfParser.cpp",
"../Importers/ImportURDFDemo/urdfStringSplit.cpp", "../Importers/ImportURDFDemo/urdfStringSplit.cpp",
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp", "../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/stb_image/stb_image.cpp",
} }
@@ -91,7 +91,9 @@ files {
"../Importers/ImportURDFDemo/UrdfParser.cpp", "../Importers/ImportURDFDemo/UrdfParser.cpp",
"../Importers/ImportURDFDemo/urdfStringSplit.cpp", "../Importers/ImportURDFDemo/urdfStringSplit.cpp",
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp", "../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/stb_image/stb_image.cpp",
"../Utils/b3Clock.cpp",
"../Utils/b3Clock.h",
} }
if os.is("Linux") then initX11() end if os.is("Linux") then initX11() end
@@ -156,7 +158,7 @@ files {
"../Importers/ImportURDFDemo/UrdfParser.cpp", "../Importers/ImportURDFDemo/UrdfParser.cpp",
"../Importers/ImportURDFDemo/urdfStringSplit.cpp", "../Importers/ImportURDFDemo/urdfStringSplit.cpp",
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp", "../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/stb_image/stb_image.cpp",
} }
if os.is("Linux") then initX11() end if os.is("Linux") then initX11() end

View File

@@ -285,7 +285,7 @@ char* makeExeToBspFilename(const char* lpCmdLine)
} }
struct CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options) CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options)
{ {
BspDemo* demo = new BspDemo(options.m_guiHelper); BspDemo* demo = new BspDemo(options.m_guiHelper);

View File

@@ -28,6 +28,7 @@ subject to the following restrictions:
#include "btMatrix4x4.h" #include "btMatrix4x4.h"
#define MAX_VISUAL_SHAPES 512
struct VertexSource struct VertexSource
@@ -288,42 +289,47 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
}//for each mesh }//for each mesh
int shapeIndex = visualShapes.size(); int shapeIndex = visualShapes.size();
GLInstanceGraphicsShape& visualShape = visualShapes.expand(); if (shapeIndex<MAX_VISUAL_SHAPES)
{ {
visualShape.m_vertices = new b3AlignedObjectArray<GLInstanceVertex>; GLInstanceGraphicsShape& visualShape = visualShapes.expand();
visualShape.m_indices = new b3AlignedObjectArray<int>; {
int indexBase = 0; visualShape.m_vertices = new b3AlignedObjectArray<GLInstanceVertex>;
visualShape.m_indices = new b3AlignedObjectArray<int>;
int indexBase = 0;
btAssert(vertexNormals.size()==vertexPositions.size()); btAssert(vertexNormals.size()==vertexPositions.size());
for (int v=0;v<vertexPositions.size();v++) for (int v=0;v<vertexPositions.size();v++)
{ {
GLInstanceVertex vtx; GLInstanceVertex vtx;
vtx.xyzw[0] = vertexPositions[v].x(); vtx.xyzw[0] = vertexPositions[v].x();
vtx.xyzw[1] = vertexPositions[v].y(); vtx.xyzw[1] = vertexPositions[v].y();
vtx.xyzw[2] = vertexPositions[v].z(); vtx.xyzw[2] = vertexPositions[v].z();
vtx.xyzw[3] = 1.f; vtx.xyzw[3] = 1.f;
vtx.normal[0] = vertexNormals[v].x(); vtx.normal[0] = vertexNormals[v].x();
vtx.normal[1] = vertexNormals[v].y(); vtx.normal[1] = vertexNormals[v].y();
vtx.normal[2] = vertexNormals[v].z(); vtx.normal[2] = vertexNormals[v].z();
vtx.uv[0] = 0.5f; vtx.uv[0] = 0.5f;
vtx.uv[1] = 0.5f; vtx.uv[1] = 0.5f;
visualShape.m_vertices->push_back(vtx); visualShape.m_vertices->push_back(vtx);
} }
for (int index=0;index<indices.size();index++) for (int index=0;index<indices.size();index++)
{ {
visualShape.m_indices->push_back(indices[index]+indexBase); visualShape.m_indices->push_back(indices[index]+indexBase);
} }
//b3Printf(" index_count =%dand vertexPositions.size=%d\n",indices.size(), vertexPositions.size()); //b3Printf(" index_count =%dand vertexPositions.size=%d\n",indices.size(), vertexPositions.size());
indexBase=visualShape.m_vertices->size(); indexBase=visualShape.m_vertices->size();
visualShape.m_numIndices = visualShape.m_indices->size(); visualShape.m_numIndices = visualShape.m_indices->size();
visualShape.m_numvertices = visualShape.m_vertices->size(); visualShape.m_numvertices = visualShape.m_vertices->size();
} }
//b3Printf("geometry name=%s\n",geometryName); //b3Printf("geometry name=%s\n",geometryName);
name2Shape.insert(geometryName,shapeIndex); name2Shape.insert(geometryName,shapeIndex);
} else
{
b3Warning("DAE exceeds number of visual shapes (%d/%d)",shapeIndex, MAX_VISUAL_SHAPES);
}
}//for each geometry }//for each geometry
} }
@@ -557,7 +563,7 @@ void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArray<GLIn
// GLInstanceGraphicsShape* instance = 0; // GLInstanceGraphicsShape* instance = 0;
//usually COLLADA files don't have that many visual geometries/shapes //usually COLLADA files don't have that many visual geometries/shapes
visualShapes.reserve(32); visualShapes.reserve(MAX_VISUAL_SHAPES);
float extraScaling = 1;//0.01; float extraScaling = 1;//0.01;
btHashMap<btHashString, int> name2ShapeIndex; btHashMap<btHashString, int> name2ShapeIndex;

View File

@@ -67,7 +67,7 @@ bool b3ImportMeshUtility::loadAndRegisterMeshFromFileInternal(const std::string&
} else } else
{ {
b3Warning("not found %s\n",relativeFileName); b3Warning("not found [%s]\n",relativeFileName);
} }
} }
} }

View File

@@ -45,6 +45,7 @@ struct BulletURDFInternalData
UrdfParser m_urdfParser; UrdfParser m_urdfParser;
struct GUIHelperInterface* m_guiHelper; struct GUIHelperInterface* m_guiHelper;
char m_pathPrefix[1024]; char m_pathPrefix[1024];
int m_bodyId;
btHashMap<btHashInt,btVector4> m_linkColors; btHashMap<btHashInt,btVector4> m_linkColors;
btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes; btAlignedObjectArray<btCollisionShape*> m_allocatedCollisionShapes;
@@ -108,7 +109,8 @@ struct BulletErrorLogger : public ErrorLogger
bool BulletURDFImporter::loadURDF(const char* fileName, bool forceFixedBase) bool BulletURDFImporter::loadURDF(const char* fileName, bool forceFixedBase)
{ {
if (strlen(fileName)==0)
return false;
//int argc=0; //int argc=0;
char relativeFileName[1024]; char relativeFileName[1024];
@@ -132,7 +134,7 @@ bool BulletURDFImporter::loadURDF(const char* fileName, bool forceFixedBase)
std::fstream xml_file(relativeFileName, std::fstream::in); std::fstream xml_file(relativeFileName, std::fstream::in);
while ( xml_file.good() ) while ( xml_file.good())
{ {
std::string line; std::string line;
std::getline( xml_file, line); std::getline( xml_file, line);
@@ -174,7 +176,7 @@ bool BulletURDFImporter::loadSDF(const char* fileName, bool forceFixedBase)
m_data->m_pathPrefix[0] = 0; m_data->m_pathPrefix[0] = 0;
if (!fileFound){ if (!fileFound){
std::cerr << "URDF file not found" << std::endl; std::cerr << "SDF file not found" << std::endl;
return false; return false;
} else } else
{ {
@@ -207,6 +209,18 @@ const char* BulletURDFImporter::getPathPrefix()
return m_data->m_pathPrefix; return m_data->m_pathPrefix;
} }
void BulletURDFImporter::setBodyUniqueId(int bodyId)
{
m_data->m_bodyId =bodyId;
}
int BulletURDFImporter::getBodyUniqueId() const
{
return m_data->m_bodyId;
}
BulletURDFImporter::~BulletURDFImporter() BulletURDFImporter::~BulletURDFImporter()
{ {
@@ -969,16 +983,17 @@ int BulletURDFImporter::convertLinkVisualShapes(int linkIndex, const char* pathP
// graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size()); // graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size());
//graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size()); //graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size());
CommonRenderInterface* renderer = m_data->m_guiHelper->getRenderInterface(); //CommonRenderInterface* renderer = m_data->m_guiHelper->getRenderInterface();
if (renderer) if (1)
{ {
int textureIndex = -1; int textureIndex = -1;
if (textures.size()) if (textures.size())
{ {
textureIndex = renderer->registerTexture(textures[0].textureData,textures[0].m_width,textures[0].m_height);
textureIndex = m_data->m_guiHelper->registerTexture(textures[0].textureData,textures[0].m_width,textures[0].m_height);
} }
graphicsIndex = renderer->registerShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(),B3_GL_TRIANGLES,textureIndex); graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(),B3_GL_TRIANGLES,textureIndex);
} }
} }
@@ -1003,14 +1018,25 @@ bool BulletURDFImporter::getLinkColor(int linkIndex, btVector4& colorRGBA) const
return false; return false;
} }
bool BulletURDFImporter::getLinkContactInfo(int linkIndex, URDFLinkContactInfo& contactInfo ) const
{
UrdfLink* const* linkPtr = m_data->m_urdfParser.getModel().m_links.getAtIndex(linkIndex);
if (linkPtr)
{
const UrdfLink* link = *linkPtr;
contactInfo = link->m_contactInfo;
return true;
}
return false;
}
void BulletURDFImporter::convertLinkVisualShapes2(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, class btCollisionObject* colObj) const void BulletURDFImporter::convertLinkVisualShapes2(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, class btCollisionObject* colObj, int objectIndex) const
{ {
if (m_data->m_customVisualShapesConverter) if (m_data->m_customVisualShapesConverter)
{ {
const UrdfModel& model = m_data->m_urdfParser.getModel(); const UrdfModel& model = m_data->m_urdfParser.getModel();
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,localInertiaFrame, model, colObj); m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,localInertiaFrame, model, colObj, objectIndex);
} }
} }
@@ -1045,13 +1071,14 @@ btCollisionShape* BulletURDFImporter::getAllocatedCollisionShape(int index)
{ {
const UrdfCollision& col = link->m_collisionArray[v]; const UrdfCollision& col = link->m_collisionArray[v];
btCollisionShape* childShape = convertURDFToCollisionShape(&col ,pathPrefix); btCollisionShape* childShape = convertURDFToCollisionShape(&col ,pathPrefix);
m_data->m_allocatedCollisionShapes.push_back(childShape);
if (childShape) if (childShape)
{ {
btTransform childTrans = col.m_linkLocalFrame; btTransform childTrans = col.m_linkLocalFrame;
compoundShape->addChildShape(localInertiaFrame.inverse()*childTrans,childShape); compoundShape->addChildShape(localInertiaFrame.inverse()*childTrans,childShape);
} }
} }
} }

View File

@@ -25,7 +25,8 @@ public:
virtual bool loadSDF(const char* fileName, bool forceFixedBase = false); virtual bool loadSDF(const char* fileName, bool forceFixedBase = false);
virtual int getNumModels() const; virtual int getNumModels() const;
virtual void activateModel(int modelIndex); virtual void activateModel(int modelIndex);
virtual void setBodyUniqueId(int bodyId);
virtual int getBodyUniqueId() const;
const char* getPathPrefix(); const char* getPathPrefix();
void printTree(); //for debugging void printTree(); //for debugging
@@ -37,6 +38,8 @@ public:
virtual std::string getLinkName(int linkIndex) const; virtual std::string getLinkName(int linkIndex) const;
virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const; virtual bool getLinkColor(int linkIndex, btVector4& colorRGBA) const;
virtual bool getLinkContactInfo(int linkIndex, URDFLinkContactInfo& contactInfo ) const;
virtual std::string getJointName(int linkIndex) const; virtual std::string getJointName(int linkIndex) const;
@@ -48,7 +51,7 @@ public:
virtual int convertLinkVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame) const; virtual int convertLinkVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame) const;
virtual void convertLinkVisualShapes2(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame, class btCollisionObject* colObj) const; virtual void convertLinkVisualShapes2(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame, class btCollisionObject* colObj, int objectIndex) const;
///todo(erwincoumans) refactor this convertLinkCollisionShapes/memory allocation ///todo(erwincoumans) refactor this convertLinkCollisionShapes/memory allocation

View File

@@ -36,7 +36,8 @@ class ImportUrdfSetup : public CommonMultiBodyBase
struct ImportUrdfInternalData* m_data; struct ImportUrdfInternalData* m_data;
bool m_useMultiBody; bool m_useMultiBody;
btAlignedObjectArray<std::string* > m_nameMemory; btAlignedObjectArray<std::string* > m_nameMemory;
btScalar m_grav;
int m_upAxis;
public: public:
ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName); ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName);
virtual ~ImportUrdfSetup(); virtual ~ImportUrdfSetup();
@@ -65,7 +66,8 @@ btAlignedObjectArray<std::string> gFileNameArray;
struct ImportUrdfInternalData struct ImportUrdfInternalData
{ {
ImportUrdfInternalData() ImportUrdfInternalData()
:m_numMotors(0) :m_numMotors(0),
m_mb(0)
{ {
for (int i=0;i<MAX_NUM_MOTORS;i++) for (int i=0;i<MAX_NUM_MOTORS;i++)
{ {
@@ -74,16 +76,21 @@ struct ImportUrdfInternalData
} }
} }
btScalar m_motorTargetVelocities[MAX_NUM_MOTORS]; btScalar m_motorTargetVelocities[MAX_NUM_MOTORS];
btMultiBodyJointMotor* m_jointMotors [MAX_NUM_MOTORS]; btMultiBodyJointMotor* m_jointMotors [MAX_NUM_MOTORS];
btGeneric6DofSpring2Constraint* m_generic6DofJointMotors [MAX_NUM_MOTORS]; btGeneric6DofSpring2Constraint* m_generic6DofJointMotors [MAX_NUM_MOTORS];
int m_numMotors; int m_numMotors;
btMultiBody* m_mb;
btRigidBody* m_rb;
}; };
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName) ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
:CommonMultiBodyBase(helper) :CommonMultiBodyBase(helper),
m_grav(0),
m_upAxis(2)
{ {
m_data = new ImportUrdfInternalData; m_data = new ImportUrdfInternalData;
@@ -128,7 +135,7 @@ ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option,
if (gFileNameArray.size()==0) if (gFileNameArray.size()==0)
{ {
gFileNameArray.push_back("sphere2.urdf"); gFileNameArray.push_back("r2d2.urdf");
} }
@@ -182,9 +189,9 @@ void ImportUrdfSetup::setFileName(const char* urdfFileName)
void ImportUrdfSetup::initPhysics() void ImportUrdfSetup::initPhysics()
{ {
int upAxis = 2;
m_guiHelper->setUpAxis(upAxis); m_guiHelper->setUpAxis(m_upAxis);
this->createEmptyDynamicsWorld(); this->createEmptyDynamicsWorld();
//m_dynamicsWorld->getSolverInfo().m_numIterations = 100; //m_dynamicsWorld->getSolverInfo().m_numIterations = 100;
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld); m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
@@ -195,15 +202,19 @@ void ImportUrdfSetup::initPhysics()
);//+btIDebugDraw::DBG_DrawConstraintLimits); );//+btIDebugDraw::DBG_DrawConstraintLimits);
btVector3 gravity(0,0,0); if (m_guiHelper->getParameterInterface())
gravity[upAxis]=-9.8; {
SliderParams slider("Gravity", &m_grav);
m_dynamicsWorld->setGravity(gravity); slider.m_minVal = -10;
slider.m_maxVal = 10;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider);
}
BulletURDFImporter u2b(m_guiHelper, 0); BulletURDFImporter u2b(m_guiHelper, 0);
bool loadOk = u2b.loadURDF(m_fileName); bool loadOk = u2b.loadURDF(m_fileName);
#ifdef TEST_MULTIBODY_SERIALIZATION #ifdef TEST_MULTIBODY_SERIALIZATION
//test to serialize a multibody to disk or shared memory, with base, link and joint names //test to serialize a multibody to disk or shared memory, with base, link and joint names
@@ -223,7 +234,6 @@ void ImportUrdfSetup::initPhysics()
{ {
btMultiBody* mb = 0;
//todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user //todo: move these internal API called inside the 'ConvertURDF2Bullet' call, hidden from the user
@@ -232,7 +242,13 @@ void ImportUrdfSetup::initPhysics()
MyMultiBodyCreator creation(m_guiHelper); MyMultiBodyCreator creation(m_guiHelper);
ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix()); ConvertURDF2Bullet(u2b,creation, identityTrans,m_dynamicsWorld,m_useMultiBody,u2b.getPathPrefix());
mb = creation.getBulletMultiBody(); m_data->m_rb = creation.getRigidBody();
m_data->m_mb = creation.getBulletMultiBody();
btMultiBody* mb = m_data->m_mb;
for (int i = 0; i < u2b.getNumAllocatedCollisionShapes(); i++)
{
m_collisionShapes.push_back(u2b.getAllocatedCollisionShape(i));
}
if (m_useMultiBody && mb ) if (m_useMultiBody && mb )
{ {
@@ -341,14 +357,15 @@ void ImportUrdfSetup::initPhysics()
if (createGround) if (createGround)
{ {
btVector3 groundHalfExtents(20,20,20); btVector3 groundHalfExtents(20,20,20);
groundHalfExtents[upAxis]=1.f; groundHalfExtents[m_upAxis]=1.f;
btBoxShape* box = new btBoxShape(groundHalfExtents); btBoxShape* box = new btBoxShape(groundHalfExtents);
m_collisionShapes.push_back(box);
box->initializePolyhedralFeatures(); box->initializePolyhedralFeatures();
m_guiHelper->createCollisionShapeGraphicsObject(box); m_guiHelper->createCollisionShapeGraphicsObject(box);
btTransform start; start.setIdentity(); btTransform start; start.setIdentity();
btVector3 groundOrigin(0,0,0); btVector3 groundOrigin(0,0,0);
groundOrigin[upAxis]=-2.5; groundOrigin[m_upAxis]=-2.5;
start.setOrigin(groundOrigin); start.setOrigin(groundOrigin);
btRigidBody* body = createRigidBody(0,start,box); btRigidBody* body = createRigidBody(0,start,box);
//m_dynamicsWorld->removeRigidBody(body); //m_dynamicsWorld->removeRigidBody(body);
@@ -357,8 +374,7 @@ void ImportUrdfSetup::initPhysics()
m_guiHelper->createRigidBodyGraphicsObject(body,color); m_guiHelper->createRigidBodyGraphicsObject(body,color);
} }
///this extra stepSimulation call makes sure that all the btMultibody transforms are properly propagates.
m_dynamicsWorld->stepSimulation(1. / 240., 0);// 1., 10, 1. / 240.);
} }
#ifdef TEST_MULTIBODY_SERIALIZATION #ifdef TEST_MULTIBODY_SERIALIZATION
@@ -379,6 +395,10 @@ void ImportUrdfSetup::stepSimulation(float deltaTime)
{ {
if (m_dynamicsWorld) if (m_dynamicsWorld)
{ {
btVector3 gravity(0, 0, 0);
gravity[m_upAxis] = m_grav;
m_dynamicsWorld->setGravity(gravity);
for (int i=0;i<m_data->m_numMotors;i++) for (int i=0;i<m_data->m_numMotors;i++)
{ {
if (m_data->m_jointMotors[i]) if (m_data->m_jointMotors[i])

View File

@@ -3,7 +3,7 @@
struct LinkVisualShapesConverter struct LinkVisualShapesConverter
{ {
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const class btTransform& localInertiaFrame, const struct UrdfModel& model, class btCollisionObject* colObj)=0; virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const class btTransform& localInertiaFrame, const struct UrdfModel& model, class btCollisionObject* colObj, int objectIndex)=0;
}; };
#endif //LINK_VISUAL_SHAPES_CONVERTER_H #endif //LINK_VISUAL_SHAPES_CONVERTER_H

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