Dyn4j integration

I’m working on a plugin that will integrate jme3 and dyn4j. I have created a very simple base implementation to handle bodies only. I will add joint support later. Basicaly the plugin has an AppState, a class to handle objects interactions with physic world (add/remove body, set simulation speed, etc.) and several classes for debugging purpose . I’m using the Bullet native integration as a guide.

[video]http://youtu.be/27YpJw-U9-g[/video]
[video]http://youtu.be/MYPMqAQAbRI[/video]
[video]http://youtu.be/W0fgLFxH7cg[/video]
[video]http://youtu.be/TNOJ_Spe888[/video]

A lot of work to do still but I looking fine so far.

Hope you like it.

10 Likes

Thats sweet. I like it!

Great ,keep going! :wink:

So awesome. I hope we’ll see a lot of 2D physics platformers using this :slight_smile:

I posted a link to this forum on the Dyn4J forum :slight_smile:
http://forum.dyn4j.org/viewtopic.php?f=1&t=94

I’ll use it for sure. I’d like to integrate this into my library once you feel comfortable with your progress. If you need any assistance, I have a pretty basic integration already complete. Just let me know.

@t0neg0d said: I'll use it for sure. I'd like to integrate this into my library once you feel comfortable with your progress. If you need any assistance, I have a pretty basic integration already complete. Just let me know.

If you can review and make any suggestion, it will be great! I will let you know when base implementation is ready. Thanks

Thanks for all your comments! I apreciate that.

Added more basic shape suppor for debugging. Dyn4j let you define the world’s bounds. So, If an body travels (fully) outside the bounds the state of the body will be set to “inactive” and will no longer be interacting with the World or other bodies. The debug shape color is set to gray for inactive objects (you can notice that on a couple of videos).

Basic imtegration is ready. I will start adding joint suppor. I will clean and document the code in order to prepare for releasing it as plugin.

New videos:
[video]http://youtu.be/KlN-aYuhomU[/video]
[video]http://youtu.be/F7geHgY9K7g[/video]
[video]http://youtu.be/0Z1tX8e3J9M[/video]
[video]http://youtu.be/jRt41_jGdxk[/video]

7 Likes

This is really looking great!

Looks good :slight_smile:

I like it! looking forward for the joint support and the release!! :slight_smile:

i would love to see it in the core engine. As bullet.
Also, interesting performance stress-test. For example add 500 bodies. How will be fps?
Also it’s possible to make it multithreading? For speed performance…

@mifth said: Also, interesting performance stress-test. For example add 500 bodies. How will be fps?
I guess 500 dynamic bodies: very bad. Here are some performance tips https://code.google.com/p/dyn4j/wiki/Performance
Also it’s possible to make it multithreading? For speed performance..

Dyn4j is single-threaded. So I guess the best way for integration would be to do exactly like the Bullet and have one separate thread for physics - at least that’s how I’d do it.

@jmaasing said: I guess 500 dynamic bodies: very bad. Here are some performance tips https://code.google.com/p/dyn4j/wiki/Performance

Dyn4j is single-threaded. So I guess the best way for integration would be to do exactly like the Bullet and have one separate thread for physics - at least that’s how I’d do it.

That’s for the stress-test. Make maximum and check the fps…

@mifth said: That's for the stress-test. Make maximum and check the fps...

Problem is how to define maximum.

“The rendering time vary relative to the total bodies of course. 10.000 bodies simulation (1000 frames in total) took about 30 minutes. the biggest one I made was with 50.000 bodies and took a little less than a day”
http://forum.dyn4j.org/viewtopic.php?f=1&t=88

@jmaasing said: I guess 500 dynamic bodies: very bad. Here are some performance tips https://code.google.com/p/dyn4j/wiki/Performance

Dyn4j is single-threaded. So I guess the best way for integration would be to do exactly like the Bullet and have one separate thread for physics - at least that’s how I’d do it.

Exactly! I’m using Bullet integration as a guide, so you have the two options: you can run the Dyn4jAppState on a different threat (by default) with fix timestep (1/60 sec) or on the same threat using variable timeStep. Running it on a different threat is the best way in my opinion (better performance and you will avoid weird results).

From Dyn4j wiki (Google Code Archive - Long-term storage for Google Code Project Hosting.):
"To allow simulation of the scene the World object has two methods that must be called from the game loop: World.update(double) or World.updatev(double). These methods must be passed the elapsed time from the last iteration in seconds.

The World.updatev(double) method can be used if you prefer a variable time step or would like to control when the World updates yourself. The World.update(double) method will only update given the step frequency set in the Settings object.

Note: Variable time steps can reduce accuracy and stability."

@mifth said: i would love to see it in the core engine. As bullet. Also, interesting performance stress-test. For example add 500 bodies. How will be fps? Also it's possible to make it multithreading? For speed performance..

I will add more interesting tests soon.

2 Likes

Hello. Do you use double’s as it is in Dyn4j for now or have switched to float’s. Any ideas about it?

  • Dmitry
@DmitryKolesnikovich said: Hello. Do you use double's as it is in Dyn4j for now or have switched to float's. Any ideas about it? - Dmitry
Hi! I use double for dyn4j related things (set gravity, etc) and the convert from double to float in order to set jme3 objects' location/rotation (inside jme3's control logic). there is no wrapers for dyn4j objects so far. You will need to create dyn4j's shapes and get body for dynamic objects from jme3 object control. You will be able to get dyn4j's World instance from Dyn4jAppState.

I’m not making a game. So, I don’t know what stuff will be needed. So, I will try release the code soon and then make changes according to users suggestions/ideas.

May be you have some thoughts from your expirience about “float vs double”? Specially when you want your game run on mobile devices. Is it worth to care about such things?