Culling Edge Faces on a Plane

   1714   2   1
User Avatar
Member
3 posts
Joined: Sept. 2015
Offline
Hi everybody,

I apologize if this is not the proper place to post this question, this is my first post.

Anyways, I am making a tool that creates a hexagonal grid. The tool is working properly- I give it the width and height of the grid and the length of the hexes, and its all dandy.

Coming from a computer science background, though, I'm trying to optimize it. I don't want any of the edge faces, as they aren't hexes. So the way I currently get rid of them is to create a delete node with delete by expression, with filter expression being checking all edge cases:

//top
//primitiveNumber % height
!($PR%ch(“../../height”)) ||
//bottom
!(($PR+1)% ch(“../../height”)) ||
//left
($PR < ch(“../../height”)) ||
//right
($PR > (ch(“../../height”)*(ch(“../../width”)-1)))

So. This works fine. The little I do know about Houdini, though, tells me there is a better way to do this. Manually checking each edge case for every primitive seems a little brute-forcey. There's always a better way! Any ideas / suggestions appreciated! Thanks.
User Avatar
Member
1750 posts
Joined: May 2006
Offline
assuming all your hexagons are identical in size, put down a measure sop to calculate each primitive's perimeter, then a blast sop with the group field using the expression

@perimeter<3

or whatever the size threshold you need.

Another way is to do it in a prim-wrangle; count the number of points in each primitive, if its not 6, remove the primitive:

int points = len(primpoints(0,@primnum));

if (points!=6) {
removeprim(0,@primnum,1);
}
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
3 posts
Joined: Sept. 2015
Offline
Cool, thank you! My initial idea was to measure how many edges each primitive had, kind of like you suggested with the points, but I wasn't sure exactly how. Thanks!
  • Quick Links