Max 8 vertices limit

edited February 2012 in Help request
According to the wiki if I have a body part of type mesh I can only specify 8 vertices, first of all in the ini file will this be done like this
VertexList = (0,0,0)#(10,10,0)
and secondly how is I'm supposed to deal with that limit? Most of my larger bodies will be have a irregularity in a way that it can not be specified with only 8 vertices unless I misunderstand something.

If I could wish for a function here it would be that we had a body part type directly shape like the graphic.


  • edited February 2012
    That's actually a limitation that comes with Box2D.

    In b2Settings.h:
    /// The maximum number of vertices on a convex polygon. You cannot increase
    /// this too much because b2BlockAllocator has a maximum object size.
    #define b2_maxPolygonVertices	8

    Not only you can only have 8 vertices, but the resulting shape has to be convex and the vertices have to be entered in a clockwise order.

    Now for irregular/concave bodies, you simply have to subdivide your object into as many convex shapes (aka parts) as needed.
    There's no limit on the number of parts a body can have.

    That being said, having a function to to the subdivision for you would be nice and it's something that can be added eventually.
    I think I've found some user-made code that did something similar on the Box2D forums, but it was a while ago and I don't have the link anymore.
  • edited February 2012
    It says on the wiki that you could only have 8 body parts too. How is it about performance if we have 30 body parts instead of 1? You forgot to mention how to set the list in the ini file, it is not mentioned on the wiki either. Is there a way of getting the latest version docs for the svn version?
  • edited February 2012
    oh woops, I'll update the wiki. The 8 parts was an old limitation that went away when I updated the Box2D version orx was using.

    The API doc lives in /orx/doc if you use the svn version. It's usually up to date.

    As for how to set the list in the ini file, which list do you mean?

    If you mean the part list, you can have a look at tutorial #11, especially in this file:

    The MaskBody is using a few parts to match the orx logo.

    As for the peformances I don't exactly know how they scale in Box2D but I'd assume they're relative to the number of total vertices of a body rather than based on the number of shapes. But again, I'm no Box2D expert and I'll see if I can find something on their forum.
  • edited February 2012
    The VertexList value for body part type mesh.
  • edited February 2012
    Mmh, I'm not sure I understand your question then.

    From the config body wiki page:
    Mesh (polygon)
    Type        = mesh
    VertexList  = <vector>#<vector>#...
    Mesh (polygon)

    Here's a list of the available properties only available to mesh 4) parts:

    VertexList: Provides a list of vertex coordinates in parent object's space. The resulting polygon needs to be convex. Up to 8 vertices can be defined and they have to be entered clockwise. You can find an example in the spawner tutorial 5).

    To sum it up it's a list of up to 8 vertices defined clockwise and whose coords are in object space.
  • edited February 2012
    Yea that's the part I didn't understand... =) for some reason... I think at the time I thought # would mean a list of random values. Sorry about that.
  • edited February 2012
    Ah, no worries! =)

    Here are some details though: # is the list separator (up to 65535 elements).
    However you can either call orxConfig_GetList* or regular orxConfig_Get* to query its value(s).

    With the first version, the explicit one, you give a list index and you'll get that exact entry.
    With the second version, however, as no index is given, one will be randomly picked by orx. That's how you can get per item randomization in config.

    Now for all the properties using the "List" suffix, that means orx code will explicitly access is as a list, index by index. That's just a naming convention to make the life of the user a bit more easy. :)

    However when there's no "List" suffix, orx will call the standard query function and get a randomized result if the value was actually a list.

    For example:
    Scale = 1.0 # 1.5 # 2.0
    Will create an object with a random scale of 1.0, 1.5 or 2.0 as orx used orxConfig_Get* to access its value.

    Of course for all user-made properties, there's no such convention as the "List" suffix, it depends on how the user is going to access its own data in config. :)
  • edited February 2012
    Quick addendum: List items can still use numeric randomization:
    Scale = 1.0 # 2.0 # 3.0 ~ 4.0

    Will result in a scale of 1.0, 2.0 or any value between 3.0 and 4.0.
  • edited March 2012
    This morning I stumbled upon Physics Editor which looks like a nifty tool.
    The author kindly provided me with a free license so it's likely that I'll write an exporter for it when I get some spare time.

    On a side note, the same author also made Texture Packer and is willing to add orx in the export format.
  • edited March 2012
    Yeah Iarwain !

    It can be very nice !
  • jimjim
    edited March 2012
    That would be so great :)
Sign In or Register to comment.