Jump to content
BramSmulders

Procedural Dungeon Delete Room Problem

Recommended Posts

Hello dear people Odforce,
 
I am currently working on a procedural dungeon for an assignment and I ran into some trouble. 
I wanted to give the user some freedom and allow him/her to alter the state of the rooms. Let's say, delete or keep the selected room.
To control this I wanted to use a Multiparm Block Folder.
In there I want to select the room and choose if I want to delete the selected room it or not. (Together with some more functions)

So in the image below I want to delete room 24 and 47

pqe0bS.png

 

I figured out how to select and detete one single room, but I can not make it to work if I add more selection.

When made, I group each room individually. Then I blast the room I have selected.

Room_`chs("../CONTROLS/roomnumber1")`

Now, this will only delete that one room and not the others I have selected. 

In a perfect world I would have put an asterix instead of the 1 (Room_`chs("../CONTROLS/roomnumber*")`), so all my selections will be deleted. Sadly I do no live in that perfect world and now I am stuck on this problem.

Do you guys have a answer or an alternative solution to for this problem?

 

Thanks in advance

- Bram

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks! This works great.

 

However; I have another small problem now. I want to add a toggle so the user can choose to delete the room or not. I want to add more functions to the room and not always delete it. Unfortunately I am not proficient in scripting, yet.

So If I have room 4 and 7 selected in the controls, but room 7 is toggled off. In what way do I have to change the script in the Blast node to only delete room 4 and not both?

Share this post


Link to post
Share on other sites

Just add if statement to check if toggle is on:

{
string out = "";

for (i=1; i<=ch("../CONTROLS/rooms"); i++)
    {
    if (ch("../CONTROLS/deleteroom"+ftoa(i))==1)
        {
        out += "Room_"+chs("../CONTROLS/roomnumber"+ftoa(i))+" ";
        }
    }
return substr(out,0,strlen(out)-1);
}

Share this post


Link to post
Share on other sites

Works like a charm!

 

If I did not give the controls any rooms to delete the blast node would delete everything since it had nothing in its group parameter.

I worked my way around it by adding a dummy room and changed the first line of your script to " string out = "Dummy_Room";

This way there was always something to delete and allowed me to keep the rest of the rooms.

 

Again, thanks a lot for your help!

 

 

-Bram

Share this post


Link to post
Share on other sites

Hello again! Hopefully all of you had a nice christmas or christmas equivalent!

I ran into a new problem again. 

I am making doorways for the rooms that have been generated and let the user choose the position of those doorways along the side of the selected room.

This works perfectly with the code Pezetko shared. The way I made it workes great for only 1 selected room. If I select another one with it, the doorway will go switch from the first room to the second. I know this is because of the way I select the rooms I want to change, but I cannot find a way that work the way I want it to be.

 

I create points along a selected room where a single grid will be copied on. Then I delete everything except the point where I want the doorway to be.

Now, If I select a second room, the points of the second room will be added to it.

bq7bOT.png

 

Do you guys know a way where I can select my room (lets say 52) and let my doorway only be created on the points of room 52 and not go the points of (lets  say) 98 and vice versa?

 

-Bram

 

Share this post


Link to post
Share on other sites

You can process each room separately in the for each sop or you can save number of points (range from-to) of each room polygon/grid to custom attribute and work with that.

Share this post


Link to post
Share on other sites

The foreach was also my first thing ot try before I posted, but when I used that it would change each doorway at the same time with one slider. I don't really get your second solution, though. I haven't been using Houdini for that long to understand most of its features sadly.

Share this post


Link to post
Share on other sites

Please post that foreach example in hip file that you tried, and how far you got, so somebody can hint you to the right direction that suits you. It's not about houdini now but about general approach how to solve a problem in different ways.

Share this post


Link to post
Share on other sites

Here is my solution:

 

First preprocess each room separately (by groups), clean geometry, clean sides etc.. and add door position attribute. This is number from 0 to maximum of possible positions for door placement (numbers that user can choose in CONTROL) (I added custom display option for that parameter to see it in the viewport).

 

In second foreach I added attribute create sop that set 1 to the chosen points (0 to others). It's limited only to the points by expression (Group parameter on attribute create sop). That way is each room processed separately. Numbers (custom door positions) in CONTROL higher then available door positions are ignored.

 

After that I blast (keep_doors) all but marked at once outside of the for loop.

Procedural_Dungeon_Doorway_Problem_01_pz.hipnc

Share this post


Link to post
Share on other sites

Pezetko, you are my hero!

This is excately what I wanted to do with it. 

 

I hoped to get more experience with houdini while working with it, but I don't see any improvement myself, sadly.

Where did you get your Houdini expertise?

I don't really like to keep asking questions when I can't answer the questions of others.

 

 

-Bram

Share this post


Link to post
Share on other sites

Thanks al lot. I think I did have the solution for a minute when I was hecticly trying to make it work. It looks similar  to what I had at one point. However, it did not work back then. Yours on the other hand works like a charm as always.

Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×