Hello,
Here's my adaptation of JBox2D, the popular Java physics engine (and probably one of the best available). This is not a wrapper around the library but an adaptation to B4A. Pro: no impact on performance. Con: the object initialization is a bit loose (some objects are initialized with a simple Dim, some need a call to the Initialize function; and IsInitialized is not implemented).
The source code is available below.
The documentation can be found on the net:
Box2D manual
The JBox2D site
If you want to know what JBox2D can do for you, download the testbed or try the twelve examples provided with the library.
Beta 2:
I fixed the issue with Next. Next for bodies is renamed NextBody, and Next for fixtures is renamed NextFixture.
Beta 3:
I fixed the remaining issues with Next. Next for contacts is renamed NextContact, and Next for joints is renamed NextJoint.
I added four events: BeginContact, EndContact, PreSolve, PostSolve. To take them into account, use the jbWorld function: setContactListener.
1.0:
I updated the code with the latest version available (2.2.1.2). There are many changes and bugfixes since the beta version.
I ported also ten "official" examples.
1.1:
I added three classes: jbQueryCallback, jbTreeCallback and jbTreeRayCastCallback;
I added a class, jbBodyEditorLoader, that allows to load JSON files created by Physics Body Editor v2;
I added two new examples (Web and Physics Body Editor Loader).
About the examples:
All examples provided with this library may run very slowly on your device because:
1) These examples use a drawing method (drawDebugData) that is convenient but very slow;
2) The interval between each step is set to a high value.
I tried to keep the original settings, so you'll get the same result as in the testbed, but these settings are too demanding for our pocket devices.
You need the Accelerated Surface library to run the examples.
Here's my adaptation of JBox2D, the popular Java physics engine (and probably one of the best available). This is not a wrapper around the library but an adaptation to B4A. Pro: no impact on performance. Con: the object initialization is a bit loose (some objects are initialized with a simple Dim, some need a call to the Initialize function; and IsInitialized is not implemented).
The source code is available below.
The documentation can be found on the net:
Box2D manual
The JBox2D site
If you want to know what JBox2D can do for you, download the testbed or try the twelve examples provided with the library.
Beta 2:
I fixed the issue with Next. Next for bodies is renamed NextBody, and Next for fixtures is renamed NextFixture.
Beta 3:
I fixed the remaining issues with Next. Next for contacts is renamed NextContact, and Next for joints is renamed NextJoint.
I added four events: BeginContact, EndContact, PreSolve, PostSolve. To take them into account, use the jbWorld function: setContactListener.
1.0:
I updated the code with the latest version available (2.2.1.2). There are many changes and bugfixes since the beta version.
I ported also ten "official" examples.
1.1:
I added three classes: jbQueryCallback, jbTreeCallback and jbTreeRayCastCallback;
I added a class, jbBodyEditorLoader, that allows to load JSON files created by Physics Body Editor v2;
I added two new examples (Web and Physics Body Editor Loader).
About the examples:
All examples provided with this library may run very slowly on your device because:
1) These examples use a drawing method (drawDebugData) that is convenient but very slow;
2) The interval between each step is set to a high value.
I tried to keep the original settings, so you'll get the same result as in the testbed, but these settings are too demanding for our pocket devices.
You need the Accelerated Surface library to run the examples.
Attachments
Last edited: