2d Polygon collision Module
Community Forums/Showcase/2d Polygon collision Module
| ||
This is a Polygon Collision module that uses code written by Gosse Corrupted (ported from Blitz to BlitzMax) Unzip the attached files to your "BlitzMax Directory\mod\" There is a demo in the zip file. http://www.indiepath.com/tim/indiepath.mod.zip |
| ||
you know, I really need line collision as I am doing a platform game, so this will be a great help I think. However I placed the mod in blitzmax\mods and tried the demo but it wouldn't work |
| ||
Skunk, What error is BMAx giving you? |
| ||
i have an error, too: [ERROR]: Compile Error:Can't find interface for module 'indiepath.poly' (using protean for blitzmax) |
| ||
Does your path look something like this? Blitzmax\mod\indiepath.mod\poly.mod |
| ||
I've uploaded a new file which might work :) |
| ||
sniff, still the same error. i double checked the paths etc. but it didn't help... |
| ||
I am now confused. I can only replecate your error if I move the files elsewhere. Have you had any problems with other Modules? |
| ||
Simply put the directory "indiepath.mod" in the mod folder of Bmax. Nice work! ;) |
| ||
Yeah, someone got it working.. and they did exactly what I originally said ?!?! |
| ||
I get this error: [ERROR]: Unhandled Exception: Unhandled Memory Exception Error It compiles fine, but the example crashes. [ERROR]: Poly_AddVertex [C:\BlitzMaxBeta101\mod\indiepath.mod\poly.mod/poly.bmx;56;19] [ERROR]: testpoly [e:\programmer\blitzmax\mod\indiepath.mod/testpoly.bmx;11;1] |
| ||
Ouch, that looks to me like a problem with types. But why does it run okay for me, Extron and others that have tested it for me.??? Source is now posted in the zip file, perhaps someone can work out the problem and let me know. |
| ||
Well, i clarify my previous post. :) Simply put the directory "indiepath.mod" in the mod folder of Bmax and compile run "testpoly.bmx" in this folder ("indiepath.mod"). Is this work? |
| ||
Rebuilding the module did the trick. Don't know why it didn't work before. |
| ||
Yes, i've don't mention this. :) |
| ||
Very odd, perhaps that is why we are still in Beta. :) |
| ||
Also. :) |
| ||
Rebuilding the module did the trick. Don't know why it didn't work before. Perhaps you compiled the module in debug mode but the example code in release mode or vice versa? |
| ||
Here is the error I get: Compiling:testpoly.bmx Linking:testpoly.debug ld: archive: /Users/stephen/Applications/Development/Languages/BlitzMax/BlitzMax024/mod/indiepath.mod/poly.mod/poly.d.a has no table of contents, add one with ranlib(1) (can't load from it) Build Error: Failed to link /Users/stephen/Applications/Development/Languages/BlitzMax/BlitzMax024/testpoly.debug.app/Contents/MacOS/testpoly.debug Will try "build modules." |
| ||
Building modules fixed it. Duh. Works wonderfully. Actually, I had already implemented most of that code myself but never released it :) Or, more accurately, I implemented a point-line distance algorithm that makes collision detection dead easy. Will post in the future, but I don't want to spend my time writing mods, I want to spend my time writing games. |
| ||
I improved the code a little (atleast to my liking) I made methods out of the functions. Which made the implentation much more trival (easier). Ex instead of : ship:dPoly = dPoly.Create() dPoly.Poly_AddVertex(ship,0,-5) dPoly.Poly_Resize(ship,10,10) ship1:dPoly = dPoly.Poly_Copy(ship) You would Do: Ship:Polygon = Polygon.Create() Ship.AddVertex(0,-5) Ship.Resize(10,10) Ship2:Polygon = Ship.Copy() It helps me to speed up the coding =) I also added a example line infront of each function And I made a new example to test the Polygon-Type. Even thou I do not use it as a module here below just un-comment the import part and make sure you name everything correctly and it should still work as a stand alone module. There isn't someone who would know how to implend collision for points/rects/ovals versus Polygons? |
| ||
Hi wave, I've done some improvements at this end also. I've implemented a point in poly detection mode as well as included polygon Collision hulls for detection. And to make it easier I've also coded a polygon editor tool to make your own polys and design the collision hull. I will post as soon after I release the game I am using it for. aHem, When Win32 Bmax is in release more to the point. Oh and nice use of the Methods, the code I posted was my first use of BMAX, thanks for the tips :) |
| ||
Cool! I'm going to use poly-collision for the maps in my game. The plan so far is to use a nice background image of a arena/map and then I'm to use polygons to plot the impasseble terrain and walls from that image. It that way I hope to mix speed with color. A polygon editor would be super! I just have to ask, What is Collision Hulls? It seems really cool but I have no real idea of what it is or what it does. =) (polygons which are joined?) Perhaps we should meld our versions, it's public domain anyway =) , What do you think? |
| ||
Hi Wave, In the game I am developing the polygons are very complex and the collision algo in the code above would be erroneous. A collision hull is a simple polygonal representation of the complex poly. I use the Hull to check for collisions which is much faster as it has fewer points to check and is a true convex polygon. Here is a screenie of an early version of the editor to demonstrate. The Blue Lines are the collision hull. ![]() |
| ||
does this only work if the user can compile it? |
| ||
@John, I don't understand the question. This is blitzmax and it's already compiled into a module |
| ||
As I see this up... Looks like the Overlap function don't work as it suposed to work couse if one of the polies it's biger and fits the other without any of their sides intersect nothing happen. After all looks good. |
| ||
It's an old library now and does not do point inside poly checks, the new version does but that's not for public consumption - sorry. |
| ||
doesnt work for me, i get the same error as the first post |
| ||
The source is in the .exe just use it as an include. |