Page 1 of 3
Box2D for ZGE
Posted: Wed Feb 17, 2010 9:54 pm
by diki
An adaption of the
Box2D Physics Engine for
ZGE 1.1.9b.
Visit the Project Page on Google Code!
Version 1 Features:
- - World (with Gravity)
- Static and Dynamic Bodies (rudimentary)
- Box Shapes
See the included demo projects for information on the intended usage (more detailed documentation will be crafted for later versions with more features :P).
Posted: Fri Mar 05, 2010 2:59 pm
by jph_wacheski
How is this going Diki,. need any testing?
I was messing around with Pocket Physics for the DS [
http://tobw.net/index.php?cat_id=3&proj ... et+Physics ] the other night and realised it too uses Box 2D,. it is fun just to build crazy Rube Goldberg machines and watch the sim work out the physics,.. . <pineing>
Posted: Fri Mar 05, 2010 9:43 pm
by diki
Uhm, it's a bit on hold currently, but I'm still planning to include at least Circles & Custom Shapes as well as Joints (everything you need for a car ;)).
Posted: Sun Mar 07, 2010 12:44 am
by diki
put it up on google code... please excuse the messy sourcecode for now :P
Posted: Tue Mar 09, 2010 4:37 am
by y offs et
Here's a twist. Use the RMB to generate a tiny block between the base and big block.
Posted: Thu Dec 05, 2013 11:05 am
by Rado1
Hi all,
I had a quick look at the current features of Box2D and see the following possible improvements of Box2DZGE:
1. update to the current Box2D library,
2. add more features of Box2D, e.g., more shapes, more properties for bodies, fixtures, joints, sensors, contact detection, raycasting, ..., and
3. compile also for Android.
Question: would anyone like to use such updated Box2DZGE? If so, Diki, can you continue with implementation? If not, then I can.
Waiting for your opinion.
Posted: Thu Dec 05, 2013 2:03 pm
by jph_wacheski
That is curious, I was just wondering last night if anyone had advanced to Box2d any further,. and I was going to ask!
Yes, I would be interested in using Box2d,. as it is slightly easier to work with than trying to limit our fully 3d physics option down to 2d. So, for many 2d and/or simple games, it would be my choice if it was ready to use.
Posted: Thu Dec 05, 2013 2:17 pm
by Rado1
Ok Jph, I'm going to have a look at it. I'll probably start building a new library from the scratch in VS2010. Or Diki do you think I should continue with your project in Code::Blocks?
Posted: Fri Dec 06, 2013 11:34 am
by VilleK
Rado1, maybe if you post an issue on the Google code page then Diki will be notified? He probably does not check this forum regularly.
Posted: Fri Dec 06, 2013 3:49 pm
by Rado1
VilleK wrote:Rado1, maybe if you post an issue on the Google code page then Diki will be notified? He probably does not check this forum regularly.
Good idea Ville, I sent an issue to Google code page and waiting for reply.
Anyway, in meantime I created own Box2D library adapter which uses the latest version of Box2D. I created it from the scratch, but of course was inspired by the original library from Diki. In addition to the original dll, it allows to specify also rotations of boxes. This is just an example of how simple it can be extended. See the attached ZGE project and dll.
Next steps:
1. Compile for Android.
2. Rethink and rework the API to ZGE to add more features.
3. Create better demos.
4. Put to Google code.
Remark: Just notice how small is this dll, half of size of the original one. Of course, it will grow with features.
Posted: Fri Dec 06, 2013 7:39 pm
by Rado1
I'm glad to announce that we have Box2D for ZGE running on Android! I also added explicit destruction of bodies and the simulation world (click LMB or tap in the demo application). Some more improvements will come later.
BTW any comments and suggestions are welcome; eg., what are your preferences for new features.
Posted: Sat Dec 07, 2013 12:13 am
by jph_wacheski
SetLinearVelocity and SetAngularVelocity to get started,. or ApplyForce, ApplyImpulse, ApplyTorque,. not sure the difference,. I am just glancing at an API page,. . A way to get collision data back will be useful as well. So b2ContactListener looks like,. .
I will need to mess with it a bit and learn how the system works more I suppose. If you will add more basic functionality,. I will help with examples and stuff.
Posted: Mon Dec 09, 2013 9:54 pm
by Rado1
I started to implement collisions and would like to know what collision detections would be most useful for you. I already implemented getting of all contacts in the world and contacts of a single body. Contacts are obtained one-by-one by consequent function calls. A contact comprises collided bodies, and collision point. I can also add collision state (new or persisted), normal, normal impulse, tangent impulse and separation. Maybe just state can be useful. For a single body, functions for number of collisions and boolean test whether it is collided are also provided. The proposed/current functions:
Code: Select all
void zb2PrepareAllContacts() {}
// return 0 - no other contact; 1 - next contact returned
int zb2GetNextContact(ref int bodyA, ref int bodyB, ref float x, ref float y) {}
void zb2PrepareBodyContacts(int body) {}
// return 0 - no other contact; 1 - next contact returned
int zb2GetNextBodyContact(ref int body, ref float x, ref float y) {}
int zb2IsCollided(int body) {}
int zb2GetBodyContactCount(int body) {}
I'm asking you because the implementation is still not mature enough and I do not want to spent some time with useless functionality.
Posted: Thu Dec 12, 2013 3:25 pm
by jph_wacheski
I have not had time to look into the box2 implementation much yet, so I am just guessing,. ( someone hacked my site,. wrecked up my wordpress install
it is always something,. . )
anyway, looking here;
http://www.box2d.org/manual.html#_Toc258082970
there is a lot possible! Of course, just having circular bodies and raycasts could be enough for a good game, so anything more is gravy.
I will go about the game design based on what you make available, for example "Chain Shapes" would make level design very different than the array based levels i am using for my current project.
Basically, I do not have a particular design in mind, and will instead experiment to see what is possible from whatever you come up with, and how it preforms.
Posted: Sun Dec 15, 2013 8:06 pm
by Rado1
Next version of ZGEBox2D library is here. It provides the following functionality:
- creating and destroying the simulation world, stepping the simulation, and global clearing of forces
- dynamic setting of global properties: gravity, sleeping of inactive bodies
- support for static, kinematic and dynamic bodies
- box, circle, polygon and edge shapes
- setting of body properties: position, rotation, linear and angular velocity, linear and angular damping, friction, gravity scale, activation/deactivation, setting as bullet (fast moving object), and mass properties
- getting of body properties: position, rotation, awakening detection and overlapping with point
- reliable global collision detection (obtaining info about contact points)
- simple body collision detection (can be improved in future, if required)
- global raycasting
All these features run also on Android. See the attached demo project with Windows and Android versions of the ZGEBox2D library. The demo shows static and dynamic shapes, global collision detection, test on "mouse over" and it is also possible to drag/drop the selected body.
Even if it is still a testing version, it can be used for your trials, demos and games. Its performance is quite good. Please try and give me your feedback.
In near future I'm going to work on the following features:
- chain shape (maybe with lower priority)
- joints (Box2D has various really nice and useful joint types)
- moving the sources to Google code
Any comments are welcome!