mcjBulletService01
Version History
July 15th 2015 -- new Bullet3-engine server, 64 bit - and MOST IMPORTANTLY - a new version of the Client that doesnt render
the server catatonic
nov 24 2013 -- launched
nov 24 2013 -- new version of the client, fixes major issues with the type 2 hinges
nov 25 2013 00:10 --- new version notably includes access to type 3 hinge parameters and springs
Introduction
This physics simulation service for Daz Studio is based on the Open Source Bullet Physics engine
read about Bullet Physics here : http://bulletphysics.org/wordpress/
This is the first beta version
It implements the following Bullet Physics features
Rigid bodies:
- static
- dynamic
- kinematic ( animated or choreographed )
Collision shapes:
- cube
- sphere
- rod
- cylinder
- cone
- triangle mesh
Hinge constraints:
- type A object-to-object hinge
- type B world-to-object hinge
- type 2 steer and roll
Installation
This system is has 2 parts
The client is a Daz Script named mcjPhysicsClient01.dsa
unzip the installation package named mcjPhysicsClient01.zip in your Daz Content folder
a typical Daz Content folder is
C:\Users\YOURUSERNAME\Documents\DAZ 3D\Studio\My Library
or in my case
C:\Program Files (x86)\DAZ\Studio\content
once installed, the script can be found in your Daz Studio content panel
typically under Daz Studio Formats / My Library / Studio / mcasual
The server is a PC/Windows executable program named mcjBulletServer001_32bit.,exe
unzip the installation package named mcjBulletServer001_32bit.zip wherever you please
example: i installed mine in the same folder as the client
C:\Users\MYUSERNAME\Documents\DAZ 3D\Studio\My Library\Scripts\mcasual
Use
overview
1 - tag objects in your scene as physical bodies and constraints ( hinges for now )
2 - click the upload button -- this will write the description of your physical world to your hard disk
3 - click the simulate button -- this will launch the server which then compute what happens in that world - the actual simulation
4 - click the download button -- the results of the simulation are recovered from a file and applied to the objects in your scene
0 - telling the client the location of the server
the heavy maths work is done by the Server
the client script must be able to invoke the server
so it needs to know the location of the server
click on the "Select server" button and browse up to the server file named
mcjBulletServer001_32bit.,exe
1 - turning objects in your scene into physical bodies
Only objects and figures processed using the client script will be taken in consideration by the physics simulator
- Static objects
select the object(s)
click the "make static" button
if you now look in this object's parameter tab
you will notice it contains a new section named "physics"
and a subsection named "body"
This object is therefore considered a physical body
objects with a mass of 0 are deemed static, meaning they wont move
so they are used as obstacles and as the ground
- Static objects
select the object(s)
click the "make dynamic" button
here too the parameter tab of the object gained a new Physics/Body section
the only difference is that the mass is non-zero
this mere fact makes the object a "dynamic" object
the object will fall according to gravity
it will bounce if it hits other physical bodies or if it gets hit by them
- Kinematic objects
select the object(s)
click the "make kinematic" button
in the newly acquired physics/body section of this object's parameter tab
we can see the "kinematic" option is turned on
Those objects will move in the physical world according to the way you animate them
they will influence the dynamic bodies, but wont be influenced by them nor by the static bodies
Objects like that are sometimes called "choreographed"
Collision shapes
The simulator does not really "see" the objects in daz studio, it sees them as collision shapes.
In the 3 examples so far, the objects were respectively a cube, a sphere and a cylinder.
The client script, based on the name of each object selected the appropriate collision shape.
The client only knows the names
- cube
- sphere
- rod
- cylinder
- cone
- triangle mesh
objects with other names will all default to the "btCubeShape" collision shape
it will be up to you to change this to the shape appropriate for your objects
for now the triangle mesh collision shape is not really really usable
unless you can figure this :
the server expects to find an obj file named mesh1.obj in the same folder as the server
the server must be run using a batch file of the form
"C:/server/mcjBulletServer001.exe" "C:/server/in.txt" "C:/server/out.txt"
you could then use the client script to download/apply the simulation results
Constraints
3 types of constraints have been implemented
Type A Hinge - constrain 2 objects
create a cylinder
this cylinder will be treated as the position and orientation of the hinge
click on the "make hinge A ( two bodies ) button
go in the cylinder/hinge's properties panel
a new section named "Physics" and a section named "hinge" was added to the panel
specify the two objects constrained by this hinge
the two objects must imperatively be physical bodies
Type B Hinge - constrain an object to the world
create a cylinder
this cylinder will be treated as the position and orientation of the hinge
click on the "make Hinge B ( world bound )" button
go in the cylinder/hinge's properties panel
a new section named "Physics" and a section named "hinge" was added to the panel
specify the object constrained by this hinge
Type 2 Hinge - steer and roll hinge
create a cylinder
this cylinder will be treated as the position and orientation of the steer axis of the hinge
click on the "make Hinge ( steer & roll )" button
go in the hinge's properties panel
a new section named "Physics" and a section named "hinge" was added to the panel
specify the two objects constrained by this hinge
in our example, a front wheel gets connected to a car body
the "roll axis" ( red cylinder ) must imperatively be a child node of the steer-axis ( green cylinder )
also, the roll axis label must contain the word "roll"
in our example the roll axis cylinder was labeled "Front roll"
the steer and roll axis must form a 90 degrees angle
experimental notes:
- make sure your wheels are not seen as boxes
- if the vehicle body's mass is only 1 and the wheels are not turning, try a mass of 10 or 100
example of a type 2 hinge rig
the blue cube named "car body" is a dynamic body with a mass of 800
the Dakota's body is parented to it
the two Type 2 hinges may be parented to it ( else they are left behind during the simulation )
the large red cylinders are dynamic bodies with a mass of 50
they are named "front wheel" and "rear wheel"
the Dakota's wheels are parented to them
the green cylinders are type 2 ( steer and roll ) hinges
the green cylinder is also the steer axis ( axis 1 )
the smaller red cylinder is the roll axis ( axis 2 )
the roll axis must be a child node of the steer axis
parenting can be performed in Daz Studio's Scene Panel ( or using my mcjParent script )
the label of the roll axis must contain the word "roll"
re-labeling can be performed in Daz Studio's Scene Panel
in the parameters tab of the hinge nodes :
the front hinge links "car body" to "front wheel"
body__A = "car body"
body__B = "front wheel"
the rear hinge links "car body" to "rear wheel"
body__A = "car body"
body__B = "rearwheel"
the hinge spring parameters ( which may not be ideal ) were
spring: On
stiffness : 1.0
damping: 0.01
angular limits: -1 degree to 1 degree
linear limits: -10 cm to 10 cm
Understanding the linear limits of the Type 2 ( steer and roll ) hinges
apparently the springs on the hinges are always on
this will be fixed in the next version
so for now you could leave the limits at -0.001 and 0.001 to get the equivalent of a disabled spring
in the figure 1 animation
linear lower limit 0
linear upper limit: 1
spring off
presently “spring off” means the physics’ engine default settings are used
probably stiffness is 0.0 and damping is 1.0
to give you an idea of the sizes, the diameter of the yellow cylinder is 1 meter
we get a spring compression of 1 meter
in figure 2 you can see a plot of the position of the cyan cube ( the first body attached to the hinge )
using a linear-lower-limit below 0.0 gives us a behavior that is hard ( for me ) to figure
but using linear lower lower limit = 0 and linear upper limit = positive works well
my conclusion is that the limits should be called
minimum spring compression and maximum spring compression
indeed if you look at the case where linear lower limit = 0.2
the simulator forced a compression of the spring at frame 1
Constraint-hinge parameters take some trial and error work
often it seems the constraints are fighting one against the other
one way to solve this seems to make the body of the car much heavier than the wheels
in the example below wheel mass = 4 car body mass = 400
hinge parameters
linear lower limit 0
linear upper limit 0.1 ( 10 cm )
spring On
stiffness 50
damping 0.001
in a previous test increasing the ground cube thickness helped
in this case increasing the wheel widths helped
fig7
Notes in the margin
In the scene shown below, the ground cube was made thick,
because on previous runs, a thin ground cube gave us large errors :
the cement blocks were half-sunken in the floor cube.
Some cement blocks were even going right through the ground cube.
another way to solve this would be to make the simulator use smaller time steps. ...
this option will be in the next version
Locked data files
If the client script or the server program fail,
the files used to exchange data between the server and the client may become locked.
one way to fix this is to close Daz Studio and re-open it
the exchange files reside in the same folder as the server program
if you try to open the data files ( in.txt or out.txt ) using a text editor
and the editor refuses to open the file, it's a sign that the data files are locked.
You may also want to check with Windows task manager if there's a half-dead server process locking the data files.
if you see one or many processes named mcjBulletServer in the task manager list, you should (ex)terminate them.
License
//===================================================================
// by mCasual/Jacques
//===================================================================
// Copyright (c) <2013> <mCasual/Jacques>
//Permission is hereby granted, free of charge, to any person
//obtaining a copy of this software and associated documentation
//files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge,
//publish, distribute, sublicense, and/or sell copies of the Software,
//and to permit persons to whom the Software is furnished to do so,
//subject to the following conditions:
//
//The above copyright notice and this permission notice shall be
//included in all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//===================================================================