how can one produce a hex grid in houdini ?
33139 20 8-
- pheryel
- Member
- 11 posts
- Joined: 9月 2016
- オフライン
-
- mestela
- Member
- 1850 posts
- Joined: 5月 2006
- オンライン
-
- anon_user_37409885
- Member
- 4189 posts
- Joined: 6月 2012
- オフライン
-
- Konstantin Magnus
- Member
- 719 posts
- Joined: 9月 2013
- オフライン
A rough implementation of a hexgrid algorithm would be connecting two attribwrangles: Set the first one to detail and the second one to run over points.
If you want to dig a tiny little deeper, here is the source:
http://www.redblobgames.com/grids/hexagons/ [redblobgames.com]
http://www.redblobgames.com/grids/hexagons/implementation.html [redblobgames.com]
// Creates a point grid in detail mode for(int j = 0; j < 10; j++){ float shift_x = ( (j + 1) % 2 ) * 0.5; float shift_z = j * 0.75; for(int i = 0; i < 10; i++) { vector pos = set(i + shift_x, 0, shift_z); addpoint(0, pos); } }
// Draws hexagonal polygons on the grid int prim = addprim(0, "poly"); float height = (sqrt(3)/2) * 0.5; float width = 0.5; for(int i = 0; i < 6; i++) { float angle_deg = 60 * i + 30; float angle_rad = $PI / 180 * angle_deg; vector pos = set(@P.x + width * cos(angle_rad), 0, @P.z + height * sin(angle_rad) ); int pt = addpoint(0, pos); addvertex(0, prim, pt); }
If you want to dig a tiny little deeper, here is the source:
http://www.redblobgames.com/grids/hexagons/ [redblobgames.com]
http://www.redblobgames.com/grids/hexagons/implementation.html [redblobgames.com]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- pheryel
- Member
- 11 posts
- Joined: 9月 2016
- オフライン
-
- ryuku
- Member
- 171 posts
- Joined: 10月 2016
- オフライン
Hey!
Thanks for the examples shown.
@mestela
How you understood that we need to put 0.6 in second transform's x Scale to make polygons symmetrical? Is there a kind of logic in it or you've found that it works by tweaking scale?
@Konstantin Magnus
You have four nodes for this (grid + attribute wrangle + attribute wrangle + null)? I have source grid visible after hexagons are created, you've added some anoter node to delete it, or I did a mistake in code retyping and something there delete grid? Yours hexagons look the same sized on the image uploaded, but how do you know that they are? Is there something in written shows you that it is so? Using what in code you adjust spacing between hexagons?
Thanks for possible replies and advices
Thanks for the examples shown.
@mestela
How you understood that we need to put 0.6 in second transform's x Scale to make polygons symmetrical? Is there a kind of logic in it or you've found that it works by tweaking scale?
@Konstantin Magnus
You have four nodes for this (grid + attribute wrangle + attribute wrangle + null)? I have source grid visible after hexagons are created, you've added some anoter node to delete it, or I did a mistake in code retyping and something there delete grid? Yours hexagons look the same sized on the image uploaded, but how do you know that they are? Is there something in written shows you that it is so? Using what in code you adjust spacing between hexagons?
Thanks for possible replies and advices
Edited by ryuku - 2017年11月22日 06:06:35
-
- mestela
- Member
- 1850 posts
- Joined: 5月 2006
- オンライン
-
- ryuku
- Member
- 171 posts
- Joined: 10月 2016
- オフライン
-
- Konstantin Magnus
- Member
- 719 posts
- Joined: 9月 2013
- オフライン
Hi Ryu,
No, just two wrangles (see attachment).
Multiply the same value on height and width.
Ryu Ku
You have four nodes for this (grid + attribute wrangle + attribute wrangle + null)?
No, just two wrangles (see attachment).
Ryu Ku
Using what in code you adjust spacing between hexagons?
Multiply the same value on height and width.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- ryuku
- Member
- 171 posts
- Joined: 10月 2016
- オフライン
-
- vusta
- Member
- 555 posts
- Joined: 2月 2017
- オフライン
so here's my way…it boils down to divide and conquer…or translated to: create a unit of something, clone it, offset it, radial clone it…whatever….it's just cloning…
I'm not a coder so cannot cram things into one wrangle…but for other non-programming ppl out there..you can look at my files here:
https://www.facebook.com/groups/HoudiniArtists/permalink/1467625033353296/ [www.facebook.com]
step-by-step are pretty easy to understand…it's just cloning, offsetting…
(oh yes…mine produces points…so technically not a grid)
I'm not a coder so cannot cram things into one wrangle…but for other non-programming ppl out there..you can look at my files here:
https://www.facebook.com/groups/HoudiniArtists/permalink/1467625033353296/ [www.facebook.com]
step-by-step are pretty easy to understand…it's just cloning, offsetting…
(oh yes…mine produces points…so technically not a grid)
Edited by vusta - 2017年11月24日 02:37:16
-
- ryuku
- Member
- 171 posts
- Joined: 10月 2016
- オフライン
-
- anon_user_89151269
- Member
- 1755 posts
- Joined: 3月 2014
- オフライン
-
- vusta
- Member
- 555 posts
- Joined: 2月 2017
- オフライン
-
- ryuku
- Member
- 171 posts
- Joined: 10月 2016
- オフライン
@vusta
Very interesting approach to create hexagon, you've reminded me that I need to find out how to work with For-Each Loops still don't know it
Changed you packing tube to six Columns, like the effect it gives and like how you've called the file, didn't think about miel before it relatively to hexagons
Thanks for the example
Very interesting approach to create hexagon, you've reminded me that I need to find out how to work with For-Each Loops still don't know it
Changed you packing tube to six Columns, like the effect it gives and like how you've called the file, didn't think about miel before it relatively to hexagons
Thanks for the example
Edited by ryuku - 2017年11月24日 13:20:51
-
- Schmauch
- Member
- 23 posts
- Joined: 8月 2014
- オフライン
I tried to replicate the code of Konstantin Magnus and the hex was always squished a bit. What gave me an regular hex was this. Took me some time to figure out because I don´t know my way around math very well. Perhaps it can be of help to someone.
@Konstantin Magnus Thanks for the starting point and the wonderful Red Blob Games [www.redblobgames.com] link
@Konstantin Magnus Thanks for the starting point and the wonderful Red Blob Games [www.redblobgames.com] link
int prim = addprim(0, "poly"); float size = 0.5; for(int i = 0; i < 6; i++) { float angle_deg = 60 * i-30; float angle_rad = $PI / 180 * angle_deg; vector pos = set(@P.x + size * cos(angle_rad), 0, @P.z + size * sin(angle_rad) ); int pt = addpoint(0, pos); addvertex(0, prim, pt); }
-
- BabaJ
- Member
- 2161 posts
- Joined: 9月 2015
- オフライン
Saw this post a while back and wanted to give it a whirl but didn't have the time…had time today.
I seperated the hexagons into two vex nodes - one for just creating the hexagons points (their hex “corners”).
And the second to make them into polylines or polygons.
The third node is an add node just to quickly create the polygons by attribute ( in this case the hex number ).
Both vex nodes have a folder tab with control paramters.
The first vex node name “Create Hexagon Points” has the following controls:
* Hexagon starting point
* Hexagon Radius
* Number of Hexagons per row
* Number of Rows
The second vex node has the parameter to switch back between polys or polylines.
I seperated the hexagons into two vex nodes - one for just creating the hexagons points (their hex “corners”).
And the second to make them into polylines or polygons.
The third node is an add node just to quickly create the polygons by attribute ( in this case the hex number ).
Both vex nodes have a folder tab with control paramters.
The first vex node name “Create Hexagon Points” has the following controls:
* Hexagon starting point
* Hexagon Radius
* Number of Hexagons per row
* Number of Rows
The second vex node has the parameter to switch back between polys or polylines.
Edited by BabaJ - 2018年5月4日 21:37:47
-
- Konstantin Magnus
- Member
- 719 posts
- Joined: 9月 2013
- オフライン
A non-mathematical approach would be
- a grid with alternating triangles,
- grouping its crossing points,
- scaling it by ~1.7 along X,
- and copying six sided circles on them.
- A fuse will cover tiny imprecisions.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- Nick Wood
- Member
- 1 posts
- Joined: 4月 2015
- オフライン
-
- STEVLTH
- Member
- 1 posts
- Joined: 9月 2018
- オフライン
Thanks to everyone for your methods. I made my own super simple method, that converts the default grid to hexagonal grid using ‘pointsfromvolume’ node with Tetrahedral point configuration.
You can easily control grid size, hexagon size (Point separation in the ‘pointsfromvolume’ and hexagon offset (circle radius).
You can easily control grid size, hexagon size (Point separation in the ‘pointsfromvolume’ and hexagon offset (circle radius).
-
- Quick Links




