Physics mods?
Monkey Archive Forums/Monkey Discussion/Physics mods?
| ||
What's the best physics mod for Monkey? Seems to be just Chipmunk and Box2D? I tried Box2D but the demo code does not compile (there is no Function Main()), and I can't be assed to fix it - be nice if stuff worked out-of-the-box! Any recommendations? Fancy having a play around with physics. |
| ||
You could checkout flixel, which has basic physics. I think there is a box2d screen/scene in playniax? |
| ||
to quote ilovepixel: To run the demo of box2d create a new monkey file and write: Import box2d.demo Function Main:Int() New MainDemo() Return 0 End ...and more monkey Box2D demos at the end of this thread: http://monkeycoder.co.nz/Community/posts.php?topic=1704 |
| ||
...also fantomEngine (MikeHart) is working on a Box2D integration. not sure how far along he is. |
| ||
There is although Fling, a port of the physaxe 2D physics library. http://www.monkeycoder.co.nz/Community/posts.php?topic=580 |
| ||
Sounds like you tried to run the actual Box2D file? You need to do what Adam says and it should all work fine. There is a Box2D scene in Playniax, but it is just using the existing Box2D mod, it is not tied into the Framework. |
| ||
I ran the one called 'demo.monkey', which imported 'maindemo.monkey', so I thought it'd run by doing that. I'll try out the above suggestion. |
| ||
From the homepage: "See the QuickStart page for instructions on getting the demo running." Where "QuickStart" is a link: https://code.google.com/p/monkeybox2d/wiki/QuickStart |
| ||
I also highly recommend reading the box2d manual, since it steps you through the basic terminology and concepts of the engine, including a "hello world" app. This is what I used to start learning it! Just be aware there are a few subtle differences between the official box2d version, and the one that Monkey uses: 1. CreateFixture doesn't have 2 overloads, there is a separate CreateFixture2 method for making a fast fixturedef from a shape. 2. (For now), the const b2_dynamicBody in box2d.Monkey is just b2_Body. |
| ||
All working now... incredibly hard to follow with all those demos rolled into one, though. Think I'm starting to understand the basics now. Thanks! One thing bewilders me, though. I've just been playing around with stuff using DrawDebugData. Suppose I have a 64x64 image of a crate, what's the approved way of creating a box2D "body" appropriate to the exact size of the image? |
| ||
You can use PhysicsEditor: http://www.codeandweb.com/physicseditor I haven't updated the last view month, but exporting to Box2d generic xml is pretty buggy. I have to flip the shapes vertically and have do some manual adjustments to get it working. Some helping code here: http://www.monkeycoder.co.nz/Community/posts.php?topic=3106 |
| ||
Hm, thanks!! Oddly enough, I bought TexturePacker from there a few weeks ago. Wasn't bothering with physics at the time though, so I didn't notice PhysicsEditor. |
| ||
Suppose I have a 64x64 image of a crate, what's the approved way of creating a box2D "body" appropriate to the exact size of the image? It's entirely up to you how you scale from the physics units to your screen pixel units. You shouldn't attempt to scale the physics objects up to match a desired pixel size. Box2D functions best with objects from roughly 0.1m to 10m in either dimension. I'd suggest deciding how physically large you want the "crate" to be in the simulation and then scaling that size in meters to 64 pixels. |
| ||
Thanks, but I don't really understand. Surely the object in the simulation needs to match the pixel dimensions of the graphic it represents? I haven't attempted anything with "proper" physics before so I am (clearly) a complete idiot on the subject, and would like the methodology to be explained to me with that in mind, if you could. :) |
| ||
I found these videos a while ago: http://www.kerp.net/box2d/ If you want to measure everything in pixels you could do: Const RADIO:Float = 30 and then divide everything by that value. |
| ||
The physics simulation doesn't measure size in "pixels". It's in meters. If you have a 1m wide crate and you want to draw it using a 64-pixel square image or as a 64 pixel square box then you just scale the physics world by 64 when rendering. The Demo debug draw has a SetDrawScale Method for doing just this. |
| ||
Gfk, you should read this thread: http://www.monkeycoder.co.nz/Community/posts.php?topic=3106 CopperCircle has added some scaling to his box2d framework. Take a look at it to get started. |