Chipmunk 2D Physics Module
BlitzMax Forums/Brucey's Modules/Chipmunk 2D Physics Module
| ||
Just a short note to say I've finally built a proper release of the chipmunk module. Chipmunk is a fast, cross-platform 2D Game Dynamics/Physics engine, written in C. The module comes with 7 small demos that highlight the various features of the library. You can download the module from here : http://maxmods.googlecode.com Note : You *will* need to compile the module using my "tweaked" BMK, since the library source requires it to be compiled in a specific way. You can get the BMK source and instructions from HERE. Hopefully this is only a temporary requirement (fingers crossed for 1.28... ;-) As usual... please let me know if you have any issues or comments, and perhaps ideas for improvements. :o) |
| ||
I did a checkout of your chipmunk module from svn, and there is a folder "chipmunk.mod" with the same content as the parent folder. A mini commit "bug" perhaps? ;) hehe Btw, module and examples compiled fine, cant wait to play with this when i have the time =) |
| ||
Thanks Brucey - this is exactly what Ive been looking for. I was thinking of wrapping box2d but it's a bit @.@ Looks like Scott took the best parts of it (algos) for Chipmunk and you've done the wrapping. happy times. |
| ||
Thanks for posting this, maybe people will actually see this now. A quick look through this release, and I think cpBodySetTorque is still missing. I have implemented this before, do you want the code? |
| ||
there is a folder "chipmunk.mod" with the same content as the parent folder. Thanks.. my feeble attempt at tagging the code... guess I should pay more attention to the options :-p |
| ||
Hi Brucey :) Glad to see that ! but the problem is ? how to compile this module ? L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/chipmunk.c:22:20: stdlib.h: No such file or directory Build Error: failed to compile Note : My BMK is ok, and mingw installed correctly... :) Any idea ? |
| ||
Hey Filax.. try commenting out that include for now... Is working fine here. It was added recently to the library source, but as far as I know, it's a pretty standard header file. Anyone else having trouble on Windows compiling the module? |
| ||
This is a great lib.. and it's blazingly fast!! :) |
| ||
I agree Lars. I think we found our 2d physics lib! |
| ||
Working fine here on Leopard : ) Great mod Brucey! - David |
| ||
Hi Brucey :) My mod install : C:\BlitzMax\mod\bah.mod\chipmunk.mod (im wrong ?) I have no other explains to say only this message : Building Modules Compiling:chipmunk.c L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/chipmunk.c:22:20: stdlib.h: No such file or directory Build Error: failed to compile L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/chipmunk.c Process complete MY MingW work correctly, and your new bmk was compiled with success and copied under the good directory Or more simple, anybody can post a link with a PC compiled version ? :) |
| ||
Hey Filax... try this : change line 22 of src/chipmunk.c from #include "stdlib.h" to //#include "stdlib.h" And see if that works. Are you the only Windows user then? :-p |
| ||
What it kind of needs now is a slightly higher level API to make building complex shapes easier etc. Demo2 shows it's quite easy to draw an image where the shape is, since a Shape/Body exposes both its location/rotation, as well as the vertices and their rotations. |
| ||
A quick look through this release, and I think cpBodySetTorque is still missing. Are you sure? I can't find that. I added applyimpulse, slew, and applyforce recently. Hmm... of course, you might just mean that I haven't exposed the variable for changing... ;-) |
| ||
I just compiled and ran the demos in XP. What a fun module! - David |
| ||
Brucey my apologies, yes there is no method for setting Torque in this release, there might have been before, I don't remember. I do know that the buggy demo set torque in order to simulate motor functionality though. So maybe you could just create a SetTorque method for the body class (granted you would need to expose it in glue somewhere). |
| ||
Yes Brucey i'm windows only So, for the problem i have try to remove all stdio.h under the sources. But other problems are coming :) referring to other missing include like math.h, string.h etc Example: L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c:23:18: math.h: No such file or directory L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c:24:19: float.h: No such file or directory L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c: In function `cpBodySetAngle': L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c:90: `M_PI' undeclared (first use in this function) L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c:90: (Each undeclared identifier is reported only once L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c:90: for each function it appears in.) Build Error: failed to compile L:/BlitzMax/mod/bah.mod/chipmunk.mod/src/cpBody.c |
| ||
maybe you could just create a SetTorque method Added... will commit shortly :-) Should we add the buggy demo to the module, do you think? |
| ||
Might be nice, but even nicer would be higher level API, like you mentioned. I've been working on one in my free time. |
| ||
Filax, your MinGW isn't working properly. Either your paths are wrong, or it is missing some vital files. Did you follow Mark's instructions HERE to ensure you got all the packages you need? It sounds, according to your error messages, like you are missing the headers - rather vital when it comes to building C/C++ :-) |
| ||
I got this working now and it's astounding and blazingly fast. I'm not gonna try to do anymore 2d physics code. I'll just spend my time working on actual games? Yeah that sounds like a plan. Thanks Brucey. Superb work. I vote this the Unofficial 2D physics solution for BlitzMax. |
| ||
works great here on WindowsXP no modifications other than replacing the bmk. Thanks! for a great mod. |
| ||
Hi brucey , i'm fighting with vista and mingw.... Bmax now won't compile any module :( http://www.blitzbasic.com/Community/posts.php?topic=72892 Anybody can tell me where i'm wrong ? |
| ||
This Chipmunk module is great fun! Now to just figure out how to get the rotation so I can put an image of a crate over the square box in demo1! And proper timing. |
| ||
Filax did your remember this extra bit for Vista... "An addition to Vista users. You must also create a new Variable called "MinGW" and set it to c:\MinGW. After I did that I was able to build modules. [edit] Under User Variables Click New and name it MinGW. Set its variable to wherever you installed MinGW." |
| ||
Now to just figure out how to get the rotation Have a look at main2.bmx - drawPolyShape(). Shows getting the body position and angle. Angle is returned in degrees, for your convenience. Notes : Objects like Body and Shape are reference counted for you, so you don't have to keep a reference to all of them yourself if you don't want to. Therefore, when you want to remove an object from the space you need to "free()" it. This will remove it properly from the space. Note too, that you also need to free() all related shapes/joints too... perhaps this is an enhancement we can have later - whereby the module will free the related parts for you. At the moment, it mirrors the functionality of the library... You also need to be wary *when* you free() something. For example, freeing an object from a collision function is not advised, since the library is still using them at that point. You should rather flag up that something needs freed and deal with it at the end of the DoStep()/update process. |
| ||
Ian Thompson : I do ! :) Anyone can post a compiled module for pc ? :) |
| ||
MinGW on Vista need an extra %GCC_EXEC_PREFIX% thing. http://wiki.codeblocks.org/index.php?title=MinGW_installation Anyway this is the compiled from Brucey's distro: http://icworx.org/_spc/chipmunk.mod.zip (Keep for few days) |
| ||
Great work. Is the SVN checkout as up to date as the download? I've really come to like SVN update, where I just rightclick the mod folder and update. (I'm using TortoiseSVN on Windows, and scplugin on the Mac for anyone looking for easy to use SVN clients) |
| ||
Is the SVN checkout as up to date as the download? SVN will always be the same or better than the latest available full release :-) |
| ||
yoko : Many thanks ! Vars added correctly but i'm alway bugged with vista :( VARS : GCC_EXEC_PREFIX => c:\MinGW MinGW => c:\MinGW PATH : C:\MinGW %GCC_EXEC_PREFIX%\libexec\gcc\mingw32\3.4.5 %GCC_EXEC_PREFIX%\lib\bin i have try to add too: %GCC_EXEC_PREFIX%\include Great wrapper brucey :) very fun :) |
| ||
This is amazing stuff... Cheers Brucey! BTW: Let's hope Mark uses your revised BMK in the next release. |
| ||
Filax, fix PATH, C:\MinGW\ to C:\MinGW\bin |
| ||
Hi Zeke :) The problem continue... But i have find a temporary alternative with blide :/ Fu.. Vista... |
| ||
Just in case anyone still needs it here is the compiled mod for windows: http://www.gigasize.com/get.php?d=gj21cvkn55c Edit: Nvm someone beat me to it. |
| ||
Looks very interesting, I'll definitely file a copy of that one away. Hey, Brucey: Any chance of a good A* pathfinding mod at some point in the future? :-) |
| ||
Any chance of a good A* pathfinding mod at some point in the future? Heh... there's actually a very fast algo on the forum somewhere, in Spanish. It uses arrays and whotnot, rather than Types based like the example that comes with BlitzMax. I hacked it into a big tower-defense type game I made, and it easily handled a few hundred objects navigating a large maze. But not really my forte though. If you can find a lightning fast pathfinding library out there, I could always wrap it ;-) |
| ||
SVN will always be the same or better than the latest available full release :-) Great. Works perfectly on my Intel MacBook and Windows XP. |
| ||
I think I need someone to take me by the hand and tell me what I'm doing wrong. I've tried the compiled Windows versions posted by yoko and altitudems, but all I'm getting are the error; Compile Error Can't find interface for module 'bah.chipmunk' It's placed in this folder which should be correct...me thinks... C:\Util\BlitzMax\mod\chipmunk.mod\ |
| ||
I should probably make the instructions on the module page better... The path should be : C:\Util\BlitzMax\mod\bah.mod\chipmunk.mod\ |
| ||
Thanks Brucey, That helped...a little. Still doesn't work though. Now I'm getting half a screen of errors saying 'undefined reference' to different things. I'm still v1.24 running though. Will it help if I upgrade to v1.26? |
| ||
get 1.26 then go here http://www.blitzbasic.com/Community/posts.php?topic=72892 |
| ||
Hi, I have just brought BlitzMax and have no idea what im doing. I copied the compiled mod thats posted above and then tried to build & run demo1.bmx but I just get: Build Error: failed to compile in Blide? What am I doing wrong,or do I need to learn the basics first somewhere? Thanks. |
| ||
Thanks Nino, The upgrade made it work...that'll teach me to update faster. :-) (the link don't work though) Now the big problem is 'only' coming up with a game that could benefit from this. :-) |
| ||
Brucey, I compiled your bmk.exe and put it into my BlitzMax bin folder. Now, when I build all modules with BLIde, I get a bunch of popup console windows. One for each module that is building. Is this something I can turn off? Edit: Nevermind, I built it as a GUI app. After fixing that, it is no longer doing it. |
| ||
he coppercircle its not needed to know the bmax language to run the demos same as in b3d if you know what i mean. the demos must run without any language knowlege but its better to know what you do....... dontknow about blide, but it must be work with the standard IDE works here like a charme , runs smooth and looks cool thx |
| ||
This thing has never worked for me. I have the compiled mod, the compiled bmx. None of the demos work. |
| ||
I have installed new mingw, rebuilt all modules, installed the bmk.exe which I compiled from your site and it still fails to build any example demo code. Runs normal code fine. |
| ||
Did you install Chipmunk from their site? |
| ||
That's strange... the compiled version doesn't need MinGW to work unless you want to re-build Did you put the module in <BlitzMax_Dir>\mod\bah.mod\cipmunk.mod ? |
| ||
Brucey - did the fix to freeing shapes ever get pushed to http://maxmods.googlecode.com ? (yeah- i know i could just go check but im lazy) |
| ||
Yep. There's a 1.01 release available with the latest fixes. |
| ||
Holy cow! This is it, guys! Mark, when this baby is completely beta-tested.... P L E A S E !!!!! include it as part of the standard BMax distribution! Anyone object to this course of action? Didn't think so ;) Russell |
| ||
I don't get it? Where is the actual Bmax module? with the bmx files? All I can download is the c version, or am I being silly? |
| ||
Ah, I have it, needed to click on the download part, it doesn't go straight to it, so it's a little confusing :) It sounds silly but it had me running around in circles. |
| ||
I don't suppose someone has a compiled example of this module? I'd be interested to see it :D (not on a suitable machine to install bmax) |
| ||
It is already compiled in the downloads section, the google bit. Just download the file with win32 written on it. |
| ||
This is a great looking physics engine, but it seems geared around sideways physics, what about top down physics, how hard would it be to do this? for example a top down car game. If it can are there any examples? Thanks. |
| ||
cheers verfum, but I mean like a running demo of what it can do (without having to compile from within bmax) |
| ||
This is a rough video of a new engine/framework I'm working on for future physle games. http://www.physle.com/images/newengine.avi |
| ||
Do all these 2D physics engines only come with side on examples? |
| ||
Certainly looks that way. Doing top-down physics is a different thing altogether. According to the author of Chipmunk it's perhaps not yet entirely suited to top-down games, but it's not impossible to do. This ruby tutorial touches on doing top down with chipmunk : http://code.google.com/p/gosu/wiki/RubyChipmunkIntegration |
| ||
Chipmunk work pretty well for simple top down - just dial gravity down to zero. This was my first shot at using it for a simple billiards sim. Definitely primitive but maybe worth a look. |
| ||
I'm having fun with Chipmunk ! Thanks a lot Brucey :) Today i discovered box2D v2.0 (well almost feature complete for 2.0) as Chipmunk is inspired by (or based on) Box2D does this make it a more featured physic engine ? Does anybody know the big differences between these engine ? I wish i could try this by myself but there is no BlitzMax port actually. The only 2 stuff i would like being optimized with Chipmunk is : - Elastic shapes don’t stack well (known problem) - No swept volume collisions (known problem) Box2D is more often updated with big features and a bigger community too. What do you think about it ? |
| ||
Perhaps it's worth wrapping it also.... to give us more choice? :-) |
| ||
I don't know, since i don't have the talent require to do so... But i would like to ! :-) I'm reading the "old" manual right now and it's quite interesting. By the way Brucey, impressive collection of modules! If i knew at that time you would add wxWidgets i'll surely donate rather than buying MaxGUI... |
| ||
Rather than start a new thread I thought I'd post this here... I haven't really had a chance to explore the module yet but is it possible to use chipmunk in a scrolling game? would you have to move all physical bodies individually or can you move the physic space with the game world as it scrolls? |
| ||
you can absolutely use it in a scrolling environment. The way i do it is through SetOrigin but there are a number of ways you could accomplish this. Chipmunk really stays away from any type of rendering routines so it's really up to you how you want to implement it. This is one of the things I really like about it. |
| ||
Thanks for the reply :-) It's funny because literally 5 minutes ago I also discovered that I could do this by altering the origin with SetOrigin. This looks to be such a versatile system. I'll definitely look into using it for a game project soon! |
| ||
For those who wonder what big points Box2D v2.0 has to offer i can tell you this : - Continuous Collision Detection (no more object passing through walls !! - Callback Collision - Bouncy object stack correctly (known bug of Chipmunk) - Manual/wiki/Community and a nice roadmap ! I'm so impatient to play with this ^^ |
| ||
Any beginner tutorials with this? (confused at the moment, demo's don't make sense) but it certainly looks good! |
| ||
I made a new entry on my blog about a "sand-box" software using Chipmunk. http://arm42.free.fr/blog/index.php Thanks a lot for your wrapper Brucey, i'm having fun ^^ |
| ||
Nice demo :-) I like the chain-links. |
| ||
Yes, great demo. I could see that "squid" thing as the star of an R-type style shooter. The more powerups you have, the longer the tail. Well done! |