Houdini Algorithmic Live #018 - Wire Trail (English / 英語)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay it's time 9 p.m. in jst so I'm gonna start doing the live tutorial for this week okay hello my name is Ichiro I'm going to do a weekly Houdini tutorial mainly using vex as a one of the algorithmic design practice and do some easy two fairly easy to do geometrical designs using algorithmic design method right so today's topic is to create something like this the trail of particles running on top of a wireframe of given geometry so it there's gonna be mainly three steps for this tutorial one is first to create a wireframe like this alright and then next I'm going to reduce the number of lines connecting those boxes since right now it's too much of a connection between point to point and by reducing the number of lines then I'll be able to let the trail to see more a sci-fi like effect at the end so the rule here the rule here to reduce the lines is to reduce as much as much line as possible until while it keeps the connection between each lines so each line should have a connection more than two or three so this line have a connection between 2 & 3 more than 2 equal to 2 neighbors this one has a connection with 3 neighbors so keep the number of neighbors for each point 2 2 or 3 other than that if you if it if the point neighbor count is more than 4 then reduce remove that line so that's the rule here to reduce the number of lines so as a result you'll be able to have all the point connected at the end you can still travel from this point to this point by tracing the line at some path so makes it some kind of a continuous maze 3d maze all right so that's the second step and the third step is to create a point on top of the line the collection of line just create a random number of points on top of the line then let those particles move along this network to a random direction using a solver like this the point here is the let point moves along the wireframe as as well as keep the direction go not keep direction to be forwarded which means if the point goes from here to the edge of the line let point go to the other edge other goal from this point to this point and when it comes to the three branch right here let this point go to either of the left direction or the right direction and try not to let those this point go backward oh thank you for the stripper chat thank you very much so that's what I'm gonna do for the third step and then finally you can create a trail from that moving point and visualize it just using something like poly wire to make something like this okay so let's do this from scratch okay so we're gonna create a geometry node first then first thing I would like to do is to create a wireframe for a point to move on top pose so the the wireframe could be derived from anything computer I from the sphere it could be try from tolerance or anything else it could be from dry from pig head but to make it simple for the first trial I all gotta make make it from a box so I'm gonna create a box first and let's keep the size to one as a default and I'm also going to create a grid of 3d point and copy this box to those points the 3d point grid points then just extract the edges which is those eight or ten twelve edges think out of this box to create a something like a squared wireframe which also have the lines inside the grid okay so I'll stuff from creating a 3d grid using a attribute wrangle creating 3d grid and let's do this if you are wondering if you want to see the file itself the completed file self i have also uploaded the completed file to the github and the link is in the video description so if you're interested you can download that and watch it see it while i'm doing the tutorial okay now let's set some parameters I'm gonna set the number of points in the x and y and z directions so it's create x y and z [Music] and let's create a three loops using those X Y and C value I'm just gonna copy this paste it like this to make three nested loop and let's rename this to TT T and this one to see and let's create a point and position using those I N and T so I and T which will be x and y and z to coordinate and then at that position as a point oh well thank you very much for the super chat well that's really appreciating thank you very much all right so now I have added the number of points using XY and Z and let's click this button to promote the number of X Y Z sliders so that you can create a number of points as a 3d grid now let's have those XY and Z as a parameter where you so that you can control it later on so I'm gonna make a node node name this something like controller and then colleges and create three integer parameters named as X or maybe I can just drag and drop this XY and Z I have created here by checking the four bit liking parameters from outside the subnet here then drag drop the value like this and that should create a linked parameter which I can control it inside a this new node right now that I have a 3d grid points let's copy this box to those point position by using copy points copy two points like this okay now I have a bunch of box stacked on top of each other let's just extract the wireframe out of this by using a convert line which will create a jungle-gym like a box wireframe and next thing I would like to do is to create reduce the number of lines out of this so that I can create more like amazing pattern amazing Network out of this rigid wireframe Network which looks a bit boring right now right so to do that I'm going to first set a group call group for primitive and let's say can use so right now all the line has a group assigned as can use if I look at the geometry spreadsheet and the primitive to have I have this can use for each lines each line now I'm going to use this group to reduce the calculation for the next for each step which is going to be done recursively so that I don't have to do like unnecessary calculations too if I should reduce that if I should remove that line or not okay so whenever it has a group called can use for each line then I can check if I can delete that line or not if whenever the line has no can use group then I'm just going to ignore that because it is already being treated as the line that cannot be deleted right and I'm also going to create a additional attribute for each line named as ID so for each primitive I'm going to create an ID integer attribute called ID drive from primitive number and this ID is also going to be used to check whether if I should delete that specific line or not so I'm just gonna name this ID right or prim ID okay and if I have if I check the primitive attribute I have I should be able to see ID rest lines which are not going to use and the group call can use all right that's good now connect this to the null node and name this in it which I'm going to access I think I'm going to access this later on using some from some Wrangell script or something right now the next thing I'm going to create a for loop to really look at each lines to see what whether I should but I could delete that line or not right so I will do that by using a for each number and the number here is actually a number of lines existed here so if you have like tons of wireframe Tom got tons of a lot tons tons of lines existed inside this in it then the calculation here it's gonna be a bit slow but this is just one time calculation so after that it's just the animation using the reduced reduced lines so even though if you have a number of tons of lines here it wouldn't affect the final animation speed so I don't worry for that okay so to know the number of primitives which is inside is in it you can just access a expression called n primitives or n frames and you can enter that here so let's write a H script expression here so in order to access the number of primitives here I think I can just say n correct me n frames so this one okay if I make a parenthesis it just shows what kind of parameters that I need to get that get the number of primitives from the specific node and it says I need to give a path to that node so all right like this I'm accessing the in it okay I don't need a semicolon T right so in this case I have total number of 2200 2592 all right okay so let's do this I have some comment here I like what you're doing here for the education of your purse but you could use a box top and then use a pound salt and turn on divisions to get nice clean grid okay a box off and then bounce off into it on division I see can I try that if it works then that might be better let me see pound box this one no all right that works yes okay didn't know that sorry for that yeah that was much easier okay now by looking at each lines here I first I need to change some parameters here so first of all together method I'm going to make it as feedback each iterations to make it a feedback loop and then let's set the method to fetch feedback right so this two combination of parameters will make this loop a feedback loop so kind of a recursive loop right okay now next thing I would like to do is to create a delete to just keep just show the lines which have can use group here so set it to no delete non-selected with this can use as a guide so this is currently the lines that can can be deleted all right okay and in order to use this as a guide I am going to use a primitive or maybe attribute detail wrangle so I'm gonna create a attribute wrangle set it as a detail and then lets me name this remove line and I'm liked also I would like to also get the data call iterations for each loop which can be get it from this for each count if you look at the for each count at the detail attribute you have a attribute go iterations which is the number of iterations for each loop so when when it goes for the first loop it will become 0 and then stop stops at 2 5 9 1 in this case I'm gonna I would like to access that data what can i connect that to the second input of this attribute wrangle then let's connect is deleted which is acting as a guide which one to delete to the third input after this removed line okay now a bit of coding from now on let's open up the editor make sure that this is set at at set as detail and then let's open up the editor by alt e' and first thing I would like to get the iterations from the detail attribute off the second input so when I write like this I'm gonna name this variable as ETA and I'm going to get the random values goes from 0 to a maximum number of primitives which is stored inside here so 1 what I want like what I want to do right here is to create a random index which is from 0 to in this case 2 5 9 1 which is the total number of delete total number of lines contained inside the lead node and then just pick a random index and if it's 18 then I'll gonna get this one this primitive then inside this primitive you should get this ID which is the original idea that line had if you delete those lines iteratively for each iterations for each loop this integer this ID will it it's going to change time by time based on the if you compare with the the original of the primitive number then so maybe if in the next loop even though the primitive number is 17 the ID might become 16 or 15 something like that so that that is why I have set the ID previously so that you will you can keep that you can keep the track of the original ID what has been deleted what has not been deleted okay and in this case I'm just accessing to the primitive number one right now so I'm going to create a random value which is goes from zero to the maximum number of primitive number so I can get that by let's name this random index and then I can calculate at first I'm going to create a random value from zero to one using some seed and the seed could be any value but for each loop it should be different values so I'm going to first use this iterations as this number of see multiplied by some random constant number and I'm also going to create a seed parameter which I can change it by myself later on so combining those two values I should be able to get a really random value for each loop and still you can change the variations okay now I have a random values from zero to one right here and in order to get the number which is between zero to and number of primitives for this delete node I can multiply this by and primitives the third input so this is the number which defines the number of primitives inside is daily node I'm not sure if the spell is correct and program it Tiff's right so now that I have a random index which which have been created from 0 to 2000 something I'm going to actually get the this ID value from this index which is for this far-left primitive number from this for primitive all that primitive number I'm going to get this ID actual ID value for the primitive for specific primitive number so to do that I'm gonna name this primary Graham from third input get the ID attribute at random index okay so this is going to be the actual printed ID number right here and then the next thing of I am going to do is to go back to this input the original input from the for each begin and if you look at the geometry spreadsheet what I'm going to do is to pick the primitive which have the same ID which I find it here so in this case if the random ID is 18 then find out the same primitive which has the same ID 18 and get this specific primitive number for that from four at zero for input 0 so feminine find I'm gonna use find at shave pal for a first input from first input for primitive I'm gonna look at look for idea idea attribute which have the same ideas of I as I found from this third input which only have can use group now this one contains both lines which is inside a kangaroo can use group or with that is not inside a can use group and I've extracted only the can use group to see that so that I can only pick up the line which is inside a can use group as a single line and from that I can check whether that picked line is connected with other lines with a specific number of neighbor count for an endpoint and from that I can check if I should remove that or not okay so now that I got one ID one primitive ID to check whether I should delete or not next thing I would like to do it to get the list of points from that primitive from that lines using print points and using those I should be able to get say if I pick up this line I should be able to get the points constructing one line so that as a result you should get two point less two points list doing this so you you you are sure that you have only two points because I have used this convert line so that everything becomes lined okay so keep that in mind I'm going to count the number of neighbors for each end point so for this point at this point and for this point currently the number of neighbors is one two three four so touch it before and this one is the same one two three four so let's get those information into count one that this is for the first point point friends so this is the first point from this pts list two points list and I'm getting the number of primitives well you can also use the neighbor count maybe neighbor count function to get the number of neighbors either way is fine I think maybe this is too long to write this matter and do the same for the end points pts one so now I have to attribute explaining the number of neighbors for each starting point and end point and I make I'm going to make a condition if one of the count either this one or this one is more than three and other one have a neighbor more than two then delete that node if else then keep that note so that I can remove only the one that I want to delete and still keeps the network for whole network so that one point can travel to other point without a missing link without any dead end now let's try by setting a condition a bit differently if I set the count one is more than one and count to it more than two which seems to be okay at first look this we point remove trim this is a bit problematic because even though this seems to keep the connection if say this is the lines you were looking for and if the neighbor number of neighbor is more than two then delete means that if there's more than three branches for each point then remove that and that sometimes create a isolated island like squares too so that point cannot be travel to the other point position so making the isolated island means that you have a dead-end you cannot you never can be able to leave from this island if the point being created on top this square so the condition should be one of the point counts should be more than two and if that's so then other ones you have more than three vice versa if count two is more than two then count three the country is of count one is more than three then also delete that one okay and else if the condition didn't meet with this then you can keep that line and you also want to ignore that line for the next calculation so you want to ignore to be chosen as a random value a primitive number for our next iterations so to make it ignored by the loop let's set the primitive group can use or that brington number to beat zero so that for the next loop the specific line that you are looking at it's going to be it's not going to be inside it's delete node which means that primitive ID is not going to be selected for the next loop okay let's check the result now at this point one of the lines should have been deleted I'm not sure where that is maybe not let's leave the node okay nothing has been changed oops maybe I did something wrong let's first leave T go back to the object node and see okay okay something must be wrong let's checked again okay let me check so I have got the iterations from the second input should be correct and I have set the random index right here that should also be correct and if the primitive ID primitive IDs got from the third input which is from here okay let's check and for and then I have got the primitive number for the first input now let's check if this is correct this needs to be correct okay ce soir that P or the detail okay I got some values here looks okay now pts print points and I have two counts now let's also check those values I at count one okay three at County okay 3 and 3 so seems to be correct seems correct and now this one we move okay we will print set friend group okay what if I change this to two does it is it going to delete some okay let's check again now previously I had two five nine two now this one two five nine one so one line has been deleted for this one oh okay I think I'm missing one node somewhere right here okay after the copying the box I think there's there are duplicate points exist so I think I need to use the fuse or something to remove the duplicate points which should clean up okay that should do the job think now let's go back and then go back to the code set this value to three again and this value to three again not this one this one okay let's see okay now that looks correct okay okay I also got the call the same cone say thank you for that okay so by checking the final output I think the whole network is connected as one continuous network so that means you can go travel from one point to any point in the grid without any dead end I think even this kind of island here but still connected as with one line here if you set the condition to only two like this then at some point you should have some island like this so that is a problem problem if you want to let point travel through all the network without any dead end so to avoid that on setting a condition like this but it's up to you for it your purpose okay now that I have a network let's create a actually created a point animation running on top of this wireframe and before doing that I want to convert those line into more a clean line such as like for this one maybe I don't I really don't need to do that but for this kind of continuous lines currently the line is created with two steps one line and two line here but I I guess I could convert this into one line which maybe this steps is not necessarily but let me just convert this into one clean line if you have a long line continuously continuous one straight line like this let's make it one single line and maybe you can ignore that but the method I'm using is first using creating a poly path so connecting all those line connected lines as one prim continuous poly line which reduce the number of primitives then use a refine to reduce the point which is on the same straight line by checking on refine then set the first to you and the second you first you to be zero second you to be one which should delete that in between points like this and then I all's I still want all the primitives to be lines and currently this is a poly lines which is to connect a connection of lines so I'm going to split it into line again using convert convert line which might not be I mean this is really not in the necessary steps I just wanted to clean those up okay now from this network I'm going to first create a random initial point which is going to be the particle that is going to move along this wireframe path so I'm just going to use a scatter node and let's create a parameter so that I can set the number of points running on top of this wireframe and that shouldn't be that much maybe maximum 100 points is good enough because I'm still going to show the trail after each point okay so let's create a parameter inside a no no no controller with the integer name this num TT num key okay and set the range from 100 a zero to hundred okay and let's copy this parameter to here force total count of scatter point okay okay so it's hard to see here let's make this point size a bit larger okay all right now next thing I am going to create a attribute for each point for initial state so the initial state for the initial attribute for each point I'm would like to set the direction which way this point should go either upward or downward for this point also for other point and I'm going to define it as two integer values positive 1 or negative 1 positive 1 means that I would like to move that point from the starting point of the line currently the point is on one of on top of one of the line here so the positive if the direction value is positive 1 I'm and if the line is created as this point as a starting point in this point as an end point then positive 1 means that the point will go from the starting point to the end point direction so that this point will go right side if the direction value is negative then going from the end point to the starting point of the light so the point goes to the left direction if you use the VEX function called primitive prim points for lines you'll always get the first point to be the first point of the point list that you get from that function will be the starting point and the second point from that function be the end point so you can use that kind of a rule to define that the point goes either the right direction or the left direction based on the layout or the direction of line itself okay and so keep that in mind I'm going to use a point wrangle to assign that direction attribute for each point that I've created and let's say let's first create a random value like this and then from derive from the point position I think that should be okay and if Rand random value is less than 0.5 then set the integer value called Direction dear to be positive one else set the direction to negative one that's all you need to do so currently I'm setting the direction randomly positive 1 or negative 1 because I don't really care which way the point should go as an initial state so that's all you need to do for the initial direction and the next thing I also would like to set the ID for each point which I'm going to use later on for a trail visualization so I'm gonna just set the ID as derived from the PT Nam PT Nam which is a number of points okay so that's all you need to do for a initial setup for each point right okay now it's time to make a animation using a solver so that the point will depart for each particle to run through the wireframe without going backward going forward if if there is like branches choose either left or right but never go back so that looks like the point is traveling through the wire Network okay so I have connected this initialized point to the first input of the solver then for the second input I am going to connect this network line as a guide use it to define the direction for each point to move like this okay now at this point let's create some additional parameters that I'm gonna use inside us over right here inside new controller so let's go back to the parameter interface and first of all I would like to set the speed for each point how much faster faster at that point should move on top of this line and currently the lines line lengths is one equal to one so the speed should not go over one should be somewhere around point zero two point five or something maybe point five is still too fast so let's set the maximum to point two if it's point if it's zero then that means the point it's not going to move right okay I guess that's all you need for now let's also create a seed value so that you can you'll be able to change the great variation with the grid remove variations wireframe variations let's set hundred as maximum and let's set the seed to some fellow random value that's it to also set the speed to random values and copy the seed first seed value first and then go back to the remove line attribute inside a for each loop and promote the parameter right here which is for this CHF seed and then paste it right yeah paste relative reference so that every time I change the seed I can also change the variation of the grid network Wi-Fi network like this okay all right and then also let's copy this seed speed parameter so that I can use it inside a silver to move the point to animate the point of the skirt okay so far no areas I think I hope right go inside uh solver and let's write some code and again I'm going to use a point wrangle to control the point movement and let's name this wire frame travel and connect the prayer frame output to the first input then the input to which is going to be the grid to be connected to the second input of this point rango right and let's have a speed parameter connected with a no controller in the geometry no network by pasting this paste relative reference so that the parameter has been linked so that you can control the speed outside is solver node okay so let's get started now for the algorithm that I'm gonna explain right now in order to move those those point on top of this wireframe I think I need a bit of sketch to explain so let me do that right so this is going to be a bit long coding but that's going to be the last coding today so bear with me if you have a network like this and if you have a point right here which is currently moving this way because the starting point of this line starting point is right here s T this is an ad e e d and currently the direction of this point it's positive one so positive one means going from starting point to end point if it becomes negative one then this arrow weakens backward going from an end point to starting point alright so that's the basic rule in order to set the direction for point and currently I have speed parameter in order to move each point for each frame so at each frame the point position is added by this number of speed so currently if the if the point position is right here at frame one then the next frame that frame to the point position is right here around here if you if it's going moving this way and the distance between the first frame and the second frame point is equal to the speed okay so that's the basic rule for movement moving the point on top of the line now the next rule when the point has reached to the end of the line yes so if it if the point has been reached to the end of the point or maybe just a bit over to the point to the line so currently the point was traveling this yellow line right here and the point was moving from left to right like this and at some point the point should go over the line should go yeah left line then at at that moment the point should change direction to other direction let's say I have another a connection like here so this point have a choice either this way or this way so I need to find out direction I'll bite first get the neighbor geometry neighbor primitives for at this point at this position so if you try to get the neighbor position at this point you should get three neighbors which is this one this one and this one but you don't want to go back to the same path that you have just traveled so you want to remove the one that you came from and just pick the one that should be the you must pass for this point then you pick random direction it could be either this one or this one just use a random value to pick one of the direction then pick one of the primitive then if you have picked this one then the first thing you want to do is to get the get whether this direction value should be positive 1 or negative 1 this looks like this goes to be positive but you don't know because this one this line might have this end point to be right here and this one to be a starting point but bite as well so this could be starting point and this could be end point for this line so if this is the starting point and this is the end point then the direction which goes from this point to this point is negative one because going from end to start if it's by file sizes this is if this is end and this is start then you should use Direction positive one for this point so that's the basic rule in order to change the direction when it reaches to the end of the line so if you remember that rule then you'll be able to create a point movement animation by using a simple conditional script right so it's do that let's do this okay now first of all I need to I also need at this point to know that to know this I need to know for each point what number of primitive it is belongs to which means if I show up the primitive number value for if the value here for input to this means that the point which is on top of this 29 number 29 primitive means that at this point is belong to this primitive 29 okay so to find that out for initial state I think I can go back to the scatter node and then activate some of the at output attribute in this case where is that primitive Nam attribute the sauce print so that I can know that what is the number of primitives which each point is standing on so currently numbered point number 0 is on top of 20 297 the primitive ID 297 which is if I show up the ID of the line currently I don't I'm not showing the point number okay it's a bit too much well I think you know what I mean right so this is the initial state I'm and I am also going to change those value programmatically for each loop so that you know you always know that each point is belongs to what primitive at that frame so that you also be able to calculate the correct directional correct distance our correct direction also get the starting point and end point of each lines okay go back to the solver and write some start writing some code okay so I'm going to also get the primitive ID from a source prim attribute for each line for each point currently I have source frame like this okay that's going to be the current prem tip number and from this current primitive number i'm going to get the number i'm going to get to point list which construct this primitive which is currently aligned so you only have two points so and pts gram points from second input trim so as a result you should get a starting point and end point off that line using this function so pts zero is starting point of the line pts one is the end point of the line okay keep that in mind if pts oh wait you're gonna first get create a PT one which is going to be the starting point pts 0 and PT 2 pts 1 now i'm would like to change this value by salsa vice versa if so that the point is going always going from PT 1 to PT 2 whenever the direction is either positive or negative but this only works when the direction value is positive because currently the front if it's going if it if the point goes from point 1 to point 2 then that means the point will go from the starting point of the line to the end point of the line right here and the direction itself it's derived from i at direction right here so this only works if this i direction which is this attribute at point is positive is plus one so if the direction is negative then I want to switch this PT 1 to pts one and PT 2 2 PT s 0 so that if T Direction is negative and if the point goes from PT 1 to PT 2 that means the point it will go from the end point of the line to the first point of the line ok I have a comment is it better to better do this thing's with sandal like pca turret where point is own ladies like pc open okay i sorry that was I didn't follow that I'm lost where that part is but there is always a better choice I think so please use whatever better choice do you think it is this is this is just my brute force way never a efficient way so yeah always do the better things and be sure that my way is not always the efficient way and I tried I tried to do that but sometimes not Santa is not that efficient there are many ways that I don't know so sorry for that okay so now that I got the pt.1 and pt.2 ids pill point numbers i'm going to get the actual point position from those point number using point function at PG 1 point PT - okay that's crazy now the actual direction which goes from position 1 to position 2 can be calculated the vector itself can be calculated but by just subdividing position to by position 1 so that the result will be the vector that you want that specific point that you're looking at do you travel to move so it's named that valve as a velocity and stopped by position to by position 1 and let's also normalize this so that the distance of that vector will be 1 and multiply it by speed so that this is going to be the actual traveling speed at specific direction which you want the point to move to right now you can update the point position with this velocity so that at for next step the point will move to that direction that you have just chosen whereas aspects Vic speed value now let's try this out by applying it updating the script make sure that the speed is connected speed parameter is linked and let's go back to the object node and it's also shoulder network like network as well as the point and see if I play it ok something is wrong obviously okay yep so wrong okay let's check so spring numb if I have this value correctly okay going back to the point Rangel so prim numb that should look okay and three TS let's check if this is correct yeah this looks correct okay this one this one should be one because I I was deriving the line position from the second input so this should be the point position off the end point and starting point should also be derived from God get it from the second input so this both should be written as 1 and ok let's go back again reset the simulations and show up line and see okay I have some cached points right here let's go back sometimes solver keeps lifting those unnecessary values which I want to remove but it's keep and I don't know how to fix that okay but I can see that the point is moving based on the Rhind election that the direction derived from those lines you see that so for this point starting from this point going right side and leave the line still keeping the moving like this so first thing first thing is done after I make this point goes over one of the line that was traveling through then you want to stop this line at this position and then change the direction to the other so that which this point will run through the other lines other connected lines other neighbor lines at this point and try to avoid going backward so when the point comes at the corner of the line and point off the line then I want those for each point search for the neighbors which is not which doesn't include the previous primitive down that the point was on but fine for a new primitive and also find the correct direction either this direction will be positive 1 or negative 1 if it goes from here to here by checking the starting and end point index for each primitive each neighbor primitive so let's do that next and I would like to throw some questions for you guys if there if you guys know how to reset those cached point when I use this solver sometimes it gives me this cached one and sometimes it just delete it if I go back to the object node but sometimes it is kept left like this which I don't really like but I don't know how to remove that if you guys know how to do that I'll be great ok let's continue writing the code so now I'm going to create a condition when the point has reached to the end of the line so to check that let's write some sketch right here so let's say I have a line here and the point is moving the point is moving oops why am i using yellow okay point is moving this way and if the point has been go over the line how to check that now what I can think of is to create two vectors and calculate a dot product of that two vectors to check whether this point is on top of the line or not so the first vector is starting point the starting point of the line here to the end point of the line here so this is the first vector back to one and the second vector that I want to create is from end point of the line to the actual point position so that is vector two so in this case in the top case this is vector one and from end point to the actual point they suspected - that means the dot product of vector one and vector to you if you calculate the dot product vector one vector two if the direction is the same such as this one then this is going to be positive and if the direction is opposite such as this one then the dot product is negative so you can check that the point is outside the line by creating those calculating this dot product if so if the dot product of this vector the line vector drive on the line and the vectors from the end point of the line to the actual point is positive which means that the point is outside this line so this is how I'm going to check if the line is on top of the line or not if it's over the corner or not right so to do that first I'm going to create another vector which goes from the end point of the line to the current point position so you can I'm gonna name this see bell current velocity to using normalize at P this is the current point position - position - which is the end point of the line so you just need to calculate the dot product between this velocity and this velocity this vector to check if it is positive or not if it's positive then it is over the line so I want to change the direction I want to switch the point direction to the next primitive see bell it's positive then first of all let's move back this point position to the last endpoint of this line right here so that it will not go over the line I first stick that step back stick that back to the end of the line then next thing I'd like to do is to actually calculate which way should this trimmed should this point go and to do that first thing I need to find out how many neighbor primitives are there at this corner in in the condition that I made previously there should be either one or two neighbors which the point can go and by reducing the previous primitive that point was was on top so first of all let's get the number of primitive at the end point which is same as getting the neighbor values at Pt - ok now I'm going to get the number of array of primitives neighbor primitives by using a point Crim's and I'm have to check the second input because the second input is the actual line network and using PT 2 which is the end of the line okay so as a result you should get the number of primitives at each corner at each corner that point has reached - and sometimes it could be 3 sometimes it could be 2 now next thing is to reduce the primitive number which you have came from so first I'm going to create a for loop and to look through all the primitives to check ok so the current primitive is you already have that information which is at this source prim attribute right here and you have named it as prim in this angle so you can check if this neighbour primitive is equal to that or not if it's not equal you can use that for a next path if it's equal then that means if you use die that means you you're going backward you're going back to the same path so you want to ignore that you want to avoid that so you need to have a condition saying if any prime is not equal to 4 in which is the current source trend number derived from here then you can use that and print for next path now there is a chance that there's a chance that there is only a one neighbor connection in this case or maybe there's also a two branches at this point and I cannot just pick random one at this point so I can either make a random condition right here or make a bit overwhelmed way to choose if I either I should choose the first one or the second one but I am going to use the open world one now first I'm going to create a throat array to store the random value that I'm gonna use it later on to for random shuffling the list know that this is one other techniques that I think you can use for other purposes so maybe it's a it's a good way to create it's a good way to know that how to make a shuffled list maybe there's not a way always and I am also going to create a array to store the actual primitive number which is for the end frame so first I'm going to store the end frame which is not equal to the current primitive the previous primitive so in the end you you should have array of 1 or 2 sizes and at the same time you also would like to store the random value at inside this array float array like here and use it as a shuffle ordering guide to shuffle this primitive later on list of primitives right on or maybe not maybe not maybe there is a better way to do that ok ok yeah I'm gonna just do a easy way I'm just going to create a list to store the primitive neighbor primitives like s primes and store all the possible neighbor primitives insiders and sprains and after leaving that I want to get the [Music] random and I want to create a random index to choose one of the primitives inside as s prims so let's create a random index random index using random and can be the seed itself can be derived from multiple value like from the point position where they fixed constant value and currently if this is maybe you can also use the PT known as a seed also multiplied by some value plus since this is inside a frame this is the insider solver network I can also use frame maybe there's too much of a seed but think that's fine so by creating like this you right now you have a value from 0 to 1 as a float number and multiplying this by a length of s frames now so if this is 2 then you have from 0 to 2 for this one if it is 1 if you have 0 to 1 for this one and finally you want to make it as an integer so I'm gonna make it 4 so if you have number of primitives inside s Prime's as 2 then you have you should able to get a random value either 0 or 1 okay and if it's only 1 then you'll always get 0 as this equations with this equations which makes a random index for this s prims and finally you can get this picked as prime neighbor prims with this random index and that is going to be the next print at that point should move to travel to so that means I would like the first thing I would like to do is to update the saw spring right here for each point with this picked neighbor primitive number yes and the next thing I'd like to do is to get the direction so that I can change I can also change this I at Direction attribute for each point either this should be a positive or negative to do that I need to know that at position 2 which is the end of the connection of the first movement of the point at the corner of the point you want to check if this position is at the starting point of the line or the end point of the line which will changed this value if so let me make a sketch again so you have the point has travelled through the lines first lines and came here and you have find out that the next primitive is this one next primitive now the next thing you want to know that either this point position of this line is starting point or end point this one is starting point or end point if this is starting point and this is end point going from start to end then the eye at Direction is positive if it's by salsa then the eye at direction is negative so that's a rule here so to check that out I need first thing I need to do is to get the neighbor points at this for this not the neighbor points the point that is constructing this s prime line s prime number so let's get there was two long two points using frame points that I've been using a lot today from the second input always don't forget this one okay is s prime all right and then let's get the point position actual point position for the first point and the second point so the first point is SP TS 0 let's copy this second point is 1 right now now I can just check the distance between this position two with s position one is position two or maybe doesn't have the position two it could be the current point position it's just the same right so if the distance is far if the distance between point and s position one and if distance between the point and s position 2 if either one is far then that means data is d that is at this position if it's close closer if the distance between the point and the S position either one is closer than that s position is at this point so create akin condition distance @p s plus 1 is less than distance s plus 2 at P so this means that this is closer to this is this is shorter this distance is shorter than this one means means that s position 1 is closer to at P which means it is kind of a pretty much equal to the position P at P which makes this a starting point which makes this position is starting point and the end point BD end point of the line so the eye at direction will be positive else the I direction will be negative okay and I think that's all you need to do to set the rule okay think that's fine and let's check that out go back to the solver and the geometry node and then start playing and I still have a cache here okay I really don't like this cache okay let me just delete that cache trying to delete that cache I don't know how maybe I can cut this paste this okay let's delete it right now let's play this point animation by also showing the line network at background okay why am I seeing it know okay let's try it's played us and see if the point is traveling correctly and yes it is not going over the line it is changing the direction and it's not going backward every movement seems correct for each particle yeah I think that's correct I think that's good and if I change the value speed the value of speed here the point should travel much faster but still is running on top of the y frame okay looks good looks good right right if I make it slow it should still work okay now that is the main part of this tutorial after that you can just create a trail using a trail node let's set these trail lengths as a parameter so that you can change how much this point left the trial points so let's give a new parameter integer trail length trail things set let's set this maximum 200 right and then set the trail copy this trail lengths to a like you oh thank you very much for the stripper chat Aleksey okay now let's try this with the trail okay yeah I see a bunch of points traveling like this now it's time to connect those points as a line and if you check this point attribute for each point the same same trail has same ID like this so that that was the reason why set the ID for each point initially okay so let's use those ID attribute to connect those point together by using add note set the go back go to the polygon have by groove by attribute and set ID okay okay now the point has been connected as continuous line and if you want to reduce the number of points because currently you have a bunch of lines in the single straight lines you can use the same technique before using refine and refine set it down refine first you to zero second you to one so that it will be more simple polyline network but this might be expensive for you so it's up to you but I'm not going to use this because I want to also set the color for gradation of color for this line and to set the color I would like to give a new value for from here to the starting point of the trail to the end point of the trail from zero to one so to do that I guess the easiest way is to use a resample maybe not the easiest way maybe not the efficient way but I'm going to use the resample and and they set the lengths here same as the speed so that you you should have the same number of points as before so let's copy the speed paste it right here the reason why use resample is to have this curve view attribute which gives you the attribute for each point from starting point to the end point from 0 to 1 so by using that I can create a simple gradation of color from 0 to 1 using attribute ran from attribute curve u and let's check which way is going so the head part right here is this left side color so let's say this set this the white the right side to black and make middle something a bit more black color like blue and let's also set the background how the material options for the display to be a bit more brighter and if you pray back again you have a line trail a bit more prettier than before let's make this faster okay and maybe reduce the numbers okay yeah maybe this is too much okay oh my mouse has been stopped wait cannot move my mouse okay what's wrong with my mouse okay I'm gonna try to do it with my touch best hey wait give me one second try I'm gonna try to change okay no watch okay okay now the final step for the final step I'm going to thicken this trail with poly wire and that's the final step poly wire connector where's this coloured line and also let's try to change the thickness of the trail by the curve you attribute so I'm going to use the expression for the wire radius you may be using a point P input at Petey name of the attribute is curve you and get the first value multiplied by point zero five or something [Music] maybe I should reverse this value like this so that white one will be thicker okay and remake this removes shaded and that's it you can change the length of the trail by going back to the no controller changing the trail lengths to make it more like like a fish-like movement or make the trail lengths a bigger to make it more sci-fi like Tron like trail on top of the traveling on top of the wireframe you can also change the speed you can also change the number of points traveling on top of this wireframe make it longer and that was the case for the box grid but you can also change this whole wireframe grid to anything else any other wireframe pattern like you just need to switch this with say torus and make this a bit this and just connected with the convert line here which should create a wireframe network like this and by using this for each network for each loop the network is going to be reduced like a maze like this but still able to travel from one point to one point and then use this finally to give a trill and for this one the techno sets a bit too big maybe and maybe I should raise the scale up a bit just a big like this and maybe you can also increase the number of points running and have some interesting wireframe trail sci-fi like wireframe trail like this ok so that it that's it for today's tutorial it took like an hour and 40 minutes today was a bit long but I hope you find this interesting somehow helpful for some of your project that will be great and if you have any questions please feel free to throw anything I know that some of the part that I explained is a bit too much too long I will try to be able to explain the algorithm a bit more simply shortly okay thank you thank you everybody for a comments and also for a super chat today that was the first time I got taking I think you can also use this for something like pig head my pig head has many like lines here so it might take a bunch of time for initial setup right here I have like five thousand six thousand lines here so it the calculation is a bit takes it to a bit much here so I I guess there's a bit more efficient way to do this stuff if you could find out please let me know okay got a reason okay I have a question is it possible to make it a perfect looping animation now right now I'm using a random value in order to change the like the branch direction so right now the it is the the current setup is not for the loop animations but by controlling the random seed I think it is possible to make it as a loop animation for sure but I guess you need to pretty much control the path where the point should go because if you have multiple points and you should be able to control for each point to come to the same point at same frame maybe from 1 to 240 the point that all the points should be comes to the same position so to do that I think need to change a bit of setup inside here I don't have a specific idea currently how to do that but one way is to use a frame value / end frame so that you'll have a value from 0 to 1 and you can use somehow use that to reuse that for random C value or something maybe a using a wave function like sine wave with a sine wave so that if you use sine wave then if the value will start from 0 and then when it gets to 2 pi then the value goes to 0 again so maybe that might be a hint to create a loop animations but currently the current setup is not for the loop animation so yeah I'm not I don't have a direct answer for that right now sorry for that I guess there is a way but there's gonna be more control you need for maybe more scripts you need to write if you're interested in that maybe I can try to think about that and create a additional file for that kiss okay yes they have answered your question you could predefined the points in their past too so that they all arrive at the start point positions after an integer amount of edge transition oh that might be a good solution hmm interesting I might also want to try that out myself thank you for answering that any other questions if not I'm think I'm going to end this live for today if you if you're interested in how to check how to if you want to check the file itself you can go to the video description I have there's a link to this file that you can download from a github repo repository please check that out to see if it's helpful for you okay I have abused this pig head network and the network the traveling is a bit mmm not too clean maybe there's speed is too fast or something like that well it also depends on the quality of the poly wires if it's just lines maybe that's much better yeah okay well any other questions if not let me in this tutorial thank you very much always I will do another tutorial next week at around the same time Wednesday 9:00 p.m. jst with different kind of topic that I found interested right and if you have any requests not creating that thing is something that you're interested in then please also let me know oh it's always welcome okay okay thank you very much I see you next week hopefully and have a good night right you you
Info
Channel: Junichiro Horikawa
Views: 2,299
Rating: 4.9652176 out of 5
Keywords: houdini, sidefx, live, tutorial, procedural, procedural modeling, parametric modeling, parametric design, parametric, fabrication, digital design, computational design, 3d, design, isosurface, lattice, structure, 3d modeling, modeling, wall, computational, generative, line drawing, drawing, illustration, fractal, lamp, vase, reaction diffusion, celullar automata, simulation, trail, particle, vfx
Id: OxoIrMf_Xf0
Channel Id: undefined
Length: 113min 50sec (6830 seconds)
Published: Wed Jul 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.