Joined: 2/12/2012(UTC) Posts: 5
|
I need to draw textured hexagons. I think Geometry class must help me, but it only for internal use. How to solve my problem?
|
|
|
|
Joined: 8/23/2011(UTC) Posts: 245
Thanks: 6 times Was thanked: 12 time(s) in 11 post(s)
|
Originally Posted by: Mahr Games Studio  I need to draw textured hexagons. I think Geometry class must help me, but it only for internal use. How to solve my problem? Are you creating the texture at runtime? Because otherwise you can just load a set of textured hexagons into the ContentManager and just draw them the normal way via Material2D.Draw.
|
|
|
|
Joined: 9/8/2011(UTC) Posts: 36
|
Draw a square with transparent corners
|
|
|
|
Joined: 8/23/2011(UTC) Posts: 245
Thanks: 6 times Was thanked: 12 time(s) in 11 post(s)
|
That would be an octagon :p
|
|
|
|
Joined: 9/8/2011(UTC) Posts: 36
|
Not if you used the correct shape triangles.  and of course, you can split that into simple quads, too. Edited by user Thursday, February 23, 2012 10:27:22 AM(UTC)
| Reason: Not specified
|
|
|
|
Joined: 8/23/2011(UTC) Posts: 245
Thanks: 6 times Was thanked: 12 time(s) in 11 post(s)
|
touche! :D
None-the-less I don't think that's what he's after :p
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
You could just go the easy way and use normal texture drawing with transparency like the others here suggested. There is basically no benefit drawing hexagon polygons instead of just quads (the textures won't be much smaller and the overhead for drawing a few transparent pixels can be neglected usually). If you have a special use case (e.g. 3D hexagons, opaque only hexagons and you want the last bit of performance and pack textures more tightly), then it might be worth the effort to do your own hexagon polygon based drawing. To do that I suggest looking at the DrawManager class (in Delta.Rendering.Basics) and implement your own geometry drawing class (like Line, Rectangle, Circle, etc.) and do whatever you like in there (line drawing, textured hexagons, shaders, etc.) Edited by user Thursday, February 23, 2012 5:03:57 PM(UTC)
| Reason: Not specified
|
|
|
|
Joined: 2/12/2012(UTC) Posts: 5
|
Originally Posted by: PG  you can just load a set of textured hexagons into the ContentManager and just draw them the normal way via Material2D.Draw.
Hexagons must be parts of big image (like puzzle). At worst it will be ~320 sprites on screen. I think more faster to draw 320x6 triangles without alpha, then 320 sprites with alpha-channel. Am I wrong?
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
Drawing 320 quads is really nothing serious, you can draw thousands of quads with alpha even on the slowest platforms (3 year old iPhones). The more important trick is to only switch textures rarely (the engine will generate atlas textures for you) and maybe only update geometry that changes (the MaterialManager will handle that for you). As I said above there is a benefit of drawing with your own hexagon polygons (half the compressed texture size usually when no alpha is needed, maybe a bit more if you can pack the hexagon textures tightly, this will give you a slight rendering increase), but it probably can be neglected (less than 10% of your overall performance if this is even a critical point for your app). Why don't you just go the easy way and render your hexagon tiles with alpha? If rendering performance is worse than you expect, you still can optimize. Edited by user Thursday, February 23, 2012 5:28:25 PM(UTC)
| Reason: Not specified
|
|
|
|
Joined: 8/23/2011(UTC) Posts: 245
Thanks: 6 times Was thanked: 12 time(s) in 11 post(s)
|
Originally Posted by: Mahr Games Studio  Originally Posted by: PG  you can just load a set of textured hexagons into the ContentManager and just draw them the normal way via Material2D.Draw.
Hexagons must be parts of big image (like puzzle). At worst it will be ~320 sprites on screen. I think more faster to draw 320x6 triangles without alpha, then 320 sprites with alpha-channel. Am I wrong? Others with more experience can speak - but since you decided to quote me I'll reply ^_^ I think you're right that drawing it as opaque triangles would be quicker in theory - but I seriously doubt it will make any difference in practice. 320 sprites is just nothing. (Least I hope so - else the games I'm attempting to write are in serious trouble! lol!) (Oops - Benjamin was quicker off the block than me. Oh well, making my post anyhow :p )
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.