Exporting to code

7 views
Skip to first unread message

Matt Sephton

unread,
Aug 8, 2010, 9:16:29 AM8/8/10
to meka...@googlegroups.com
I've been playing without the Export to C++ feature. It works well but export to Box2D does not support every feature Mekanimo does. But I thought Mekanimo was built using Box2D? So why are there differences?

If the differences are unavoidable, it would be great if the export function could export extra code to "fake" the missing items. For example, spring could map to a series of "soft" distance joints.

Thank,
matt

Fahri

unread,
Aug 8, 2010, 11:31:02 AM8/8/10
to Mekanimo
Mekanimo is using pyBox2D as its solver. To simulate the spring
forces, we add external forces and torque at each time step by using
Euler integration. For games this works fine but for engineering and
scientific simulations an adaptive step size Runge-Kutta method or
something similar would be better. As an option we can use modified
distance joints to simulate springs and generate code for springs.
There would be several problems with this but it would be better than
nothing. One problem would be the damping behavior. I am not sure if
it is possible to simulate damping with distance joints. I will look
into this. If anybody knows how to do this please chime in.

Fahri

The generated C++ code creates a C++ header file for the Box2D (C++
version) testbed. I think many people take this code and convert it
to C#, Java, Flash, Javascript etc.

Matt Sephton

unread,
Aug 8, 2010, 12:04:10 PM8/8/10
to meka...@googlegroups.com
In the Box2D manual they state:

"The distance joint can also be made soft, like a spring-damper connection.

Softness is achieved by tuning two constants in the definition:
frequency and damping ratio. Think of the frequency as the frequency
of a harmonic oscillator (like a guitar string). The frequency is
specified in Hertz. Typically the frequency should be less than a half
the frequency of the time step. So if you are using a 60Hz time step,
the frequency of the distance joint should be less than 30Hz. The
reason is related to the Nyquist frequency.

The damping ratio is non-dimensional and is typically between 0 and 1,
but can be larger. At 1, the damping is critical (all oscillations
should vanish)."

> --
> You received this message because you are subscribed to the Google Groups "Mekanimo" group.
> To post to this group, send email to meka...@googlegroups.com.
> To unsubscribe from this group, send email to mekanimo+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mekanimo?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages