Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline mahrizh  
#1 Posted : Thursday, February 23, 2012 6:57:54 AM(UTC)
mahrizh

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?

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline elasto  
#2 Posted : Thursday, February 23, 2012 7:18:15 AM(UTC)
elasto

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 Go to Quoted Post
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.
Offline AaronStackpole  
#3 Posted : Thursday, February 23, 2012 7:59:22 AM(UTC)
AaronStackpole

Joined: 9/8/2011(UTC)
Posts: 36

Draw a square with transparent corners
Offline elasto  
#4 Posted : Thursday, February 23, 2012 8:20:37 AM(UTC)
elasto

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
Offline AaronStackpole  
#5 Posted : Thursday, February 23, 2012 10:23:29 AM(UTC)
AaronStackpole

Joined: 9/8/2011(UTC)
Posts: 36

Not if you used the correct shape triangles.

UserPostedImage

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

Offline elasto  
#6 Posted : Thursday, February 23, 2012 11:12:35 AM(UTC)
elasto

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
Offline Benjamin  
#7 Posted : Thursday, February 23, 2012 5:03:17 PM(UTC)
Benjamin

Medals: Admin

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

Offline mahrizh  
#8 Posted : Thursday, February 23, 2012 5:21:52 PM(UTC)
mahrizh

Joined: 2/12/2012(UTC)
Posts: 5

Originally Posted by: PG Go to Quoted Post
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?
Offline Benjamin  
#9 Posted : Thursday, February 23, 2012 5:27:13 PM(UTC)
Benjamin

Medals: Admin

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

Offline elasto  
#10 Posted : Thursday, February 23, 2012 5:31:06 PM(UTC)
elasto

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 Go to Quoted Post
Originally Posted by: PG Go to Quoted Post
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 )
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
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.

Powered by YAF.NET | YAF.NET © 2003-2022, Yet Another Forum.NET
This page was generated in 0.072 seconds.