Render complex polygon with texture

Hi!

I'm developing a game that includes a terrain that consists of a number of polygons. Each polygon may contain a large number of points, and can be complex in shape (including concave polygons). I would like to use a texture to draw this terrain.

Does anyone have a good working example (preferably in CocosSharp 1.5) of drawing such polygons?

I assume I need to use the CCGeometryNode (the artist formerly known as CCGeometryBatch), but find very little examples and documentation around this.

Can CCGeometryNode work directly with such shapes, or does it need to be converted into triangles first? (as discussed here)

Posts

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    Jon

    You will need to create your own triangles for this to work.

  • JonJarnJonJarn SEMember

    Thanks Kenneth, then I have better picture of what needs to be done.
    I did try the LibTessDotNet that you suggested and that one can create triangles for my polygons.
    Still quite a bit of hassle, and I'm not sure about performance though.
    I might try out using a bitmap that I mask out bits from instead, when my terrain gets destroyed.

    I'll post here again when I decided on solution to go for.

    (But please ship in with ideas anyway if possible)

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    jonjarn

    Not sure about the performance but the Spine rendering seems to work ok. Of course if you try to render a large amount of the spine characters it will degrade performance. From what I have seen though it is not the rendering but all the code for the skinning and triangulation code that is in there.

  • JonJarnJonJarn SEMember

    For reference, I'm currently going with CCGeometryNode, drawing my triangulated polygons. This is working great (and also gives me the added benefit of texture mapping). I'm doing updates to my terrain during the gameplay, but I still get good performance. So, seems like the way to go.

    I also read that there is currently an issue with the ClippingNode on iOS (which was my other solution to the problem: One big bitmap that I "punch" holes in).

    Still have a few things to figure out:

    • Repeating a texture, can't understand how to calculate U/V for tiled textures. One big texture (filling the screen) works for now and is easy to calculate.
    • Optimizing my vertices. I'm currently handling my triangles (triangulated polygons) as individual elements. I should probably try to understand how to use the output from libtessdotnet to reuse vertices properly.

    Will post here again when my game is downloaded a trillion times and I'm inviting you all to join me on my private pacific island. ;)

Sign In or Register to comment.