mjbWorld program - User guide - Dynamics

The previous tutorial allowed motion to be into the 3d models, this tutorial adds the ability to detect and respond to collisions.

To do this we add the DynamicsBean (here we are doing forward dynamics as opposed to inverse dynamics - inverse comes later!). I.e. motion is calculated from the forces, such as, force = mass * acceleration, constraints are not yet applied.

This tutorial sets up a collision between two shapes, when they collide they should bounce off each other rather than passing through each other.

First add two shapes with kinematics beans added to them (to see how to do this read the previous tutorial )

Change the colour of one of the shapes so the we can distinguish between the shapes..

Setup the kinematics beans under each of the transformGroups to setup the collision as follows:

Left hand shape:

Right hand shape:

Now add a dynamicsBean to each of the transformGroups, and set:

This tells the program that when this node collides with another node, then reverse the direction of this node.

(don't reverse the direction of the other node because that has its own dynamicsBean.

Future upgrades to the program will allow a better simulation of the physics of the collision.

To get to this point you could load the following file collision2.wrl

Now run the simulation by adding a timeline view and hit play (green arrow) to see animation.

Note there is currently a bug in the program, the collision only seems to be detected when one of the transforms is selected, I'm working on this bug, can anyone help? see trace

metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.


Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.


This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2018 Martin John Baker - All rights reserved - privacy policy.