[SOLVED]Detecting patterns in a grid

   2426   5   3
User Avatar
Member
10 posts
Joined: March 2018
Offline
Hi all,
I've been using Houdini now for a few months but mostly worked with heightfields. So I wanted to create something relatively simple during my free time but ended up scratching my head longer than I would've liked. The hardest part for me is to find solutions in Houdini I would otherwise find easy to solve using Blueprints or coding. I think I sometimes rely too much on VEX.

I'd like to create a simple LEGO tool since I saw a few popping around here and there and it seemed like a good practise project.
However instead of using only one kind of block I would like to use different kinds. Maybe a 1x1, 2x2 and a 3x2.
But I'm having problems figuring out how to detect these shapes in my point grid, how to isolate them properly and then merge them together.

What I currently do is iterate over every row(layer) in the point cloud(which is evenly spaced). Then I let a bounding box iterate over every point and see when the box has an equal amount of points inside it as the pattern. This part kind of works, but I have trouble with the next part. I need to isolate these points and keep them “aside” as to not generate false positives in the next iteration, since some of the points are already part of the found pattern.
I find the for loops a bit confusing tbh..

I also tried with a point wrangle, but then I was hard coding the patterns which also seemed like a wrong approach. And I also didn't get that to work.

Here is a screenshot of what I have:


I think understanding these kind of problems better would help me for future projects I wanted to do. Like some kind of tile based city generator.

Any help would be highly appreciated!
Have a nice weekend
Edited by FloreV - Nov. 2, 2019 11:55:16

Attachments:
problem.png (278.3 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hi,
I'm not sure how to help you with the for-loop.

Regarding a vex a possible approach:
for each point create an array attrib and populate it with neighbours points (up,left,right,down).
Then in another wrangle (detail or numeric) you loop over each point (even randomly) to place the blocks. When a block is placed you flag the points occupied by it, so you skip them in the iteration, and also you remove those points from the arrays.

This is just out of my mind, I don't if I'm overlooking some important step.
Edited by Andr - Nov. 2, 2019 06:54:25
User Avatar
Member
10 posts
Joined: March 2018
Offline
I managed to solve the issue. The issue was more me not completely understanding how for loops worked in Houdini. The differences between the input, feedback and piece begin blocks.

I know this image doesn't really say much. If someone wants a more detailed explanation I can write it down.
Edited by FloreV - Nov. 2, 2019 10:36:20

Attachments:
solution.PNG (36.9 KB)
solution2.PNG (1.5 MB)

User Avatar
Member
42 posts
Joined: April 2018
Offline
How far did you get with this in the end? I only just found this thread I am currently doing something very similar (trying to make a version of the bricker plugin for blender as a learning project) and had the exact same problems you did with doing the loops. It was a real headache figuring out the right combination of feedback and merging and iterating. The hardest bit was removing points from the iteration feedback but keeping them for the final copytopoints

From reading this it sounds like we both used the same approach, iterating over a bounding shape within the volume and tagging points! I wish I had read this thread when I started tho…

I currently have a library of 12 rectangular bricks. But I am working on the next part of the network which is adding slopes and flat tiles on the top and bottom of the model.

If you want to see some shots then I can post some in progress ones.
User Avatar
Member
2 posts
Joined: Feb. 2018
Offline
I'm also interested in this set up, are you able to share a more detailed explanation, or share the scene file? thank you in advance!
User Avatar
Member
10 posts
Joined: March 2018
Offline
Hi sorry for the super late reply.
I wrote it down on my artstation a while ago, hopefully it gives you a better idea:
https://florevanackere.com/blog/e71W/houdini-lego-tool-breakdown [florevanackere.com]

@Aten, I'd love to compare some of the workflows
I haven't worked on the tool anymore but might revisit it to add more bricks at some point.
  • Quick Links