Physics simulator based on dyn4j

Posts that don't fit into other categories.
maheshkurmi
Posts: 63
Joined: Tue Mar 27, 2012 7:20 am
Location: India
Contact:

Physics simulator based on dyn4j

Postby maheshkurmi » Mon Jan 21, 2013 1:24 am

Hi,
I am planning to develop Physics Simulator based on 'dyn4j' . I have tested it a lot against 'box2d' and I found dyn4j to be more usable from my perspective than box2d.
I have already developed maths 3D plotter in pure java whose GUI is inspired lot from nicely built 'Sandbox'. http://code.google.com/p/calc3d/downloads/list
I also tried to make JOGL version of the code.

Now I am comfortable enough in how to use dyn4j and JOGL both, but there are few problems.
1. How to export JOGL projects as executable outside eclipse?
2. can Java2D be used for sandbox like application?
3. I am still unable to set physics environment in dyn4j close to ideal (eg. zero damping in spring ) otherwise real world simulation is quite fine. dyn4j Engine may be modified to have the option to run for real world/ ideal state simulation.
4. I may need support from all members of the forum especially the developer himself(I am a big fan of him) while development.

Regards
mahesh Kurmi.
[url]neoaudioplayer.blogspot.in[/url]

William
Site Admin
Posts: 378
Joined: Sat Feb 06, 2010 10:23 pm

Re: Physics simulator based on dyn4j

Postby William » Mon Jan 21, 2013 8:12 am

Nice job on Calc3d!

1. There are few deployment methods for JOGL:
One, which is the preferred way, is to use JNLP. This is what Sandbox uses for its deployment and its super easy to add JOGL (just reference one of JOGL's JNLP files inside yours and you are good to go). The only downside to this method is that it requires (your) jar files to be signed (JOGL's binaries are already signed). You can self sign your jars but it will display a warning to the user before running, asking if they are sure they want to. On the other hand, you can have your jars signed through a CA so that you don't get that message, but its not cheap. Another option is to use a third party java installer like Launch4j. These will package your resources into a native executable. Another option is to write something yourself. You can package anything into a jar file (since its really just a .zip). You could package all the resources (natives and all) and just unpack them when your app starts. Lastly, you could just offer a .zip which contains everything. I have a project that I'm releasing soon that will be packaged this way.

2. Java2D is great for most apps. If you were making a high quality 3D game or something, you would need access to the GPU directly, but for stuff like the Sandbox, its not really needed. In addition, Java2D doesn't require any additional packaging steps, and therefore could be released as a single jar (much easier than any of the above; just like you did with calc).

3. dyn4j was not built for ideal physics. However, it should be possible (in some cases) without too much modification, but I would be hesitant to add it to the main distribution. In my opinion you can get close by adding a few custom classes (like the ideal spring that I posted on another post). However, it will be difficult to do this in the general case. Ideal physical simulations are extremely difficult to get right. In my experience the simulation will always blow up (not to mention jittering, oscillation, locking, and low performance). This is due to a number of factors, including the integration scheme (which can only ever be an approximation), finite precision, and an already approximate modelling of the real world. If you have some situations that aren't acting ideal, let me know and we can try an work out a solution.

4. I am always happy to offer whatever help I can.

William

maheshkurmi
Posts: 63
Joined: Tue Mar 27, 2012 7:20 am
Location: India
Contact:

Re: Physics simulator based on dyn4j

Postby maheshkurmi » Mon Jan 21, 2013 10:48 pm

Hi,
Thanks for ur fast reply..
One more question? Have you tried dyn4j on android? how does it work? Does it have compatibility/ performance issues? If you haven't, I will make a try.
Regards
Mahesh Kurmi

William
Site Admin
Posts: 378
Joined: Sat Feb 06, 2010 10:23 pm

Re: Physics simulator based on dyn4j

Postby William » Tue Jan 22, 2013 7:39 am

No, I haven't tried it on Android. It would compile and run no problem, however, I'm afraid it may not be fast enough. Not sure if anyone else has tried this or not (would be great if some one did).

William

maheshkurmi
Posts: 63
Joined: Tue Mar 27, 2012 7:20 am
Location: India
Contact:

Re: Physics simulator based on dyn4j

Postby maheshkurmi » Fri Jan 25, 2013 8:47 am

I tried to port example2D of dyn4j test in android, but it is running slow(as expected). link for apk..
http://code.google.com/p/calc3d/downloads/detail?name=dyntest.apk&can=2&q=

William
Site Admin
Posts: 378
Joined: Sat Feb 06, 2010 10:23 pm

Re: Physics simulator based on dyn4j

Postby William » Sat Feb 02, 2013 2:15 pm

Thanks a lot for testing this out. I don't have an android device to test with.

I would like to know, however, if it was dyn4j that was not performant or Java2D. Did you have any indication of which it might have been? Also, did you try setting the number of velocity/position constraint iterations to a lower number (10 is the default for both). Also, you might try disabling CCD altogether. You can also try some of the other performance enhancements outlined on the wiki.

Willaim


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest