BramSmulders Posted December 22, 2014 Share Posted December 22, 2014 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 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 1 Quote Link to comment Share on other sites More sharing options...
pezetko Posted December 22, 2014 Share Posted December 22, 2014 Do a loop over them to collect them all. There is hscript example attached. pz_group_multiparam.hipnc Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 23, 2014 Author Share Posted December 23, 2014 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? Quote Link to comment Share on other sites More sharing options...
pezetko Posted December 23, 2014 Share Posted December 23, 2014 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); } Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 23, 2014 Author Share Posted December 23, 2014 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 Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 27, 2014 Author Share Posted December 27, 2014 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. 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 Quote Link to comment Share on other sites More sharing options...
pezetko Posted December 27, 2014 Share Posted December 27, 2014 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. Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 28, 2014 Author Share Posted December 28, 2014 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. Quote Link to comment Share on other sites More sharing options...
pezetko Posted December 28, 2014 Share Posted December 28, 2014 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. Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 28, 2014 Author Share Posted December 28, 2014 That was my intention in the first place, but I forgot to attach it. Room 0 and 1 should be in the upper left corner of the map just in case you can't find them. Procedural_Dungeon_Doorway_Problem_01.hipnc Quote Link to comment Share on other sites More sharing options...
pezetko Posted December 30, 2014 Share Posted December 30, 2014 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 Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted December 30, 2014 Author Share Posted December 30, 2014 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 Quote Link to comment Share on other sites More sharing options...
pezetko Posted January 3, 2015 Share Posted January 3, 2015 I added scatter example as you asked. You can do it in the main loop or in separate foreach cycle. It depends what you further do with those points and how snappy response you expect from changing parameters in the control UI. Procedural_Dungeon_Doorway_Problem_02_pz.hipnc Quote Link to comment Share on other sites More sharing options...
BramSmulders Posted January 3, 2015 Author Share Posted January 3, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.