problem with hexagrid

Discussions about SOFTIMAGEs© Interactive Creative Environment©
clankill3r
Posts: 131
Joined: 21 Oct 2012, 13:36

problem with hexagrid

Post by clankill3r » 06 Feb 2013, 21:08

Hi,

i'm trying to create a hexagrid.
I succeeded for the case where the amount of x steps and the amount of y steps both is odd (wich is the easiest case).
Image

There are 4 possible cases.
1: xSteps odd and ySteps odd
2: xSteps odd and ySteps even
3: xSteps even and ySteps even
4: xSteps even and ySteps odd

Case 3 and 4 are the hardest, tried them in java but i need more time to figure it out.
Case 2 shouldn't be that hard, i succeeded in java en have it in ICE now but something is wrong.

I would really like if someone can take a look at what is wrong.

I didn't post a image since it's a bit large for a image, however i added comments so it should be clear i guess.

https://dl.dropbox.com/u/17630770/temp/hexagrid_02.scn

grahamef
Posts: 281
Joined: 23 Jun 2009, 19:01

Re: problem with hexagrid

Post by grahamef » 08 Feb 2013, 23:55

I didn't completely follow your logic through so I can't spot the error. However, I might suggest a different a slightly different approach which may be easier (at least, it's easier for me to visualize). Imagine starting with a bigger grid than you need and deleting even more points. The key is thinking about a hex grid as basically a sheared square grid.
grid_preshear.png
hex_grid.png
In the second image, the centers of the hexagons correspond to every odd/even point (alternating) in every other row. So you could just shear a grid and use modulo on the X position to move the "overhanging" points back to the beginning.

Come to think of it, I think this is basically just turning an X by Y case into a 2X+1 by 2Y+1 case, which reduces everything to the easy odd by odd case.
You do not have the required permissions to view the files attached to this post.

Bullit
Moderator
Posts: 2621
Joined: 24 May 2012, 07:44

Re: problem with hexagrid

Post by Bullit » 09 Feb 2013, 12:07

http://xsisupport.com/2013/02/03/screen ... e-week-73/

Have some screens with hexas, maybe the icetrees there might help your issue.

clankill3r
Posts: 131
Joined: 21 Oct 2012, 13:36

Re: problem with hexagrid

Post by clankill3r » 09 Feb 2013, 12:52

hi grahamef, i like your idea but it makes something else more complex.
Check:
http://www.youtube.com/watch?v=kwWnPAA67Ls&feature=youtu.be

It figures out the bounds and based on a spacing it makes a grid.

Maybe someone can tell me why it always show 61 when i show the countervalue + offset.
Image