How to create concave polygons

Yes, yes I know the documentation is lacking at the moment for Farseer.BMX. I’m still working on it on a few fronts. First, I’m trying to do api documentation (bbdoc mostly). Secondly, I’m trying to write tutorials/guides that help show how to use some of farseer’s features. I had hoped that releasing the demo application source code would’ve covered this aspect as the demos cover pretty much each feature, but I guess since the demo source is a bit more complex in design (handling a lot of graphics related mumbo jumbo), the actual ‘needed content’ wasn’t particularly easy to find. So I’m going to try to write up very simplified versions of some of farseer’s basic features (minimal graphics, minimal code).

I’ve uploaded the first of these tutorials to the articles section. It covers creating concave polygons in farseer :). More to come soon…


  1. Could you also try to post your Tutorials at as someones made an “Unofficial Wiki” for it, ive contributed 3 tutorials which are pretty crap and i need to add in a first tutorial which was just gonna be making the QuickStart.bmx, the other 3 are Images, Polygons and then how to make those custom functions.. Ive yet to post ones about Friction and things like that

  2. Yes, I only found out about the farseer wiki very recently. Great to know there’s others joining in on the effort for xna and blitzmax! I’ll try to get content up on the wiki there when I have a chance. Thanks for the heads up!

  3. No problem… It only has 3 Sections and there all pretty empty tbh, C#/XNA, BlitzMax and Tutorials… Only me and nergal ar doing anything ATM but were gonna see if Jeff will post about it on his Blog and im going to update my Post on Fun-Motion with it

  4. Id like to ask a question… How would i make a sort of camera on BlitzMax so that i could go from: Beetween (0,0 – 800,600) to looking at everything Beetween (100,100 – 900, 700)? If tried everything i know so far and i cant think of anything

  5. you can use the SetOrigin(x,y) command.

    SetOrigin(0,0) would give you coordinates between (0,0-800,600)

    SetOrigin(-100,-100) would give you coordinates between (100,100-900,700).

  6. How would i use this to make a Box the center of the screen at all times? Like classic SideScrollers? Ive been trying to figure it out for a while… I already knew about Origin through your demos but couldnt figure out how i would get the “Camera” effect

  7. Nvm… Got it just this second lol

    Was Using this sort of thing:
    Pos:Vector2 = Box.GetPosition()
    SetOrigin(Pos.X – 400, 0)

    When i needed:
    SetOrigin(400 – Pos.X, 0)

    Thanks for your help

  8. Finally found out how to get modules working on BMax lol, I tried using the Module version but it doesnt sem to allow TPhysicsSimulatorView or TDrawingHelper? Also, I posted this in the tutorial comments but, How do i make Polygon textures???

    Ive tried things like:
    TDrawingHelper.CreatePolygonTexture(CarVerts, TColor.White, TColor.Black, 3)
    But, No dice?

  9. Hi Leonard,
    TPhysicsSimulatorView and TDrawingHelper are not core parts of the farseer physics engine, they were used to help the development of the demo application. As such, they are not included in the actual module. To use them you’d have to include them manually in your own code.

    Also the function signature for polygon textures is this:

    Function CreatePolygonTexture:TImage(points:Vector2[], color:TColor)

  10. Why only one colour? And no line width?
    So how would i use this to make a Triangle texture with the coordinates:
    0, -10
    5, 10
    -5, 10

  11. Adding support for outlining arbitrary polygon’s wasn’t as trivial as the other helper functions, so for the sake of time/performance I left the polygon function as is. Again, those functions were created more for debug purposes to help development along.

    As for your question, I don’t have the code in front of me at the moment but I believe it would be something like similar to this:

    local points:Vector2[] = new Vector2[3]
    points[0] = Vector2.create(0,-10)
    points[1] = Vector2.create(5,10)
    points[2] = Vector2.create(-5,10)

    local triangleImage:TImage = TDrawingHelper.CreatePolygonTexture(points,TColor.White)

  12. Ah, gotcha… Thanks anyway, I guess i could find someway to save the textures made to a JPG or something and edit in some more details myself.

  13. Hey, ive tried to make my own type (TRagdoll) that goes in the DemoShare and then included into the Engine, every time i try to put it into a simulation using:

    Global Ragdoll:TRagdoll = TRagdoll.Create(Centre)

    I get an Memory Exception Error, Any ideas what this could be caused by? If you need i could send you a copy of the Type’s file…

    P.S Yes i have set up Methods for creating the type and for Loading it (Drawing it too, but i havent actually used that yet)

  14. Yet again, found the problem minutes after… I was getting the rotation of the Ragdoll (Its torso) at the beggining, not in a method which seemed to break it…

    Field Rotation:Int = MathHelper.ToDegrees(RagdollTorso.GetRotation())

    Then returning it in a method, the GetRotation() should have been called inside the method…

Leave a Reply

Your email address will not be published. Required fields are marked *