WIP / FREE 2D Physics Engine Plugin! |
| Author | Message | ||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
This is basically a wrapper (with some extra features like drawing debug information, etc.) for a physics engine called Box2D. It is a WIP, because there are many more features I would like to add before it is completely finished. Also, so that you can suggest features you would like to see added If you like this physics engine, please donate some money to Erin Catto, the engine's creator H4ck1d has kindly offered to work on the help files, and is doing so at the moment. So all credit for those when they're finished to him Here is the current download (Box2D v1.4.1) Here's a screeny of the example two posts down: ![]() There are no help files yet (see above), but I will give a brief explanation of how to use it here (you can get a command list from the keywords file) Before you can start creating things, you need to make a WORLD object. This is basically the container for the simulation. You can have more than one world. Here is code to create a world: + Code Snippet The first four parameters define the maximum size of the world. It is better to make this too large rather than too small. The next two parameters define the gravity X and Y of the world. The last paramter determines whether objects go to 'sleep' when they stop moving (improves performance). The engine is tuned to using metres and radians as the units, so you can use the command b2SetUnits to alter this. You should use this BEFORE any other commands, and it affects all worlds. + Code Snippet This will make it so that each unit is 1/10th of a metre, and so that angles are in degrees rather than radians. It also inverts the angle, because DBP has the point 0,0 at the top left whereas normally it is at the bottom left. An easy way to draw the simulation to the screen is by using the command b2DrawDebugInfo: + Code Snippet The first parameter is the world to draw, the next two define the top-left corner of the world, and the last two are for scaling the output in the X and Y directions. Shapes: Shapes define a collision shape. They can be created with any of these commands: b2CreateCircleShape b2CreateBoxShape b2CreatePolygonShape Body templates: Body templates contain one or more shapes. They are templates for bodies. Bodies: Bodies are created directly from a body template. This allows you to create many identical bodies in the simulation with fewer commands. These are part of the actual simulation rather than just data. To create a body from a body template, use b2CreateBody. To qquickly make a body without worrying about shapes or body templates, use b2CreateCircleBody or b2CreateBoxBody. Joints: These are not fully implemented yet, but you can do simle things with them. They can be created using b2CreateDistanceJoint, b2CreateRevoluteJoint and b2CreatePrismaticJoint. Feedback and suggestions are welcome |
||
| Back to top |
|||
|
TEH_CODERER
User ![]() Joined: Wed Nov 12th 2003 Location: Right behind you! |
|
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
Here is a small demo program to show off the engine To run it without downloading the image, simply comment out the 4th line. The image you need otherwise, is attached. EDIT: Updated to work with current version (also gets rid of jitter!) + Code Snippet |
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
Awsome work Diggsey. Cheers, -naota |
||
| Back to top |
|||
|
TEH_CODERER
User ![]() Joined: Wed Nov 12th 2003 Location: Right behind you! |
|
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
I don't know why it would do that... Are your running a 64-bit version of windows? |
||
| Back to top |
|||
|
aluseus GOD
User Joined: Mon Mar 19th 2007 Location: I\'m here. Now I\'m there. I keep moving |
Will it have PIXEL PERFECT COLLISION?? Your signature has been deleted by a moderator because this joke is getting old. |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
@aluseus GOD There's no such thing as pixel perfect collision in physics engines. They use VECTOR COLLISION. With vector collision, the accuracy depends entirely on the number of shapes and vertices each body contains. Obviously, the more shapes and vertices there are, the longer it takes to check collision against them. |
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
I made a small demo alternation to diggseys... Left click for "waiting" creation of boxes... Right click for the MADNESS! Cheers, -naota |
||
| Back to top |
|||
|
flashing snall
User ![]() Joined: Sat Oct 8th 2005 Location: Boston |
I jave the same probelm as teh coder.... |
||
| Back to top |
|||
|
Zotoaster
User ![]() Joined: Mon Dec 20th 2004 Location: Scotland |
That's truly awesome Diggsey. Could this work with any shape, or does it just work width squares at the moment? "It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers |
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
@TEH_CODERER and flashing snall I helped diggsey solve his problem (Told you Release mode was better In addition to that, it's now only 80KB in size instead of 170~KB. @diggsey Hope it's okay that I post that. Cheers, -naota |
||
| Back to top |
|||
|
Ron Erickson
Moderator ![]() ![]() Joined: Fri Dec 6th 2002 Location: Pittsburgh, PA, USA |
Looks cool Diggsey! ![]() a.k.a WOLF! |
||
| Back to top |
|||
|
aluseus GOD
User Joined: Mon Mar 19th 2007 Location: I\'m here. Now I\'m there. I keep moving |
Could you uses polygons? Your signature has been deleted by a moderator because this joke is getting old. |
||
| Back to top |
|||
|
H4ck1d
User ![]() Joined: Tue Dec 27th 2005 Location: Yes |
|
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
@H4ck1d Have you tried running the example I made? It has an executable file with it.. Cheers, -naota |
||
| Back to top |
|||
|
H4ck1d
User ![]() Joined: Tue Dec 27th 2005 Location: Yes |
|
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
It's the DLL. Cheers, -naota |
||
| Back to top |
|||
|
H4ck1d
User ![]() Joined: Tue Dec 27th 2005 Location: Yes |
|
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
Diggsey said (Before going to sleep) that he was going to upload it "tomorrow", which should be today in a few hours. Cheers, -naota |
||
| Back to top |
|||
|
Google Ad
AdBot Joined: Aug 26th 2002 Location: Everywhere |
|||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
Good guess Here is the updated version, which will hopefully fix all your problems @Zotoaster + aluseus GOD This will work with any convex shape with 3 to 8 vertices by simply by using the polyhon shape commands. To make concave shapes or shapes with more than 8 vertices, you have to make multiple convex shapes, and attach them all to a body template. If nobody has done it already by the time this is nearly finished, I will probably make an editor to make it easier to make collision shapes for an image @Everybody Thanks for the feedback, and this is still a long way from being finished, so look out for the following: - More types of joint - Limiters on joints - Motors on joints - Setting friction on individual shapes (means multiple frictions per body are possible) - Anything else that gets added to the Box2D engine (it is still in active developement) |
||
| Back to top |
|||
|
flashing snall
User ![]() Joined: Sat Oct 8th 2005 Location: Boston |
yea! it works now. thanks a lot, this is reaaaaaallllly cool. just waiting for the help files now. !!!! |
||
| Back to top |
|||
|
Silvester
User Joined: Wed Dec 7th 2005 Location: Netherlands |
|
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
I have nearly finished a version with motors and limiters, so later today it will be released. (I will make a demo with a car that you can drive up ramps and things as well |
||
| Back to top |
|||
|
aluseus GOD
User Joined: Mon Mar 19th 2007 Location: I\'m here. Now I\'m there. I keep moving |
hey diggsey, can you add support for convex shapes? Please? I mean is it really that hard? Oh could you add more useful things like: Character/Enemy Creation Character Gravity and Physics Your signature has been deleted by a moderator because this joke is getting old. |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
@aluseus GOD As I have said, you CAN make convex shapes! Here is a picture showing what I mean: |
||
| Back to top |
|||
|
Mr Tank
User Joined: Mon Nov 25th 2002 Location: United Kingdom |
This looks very cool. Maybe i'll give it a bash someday. |
||
| Back to top |
|||
|
aluseus GOD
User Joined: Mon Mar 19th 2007 Location: I\'m here. Now I\'m there. I keep moving |
No, I mean, if its that simple, cant you build it in? Your signature has been deleted by a moderator because this joke is getting old. |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
@aluseus GOD It's simple to do, but very difficult to program something to do it automatically |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
Here is a screeny of a demo I made with the new commands It drives with a motor applied to the back wheel joint. You can control the car with the arrowkeys and spacebar, and hopefully I will be able to release the new version of the plugin so that you can compile it soon |
||
| Back to top |
|||
|
MonoCoder
User ![]() Joined: Sun Dec 4th 2005 Location: Sc-nthorpe a la cesspit |
This is good, I'm whipping up an editor and some simple level sprites, and using this plugin to make a quick and easy mario land-esque game. One thing though- is there a way to return collision against individual collision lines? For example, if I had some spikes, could I make it so the player was hurt only if he landed atop them? Keep it up! EBA: A banner coming soon. Then maybe a game. |
||
| Back to top |
|||
|
Aaron Miller
User ![]() Joined: Sat Feb 25th 2006 Location: Behind the trusty dumpster. |
Good job diggsey. Cheers, -naota |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
@MonoCoder That will be the next thing on my list @Aaron Thanks |
||
| Back to top |
|||
|
flashing snall
User ![]() Joined: Sat Oct 8th 2005 Location: Boston |
this is awsome. its going to add some great effects to par 2d games. bullets will be fun to play with.... |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
|
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
NEW RELEASE!!! This release has these features: Parts are just like shapes, but they are the shapes after they have been added to a body. This allows you get extra information about collision, and also change settings on a per-part basis for each body. This will probably be finished by next release You can download the latest .dll and .ini file from the top post Here is the code for the car example from above as promised: + Code Snippet The images needed are attached. The controls: Upkey/downkey - Accelerate/reverse Rightkey/leftkey - Lean forward/backward Spacekey - Fly straight up in the air |
||
| Back to top |
|||
|
el zilcho
User Joined: Mon Dec 4th 2006 Location: Cyberspace |
parameter mismatch in expression 'b2createboxbody' at line 18. otherwise, this is very cool! the reason i gave up on my last 2d platformer is because i couldn't find any way to make 2d physics. do you think you will be able to fix the way the crates vibrate, so that they actually come to a complete halt? |
||
| Back to top |
|||
|
MonoCoder
User ![]() Joined: Sun Dec 4th 2005 Location: Sc-nthorpe a la cesspit |
I get parameter mismatches at lines 14-17 and 24-25, and commands not understood at lines 38, 48-49, 52-53 and 55. On commenting all of these out, the program compiles then crashes immediately with a dialog box stating that it "Failed to load DLL (4: PhysicsPlugin.dll)." edit: this is with the latest version, using the example two posts above. EBA: A banner coming soon. Then maybe a game. |
||
| Back to top |
|||
|
Diggsey
User Joined: Mon Apr 24th 2006 Location: On this web page. |
@el zilcho That was just an error I made with the SetUnits function. Set it to 0.1 or 0.01 and you will see that objects go to 'sleep' when their velocity goes under a certain amount. Later versions will have the option to set this amount directly Your error is because I have not updated that example to the current version. Try the example two posts up, it is much better anyway edit: I have updated that example now |
||
| Back to top |
|||
|
el zilcho
User Joined: Mon Dec 4th 2006 Location: Cyberspace |
i got the error when i ran the car demo though.. and ive downloaded the latest files.. |
||
| Back to top |
|||
This is a multi-page thread older than 30 days.
Go to the last page to check if you can reply to it.
Go to the last page to check if you can reply to it.
Forum Search
Enter a word or phrase to search our Forum for:
|
|



















