Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / FREE 2D Physics Engine Plugin!

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Sep 2007 18:58 Edited at: 31st Oct 2007 12:09
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:


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.


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:

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

TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 29th Sep 2007 20:30
Sounds great! I will definitely try this out when I get a chance.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Sep 2007 21:21 Edited at: 1st Oct 2007 21:50
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!)


Attachments

Login to view attachments
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 29th Sep 2007 21:54
Awsome work Diggsey. Glad Box2D is workin' for ya now. I'm pretty sure many people will find use of this. ^_^



Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 29th Sep 2007 23:27
Won't run I'm afraid. It keeps popping up an error message asking if I would like to send an error report.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 00:11
I don't know why it would do that...

Are your running a 64-bit version of windows?

aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 30th Sep 2007 00:14
Will it have PIXEL PERFECT COLLISION??

Your signature has been deleted by a moderator because this joke is getting old.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 00:19
@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.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 01:00
I made a small demo alternation to diggseys... Left click for "waiting" creation of boxes... Right click for the MADNESS!


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums

Attachments

Login to view attachments
flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 30th Sep 2007 02:50
I jave the same probelm as teh coder....


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Sep 2007 03:03
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
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 04:07
@TEH_CODERER and flashing snall
I helped diggsey solve his problem (Told you Release mode was better ) with the DLL, as I was having a similar problem... Except it would just close without any message (My computer does that, disabled the error reporting).

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

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 30th Sep 2007 05:08
Looks cool Diggsey!


a.k.a WOLF!
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 30th Sep 2007 05:17
Could you uses polygons?

Your signature has been deleted by a moderator because this joke is getting old.
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 30th Sep 2007 06:03
This looks really cool! But it doesn't work on my computer . It crashes when I try to run it. I hope you can get it to work, because I would really find it useful! Keep up the good work Diggsey!

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 06:34
@H4ck1d
Have you tried running the example I made? It has an executable file with it..


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 30th Sep 2007 07:01 Edited at: 30th Sep 2007 07:07
Oh wow I feel stupid for missing that; I couldn't understand where the fix was that you were talking about . Thanks aaron! It works! This is sweet!

[Edit]?!!!! Wha.... when I compile it myself, it doesn't work! Your compiled version runs, but when I compile it, it crashes... I don't get it!

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 07:13
It's the DLL. I helped diggsey fix it. It has something to do with MSVCD DLL, and changing to MSVCR DLL fixed it.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 30th Sep 2007 07:24
Ohh, I get it. lol. So when will an updated dll be available to use?

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 07:30
Diggsey said (Before going to sleep) that he was going to upload it "tomorrow", which should be today in a few hours.


Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 10:51 Edited at: 30th Sep 2007 10:52
Good guess

Here is the updated version, which will hopefully fix all your problems It ia also less than half the size

@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)

Attachments

Login to view attachments
flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 30th Sep 2007 15:34
yea! it works now. thanks a lot, this is reaaaaaallllly cool. just waiting for the help files now. !!!!


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 30th Sep 2007 15:59
When body's reached 242 it crashed. works nice though.


Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 16:31
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)

aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 30th Sep 2007 16:47
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.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 17:59 Edited at: 30th Sep 2007 18:00
@aluseus GOD
As I have said, you CAN make convex shapes! If you really mean concave shapes, then these are also possible, just by using multiple convex shapes in the same body.

Here is a picture showing what I mean:


Attachments

Login to view attachments
Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 30th Sep 2007 18:17
This looks very cool. Maybe i'll give it a bash someday.

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
aluseus GOD
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: I\'m here. Now I\'m there. I keep moving
Posted: 30th Sep 2007 20:02
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.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 21:04
@aluseus GOD
It's simple to do, but very difficult to program something to do it automatically There are more important things first anyway

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 30th Sep 2007 22:24 Edited at: 30th Sep 2007 22:24
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

Attachments

Login to view attachments
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 30th Sep 2007 22:50
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.
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 30th Sep 2007 23:07
Good job diggsey.

Cheers,

-naota

DBP, $80. DBP's plugins, $320. Watching DBP Crash, Priceless.
NG Website Aex.Uni forums
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 01:13
@MonoCoder
That will be the next thing on my list Can't wait for the editor

@Aaron
Thanks (and for the car)

flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 1st Oct 2007 02:24
this is awsome. its going to add some great effects to par 2d games. bullets will be fun to play with....


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 19:27 Edited at: 3rd Oct 2007 23:49
<irrelevent now>

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 20:50
NEW RELEASE!!!

This release has these features:
Motors
Limits (untested)
Contact list
First two commands which use PARTS

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:


The images needed are attached.

The controls:
Upkey/downkey - Accelerate/reverse
Rightkey/leftkey - Lean forward/backward
Spacekey - Fly straight up in the air

Attachments

Login to view attachments
el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 1st Oct 2007 21:21
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?
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 1st Oct 2007 21:42 Edited at: 1st Oct 2007 21:52
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.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 21:44 Edited at: 1st Oct 2007 21:51
@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

el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 1st Oct 2007 22:16
i got the error when i ran the car demo though.. and ive downloaded the latest files..
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 22:34
Sorry about that, I somehow managed to upload an older version of the .dll
The download should be fixed now

H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 1st Oct 2007 22:48 Edited at: 1st Oct 2007 22:48
It works for me! Thanks a ton diggsey, this actually works great! If you need me to, I'd be glad to do some help on the ini file or some help files as well, whatever you need really. Thanks for the awesome work!

[edit] oh didn't see the second page. Well it works for me either way

el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 1st Oct 2007 22:51
thanks diggsey!

and btw, already started a new 2d project.

i think your doing the community a big favor here, so thanks.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 1st Oct 2007 23:54
@H4ck1d
Helping with the help files would really help, thanks
I added you on MSN, so hopefully I can send you the template for the help files

H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 2nd Oct 2007 00:22
Actually that msn account shown on my profile is restricted use so it might not work. I would add you, but the msn button thingy doesn't show your screen name. Try adding jeffsto - at - jeffsto.com. That one is unrestricted so I'll actually be able to talk to you

flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 2nd Oct 2007 03:42
omg thanks sooo much.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 3rd Oct 2007 00:53
I am allowed to bump this aren't I?

BTW
I'm working on a collision shape editor to make it super easy to make accurate collision shapes for your objects

flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 3rd Oct 2007 02:21
omg thank you. this is sweetness in a buddle of chocolate. if i can get this working right, my game will become waaay better


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 3rd Oct 2007 03:08
Quote: "I'm working on a collision shape editor to make it super easy to make accurate collision shapes for your objects"


Oh, cool, I was about to make one for myself but I guess it's no use reinventing the wheel . Thanks again for this plugin, it's exactly what I needed for my latest project!

On another note, for anyone interested, I tweaked the car example a little bit. You'll need to copy the crate image into the car example's directory.



flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 3rd Oct 2007 05:13
50thpost. reaaaaly cool. but im one of those people who needs a help file.


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/

Login to post a reply

Server time is: 2024-11-24 08:46:35
Your offset time is: 2024-11-24 08:46:35