Houdini Algorithmic Live #063 - Pac-Man Garden

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so okay it's around time it's 10 p.m in japan time so i would like to get started um hello everybody so this is stranger horicawa and i am i'm going to do this weekly houdini tutorial and the topic for today is to create a bit a fun project rather compared to other stuff that i've been doing which is this kind of stuff creating a small garden for a pac-man to run on together with these ghosts and one thing about this is that you can change the geometry where the pac-man runs so you can change the geometry to run on top of any kind of grid like these or you can even make it inward running inside like these or of course you can make it as a grid as well which i don't really have a maze for this one so it all everyone just moves on like every grid every possible grid but that's what i'm going to create today and and i'll show you how i created this one and the logic under this one is pretty simple but might take a little bit of time to implement so feel free to join or leave anytime i might it might take some time to complete this one but i think it's going to be pretty fun so let me first explain how i came up with the algorithm so first of all it's easier to think from a grid like these and first thing i'm going to do is to it doesn't really have to be like a square grid but any kind of like mesh mesh is fine and the first thing i'm going to do is to create a network in which direction can the pac-man can run on run through meaning in this case i'm going to connect the center of the of each primitive or each faces like a network like these and this red line is actually the path for the pac-man or the ghost currently i didn't really make any interaction between goats ghosts and pac-man it's just the difference of the variance so it's not really uh it's not really interactable it's not really like a game it's just a installation kind of but still fun okay so after i have created the path like this for the pacman pass what i and what i'm going to do next is to pick several starting points for the murder agent which is going to be the pacman so let's say this point and this point at this point has been chosen maybe this point also has been chosen as a initial position for the pac-man or ghosts okay now uh the next thing you want to do is to define it in which direction does this each of the pacman would want to go on top of this red path okay and the important thing is that when for example when this pacman moves to this directions then you cannot really move the one that's right here downward as well because it's going to crash okay which might be okay if it's a combination between ghost and pac-man but it's going to be really complex with those i'm just going to apply a logic that whenever there is one agents going into a site then this block has been blocked this cell is going to be blocked for the next candidate for this one to move for the other agent to move so this one cannot go downward but instead you have it has to go either left or top okay same for these um this could go to in this case can go to anywhere i mean it can even go to the right side because this one right agent has just moved to the right side so you have an empty space left so this can actually go to the right side okay and this same for these it can go anywhere so the key point is how do we block how do we prevent each agents to be cla crushed okay and since we are going to make an animation a procedural animation like the one that i just showed i don't really want to use like a for loop for each point to decide each which direction should point go and counting one by one because if there's tons of agents to calculate then it's going to be a tons of calculation so um as much as possible i want to use the multi-threaded calculations like using point wrangle or primitive wrangle and i like that so to do that first thing i'm going to do is to separate the cluster of agents based on the the order and when these agents can move for example if the agents have at the same point this point this point this point and this point with those paths okay as i said this one this one and this one is close to each other meaning we have to think about which ones goes first and which ones go which can go next this one i think it doesn't really need to care about because there's nothing in here so first thing i would do is to pick the one that's free from the nearby agents as a first candidate okay uh put it in the list as a first candidate and i'm also going to pick one of the agents as the first candidate from here and let's say i'm randomly going to pick this one right here then if i choose this one to be a candidate then i think it's safer to prevent this one goes move at the same time okay meaning if this one moves to the right hand side and then this one moves the left hand side this will obviously crash so to prevent that this agents wouldn't crash with these one i think these block as an obstacle which this agent cannot move to so keep this as a second candidate to move okay now after mate make this one as a second candidate then we're going to check the other agents which is this one and see if this will be okay to move into this direction distraction in this direction and looking at the other first agent and i think it's fine so this can also be the first station okay now that you have a first candidate for the asians to move then after you have moved those agents then you can go to the second one and keep doing it until you have all the agents to be moved okay and i am going to repeat this one until each of the agents go to the next grid in specific frames like 30 frame or so like taking one second to move and then for the next 30 second i'm going to do the same thing over and over again try to estimate which one goes first which one goes next and which direction should each agent move okay so that's the main part main key main concept here and most of the stuff most of the difficult algorithm that i'm going to implement is about this one and all the other stuff is based on creating these like characters funny characters which is not that hard i think so let's do that let's try to create that logic from scratch and i've just done it yesterday and i don't really remember what i have written so i'm going to look at the code that i have written previously to see to follow what i have done okay so let's see and and if you have found any questions if you have any questions please throw anything you would like all right so first thing first i am going to create a grid which can be anything with i could start from three-dimensional or two-dimensional but i think it will be easier to start from a 2d grid so let's just do a 2d grid and later on i'm going to make this unable to be used as a 3d three-dimensional geometry to see to transfer from 2d3 okay so um after i have created this grid the first thing i wanted to do is to first create a network so this grid is the the cell that each agent in this case a pac-man would move from to move to and the path of the pac-man is going to be the center the connection of the primitive from center to center center of the primitive to the center of the primitive on the neighbors so keep that in mind let's try to create that and to make it to make well let's just see let's just try to create those and i am going to create it let's see what will be the best way to do let me check so so first thing first i think and i think using a point where angle makes sense in this case so let's try to do this and there is some rule here let's check let's see that we are going to check at each point right here there and what i'm going to create is a square or triangle grid a triangle shape for each point except for the borders okay for example for these points i can check the neighbor primitive for this point and create a square like these and the edge of the square is going to be actually be a path connecting the center of the primitive the other center of the primitive if i try to create the path i mean try to create a square at the border then there's not enough points which in this case there's only two points two primitives from this point so what i am going to do is to ignore all the points which is on the border and only creating these squares at the center the interior of interior points so let's see i am going to first delete first going to determine which one is the border point okay by using the group i have a questions from get diminished qld kiss uh any ue5 video coming soon from you uh yeah actually i did created some workflow to bring a animated geometry from houdini to ue5 use together with a custom attributes other than point normal or colors so i think yeah i could make some video for that maybe later this week or weekend if that's okay okay so i'm first going to create a border group for the point which is at the edge i'm going to use this include my edge and share the edges all right okay now what i'm going to do is to ignore these border group to create the square okay for each point so i think i have to make this group previous 2d point wrangled and for this one i'm going to say create path okay now let's see so first thing first i am going to get the the primitive the neighbor primitive or the connected primitive to this point and what i would like to do is to get this path in an order either clockwise or counterclockwise so that i can create a square from this point to do that i think the best way to do that is to first pick one of the half edge from this point which can be either this one this one this one this one let's say i have picked it this half edge okay if i have picked the first half edge then from this half edge i'll be able to get the primitive belongs to this half edge which could be this one and by getting this primitive i can also get the the next half which belongs to the same primitive which is this one and then from that half edge i can get the equivalent half edge which belongs to this primitive and if you continuously doing that you'll be able to get all the primitive in a clockwise order counterclockwise order i don't know which order it is by getting the half edge equivalent or half edge previous but i think that by using those half edge logic you'll be able to get the uh primitive in an order okay so let's do that first thing first of all i am going to check if the neighbor primitive count for each point is more than two because if it's less than two less or equals to two then you cannot create any primitive you at least need to have three points in order to create a triangle or square okay so let's get all the connected polygons first using point prims prims at pt num okay then i'm going to check the length of the polygons if it's larger than 2 and that's the case where i want to create this square or a triangle it could also be used for the remeshed geometry where you only have triangles okay so first thing first i am going to get the half edge from the point different so i'm going to create i'm going to get the first half edge by just using the point hedge point h edge at ptnum which will give you the first half edge belongs to this point okay now from this half edge i can then get the this primitive belongs to this half edge so let's get that ram is equal to hedge frame from this half edge number okay now uh from this uh heart from this primitive then i can get the the next half edge let's say i have just retrieved the this primitive from this half edge right here so this is the source point of the half edge this is the destination of point for the half edge and this is the primitive now the next off-edge value or index that i want is this edge right here which belongs to the same primitive okay now to do that to do that um i could actually i think i don't really need to use the primitive self but i could directly use this half edge value by checking the previous half edge for this one which is going to be if the if this one is the source and if this one is the destination and this is the primitive then the previous half edge is going to be from this point to this point okay because the half edge always goes around one primitive from source to target from source to target from source to target from source to target so if this is the source to target and this is the half edge then the previous half edge should be this one going from source to target okay so and a previous half edge is equal to edge previous rev zero fetch okay then from this uh half edge the one that i have want to get is the half edge for this primitive which is going from this point to this point so you can get that by using a half edge next equivalent functions so if the currently i have the half edge going from this point to this point but the one that i want next is from this point to this point to the opposite direction in order to get that i can use the hedge next equivalent for from this pref h okay and now i have the next half edge okay and by continuously doing it for all the primitive you'll be able to get all the primitive numbers and then you can also create get the center point from the primitive to connect to create the square so i do have a primitive right here so let's also get the center point let's name this pause and get the center point from the primitive like this all right now i am going to add this position as a new point using at point zero position now this point has to be the vertex for this new square that i'm going to create so let's also create the primitive new gram is equal to add trim zero poly then right after i have created the point i'm going to use the add vertex add vertex to this primitive with this point number and i think i have some errors here i was missing did yourself okay now okay something looks wrong here let me just try to disable this one okay so the problem here is that i have just done a first loop i mean the first iterations but i have to continue is continuously doing the same things over and over again and if you have four primitive you have to continue doing this for four times so let's also create the for loop somewhere after i have created the new primitive so four and i until the number of neighbor primitive oops zero lengths of police okay like this and since i am referring to this half edge in the first line of the loop i have to update this half edge and the last of the loop by using this next stitch by updating with this next edge that i have found out as a next half edge okay now let me just save this somewhere so that i don't get i don't lose the process okay now next um let's see what what i need to do next so i do i did get the half edge right now uh let me also remove the the primitive that i have just referred to which i don't really need anymore i think so let's just do it inside the loop by using remove rim 0 prim number okay okay i think i just lost all the geometry so i think i'm i'm missing something here so let me see okay uh first thing i was missing is that i need to ignore the border points which i didn't really do that so first of all i'm going to create the filter right here okay and now let's see so i have just get the point primitives and i'm checking if the number of the polygons connected to this point is more than two let me just check if i'm getting the light correct value right here release and go to the geometry spreadsheet for each point now i should not delete anything in order to debug so let's see so i have this police yeah i do have values being created so i think that's fine although not all the point is being used all right let me just disable these one which is creating the new points and check with these okay so it seems correct seems okay i think these empty areas is just the one that the water so i think these are okay so let's go inside to check what's wrong here so i have this point a half edge getting the half edge and i'm getting i'm you creating a new primitive right now and for each uh loop for each polygons for each neighbor polygons i am getting the uh primitive versatile primitive from the half edge okay then getting the position which is the center of the primitive then at that point as a then at using at okay this is the problem here this primitive is not the one that i've created but this is the one that i've created new print okay so make it right here okay so something has just happened so let's remove the original geometry to see what happened okay looks pretty much the same but the difference is that previously it was like these and by using uh i've just created the squares which connects the center of the primitive like these okay and which is going to be used as a path later on all right so looks good i think let's also make some let's also set a group to these geometry just in case i can separate those later so set trim group zero path for this new prim as one right now let's fuse to merge all the connected points and then convert it into a line because i am going to use it as a path for the pac-man to move all right okay so uh the first thing i like to do now is to set some initial attribute to this path for example [Music] the one that i'm going to use like i'm just gonna create i'm gonna create a new attribute using attribute create i'm gonna explain later how i'm going to use it but the first attribute that i'm going to use is the current starting from negative one okay so the current means um current uh it's the point which is currently used as the moving agent which is either ghost or pacman okay another one which is going to be the next so the next attribute is going to be the point number where defines in which uh neighbor would the current goes to pacman would go so if the pacman's right here and this this point number is the current point number then for the for this next one it's either this point number this point number this point number this point number where and which which defines the direction and which direction should this mover agent would go okay that's the next and can go num which defines if the point can go can move or not which would start from minus one as well okay all right okay so these are the initial attributes i'm not sure um i've done it like temporarily so some of the attribute might not be necessary but let's just say it's necessary yeah i think it would work without these uh initial attributes because if you don't have anything then it will just create automatically but let's just say these are the initials all right now uh next thing i would like to do is to create a initial a movie point okay which is going to be set as a pac-man or a ghost okay so let's try to do that i'm going to create a bunch of points on top of the this path node i like getting 20 of the point and then also uh out of those 20 percent i'm going to set like 10 percent as a pacman and other 90 as a ghost or something like that okay so i'm going to use the another point wrangle let's name this set init mover okay now uh first of all i am going to create a parameter which is going to be used as a percentage how much i want to use this grid point as an initial point position for the ghost or the pacman to be appeared so let's just name this threshold i don't know appearance or just gonna say thresh okay and it's going to be a from zero to one if it's one then hundred percent of the point is going to be used if it's zero none of the point is going to be used okay let's also create a null controller to have all the parameters that i would like to control later on all right okay one question i would like to throw you guys if you are interested in like connecting houdini animation and unreal 5 engine [Music] do you want it to be do you want the video to be recorded or do you want the tutorial to be on live do you have any preference that if you have please let me know if not i guess i would do the recording i guess okay so what was it appearance appearance or mover ratio okay from zero to one okay so point two let's start from point two okay so either ways okay so then i'm going to think about you doing it on the recording since in live it tends to take much more time than the recordings because i don't have any way to edit it okay so now that i have the threshold let's do the random value for each of the points so using rand at p [Music] and maybe you also want to have some random seed as well it's less than the threshold then you want to create a point okay which is going to be used as the mover so into add point i'm just going to create a move a point at the same point position the same node point position now uh first of all i am going to set the group so that i can define that this is a river group okay at pt okay i think i have some errors here thresh if okay i have to close the randomness all right now let's just see if this has created the point or not i'm going to try to color or maybe use the copy to point to check if the mover point has been created and i'm just going to copy this to the mover target okay so that's the number of murderer that i've just created which looks good so let's continue with these now i'm also going to create another um random ratio which is going to dip which is going to defined uh which is going to separate the mover between the pac-man and the ghost which is not like critical stuff but just for fun so another randomness using that p plus some other value plus the same seed value which should create a different value and smaller than maybe another threshold which in this case i don't know pac-man ratio ratio okay and i'm gonna make this 0.2 it should be here as well okay well also since ue5 is in alpha i assume it's a bit unstable you don't want it to crash on you during the live stream exactly exactly yup it didn't really crash at this moment when i have tried actually houdini crashes more than a real five but like you said it's unstable still unstable and the rendering for the unstable topology is not that great so yet so probably those stuff is going to be much better in later but still i'm going to show you some process which could be pretty useful okay so what was the name pack and ratio okay from zero to one let's make this point two as well oops copy parameter right now for those point which is less than 20 percent let's set it as um let's set the variant attribute which later on i'm going to use it with the point uh copy to point group stop node which is this one so co set point attrib as variant to this pt as zero so zero is the pacman now else i'm going to set it as variant as one which is going to be used as a ghost okay now let's see and the next thing i would like to do is to um set the the network node where the agent has been postponed as the current node or current attribute or i mean the current node so and this current node is going to be the number of this mirror point okay which is this one that i've just created so set point at riv zero current to no actually actually what i'm trying to do is to copy the current point number from the node to the mover so the mover have all the attributes the current next and what was it next current next and can't go num can go num and so on okay so i am going to copy the current point number from the node to the mover point so i should write like this right now in this case i am working with 2d grid so it's not really necessary but just in case i'm going to transfer think about how that i'm going to transfer this into a 3d layer on i'm going to try to get the normal direction of this plane as well and set it to a mover point so to get the normal direction i can go back to the original geometry somewhere around here maybe this one right here and since i'm going to create the initial geometry like a grid so probably the resolutions of the geometry is not that high so just in case i am going to subdivide this geometry a little bit to make it a bit smoother one or two maybe one is okay then calculate the normal for each point because i want to sample the normal direction from this point now connect it to the initial mover edit mover go back then get the normal direction from the second input by sampling the using the uv okay so what i'm going to do vector known as the co2 uv sample from the second input normal direction using a p as a uv value okay by doing this one you'll be able to get the normal direction from the second input then i am going to apply this to a mover as an attribute so set attribute setpoint attribute set the normal direction for the move a point with this normal direction okay what else now i would also uh want to create the initial direction where this mover would want to go for probably or do i need that let me think i might not yeah i don't i don't think i do need that yeah let's just leave that okay so this is the initial setup okay i have a comments ue5 will be all awesome this is asking a lot both maybe do the recording later and later after allowing us some time to follow the video and try it out do a live exploration of your creation with queueing q a uh yeah if that's uh necessary i could also do that probably but the thing that i'm gonna show is not not that hard to follow i think i mean i ha there is three ways i mean mainly three ways to achieve it if you already know some technical terms i can just say it right now first of all the first thing is to use the alembic and instead of using the color attribute you can just change it to the other attributes but the problem is that it's only limited with one attribute so you cannot really do much more than that another way another way is to use the v8t using your vertex animation textures and there's a component for the houdini called from the side effects labs which call which can you can export the vertex texture animations vertex animation textures which in default you can only export the position color and normal maps i think but by tweaking a little bit by hacking it a little bit you can export like as much attribute as you want as a texture and use it as a inside shader for as an additional attributes so that's the main part now the last part is a bit more hacky since i found out that the some of the geometry especially if you use the side effects labs v80 component or node there is a bit of still a bit of problem by when you want to create like a fluid shape non-topological shape non-non-topological stable shape the the rendering looks a bit messy if the number of the vertex is the same overall the time frame then you can use the soft setup which can which you can create a really clean animation but um the problem is with the fluid it doesn't really create a clean animation so instead of that i am trying to create another method for myself which might be too hard for everyone to follow so but for that i'm trying to combine both alembic which creates the smooth geometry as well as the additional like texture to use it as a vertex animation vertex animation texture so combining alembic together with the v80 that's the third option which might be too like hacky and not too friendly for anyone but should create a bit more better result but i'm thinking to show you the second option try to hack a little bit the v80 to be able to use many uh attribute as possible okay so that's that so if you have any technical like um imagination how it work maybe you can just do it by yourself from what i have just said all right okay so did you try uh did you try using hdas and houdini engine with unreal yet no actually not i haven't used the houdini engine uh for unreal i have used it for unity i have checked if i can use the houdini engine for the animation but it seems a bit too tricky so i haven't really touched that touched yet because i wanted to bring the procedure animation but it did look cool that you can do the modeling inside a game engines but unfortunately we the engine cannot be shipped when compiled so it only works on the editor so that's the kind of a downside i guess okay so where was i so i have just copied the normal to the mover attribute now the next thing i would like to do so this is done the next thing i am going to do okay so the initial setup is done so i'm going to get inside the solver to actually create some animation okay so this one goes to the first input and for the second input i think i will need this base geometry to copy the normal direction again for the mover if it's 2d then it doesn't really matter because the normal direction is always facing up but if when it comes to 3d this geometry is going to be important so that's that let's go inside and let's try to create this procedural animation all right so first thing first i have i am going to create some several switches when when does some operation happens and when does when does the specific operation not happen so there is mainly three steps uh that i need to do okay first of all for each like three frame or 15 frames the frames you specified like maybe the if starting from the first frame the frame one then for for every 15 frames you want to move the mover from the first point to the next point and use the spend 15 frames to do that then for each 15 frames in this case 1 16 31 and 46 and so on i need to refresh i mean and recalculate which direction should point go from the current point this if the current moving point is right here then you have to decide which point which direction should move go and as i said if there's uh if there is multiple points blocking to each other then i have to decide which point which collection of the points should go which uh decide first where the where in direction which where they can go then pick the second group so that they can decide where they should go next then pick the third and and so on using a loop to decide okay so that's what i would like to do and the timing that i need to do those calculation should be every like at any time the point has come to the first point or the edge of the point or on top of this node okay so let's say every 20 frame for now i'm going to create a switch and let's create some expression if the current frame and module modulus 20 now this 20 should be better if it's being parameterized so i'm going to go back to the controller create a frame parameter like moving moving step moving frame moving step frame okay from 1 to 50. okay as initial value i'm going to set it as 20. copy this one go back inside paste it right here and if it's equal to one then that's the timing we want to run the initial initialization code to decide which point which direction should point go okay so let's connect this right here okay now if it's zero then if this value is zero meaning if it's two three four five until 20 from 2 to 20 i would like the point to just move which the point should be on top of this edge moving from left to right or right left bottom to top and so on when it is equal to one then that's the timing when where the point has come to the end right here or right here and on top of this node okay so when the point has come on top of the note then i have to decide uh which direction the point should move to so let's do that and to do that as i said if you have a multiple number of mover agents i have to collect a bunch of points together to pick the first candidate second candidate to decide its direction so i'm going to use the for each loop by using a number okay and probably creating as a feedback loop makes sense so make it feedback each iterations fetch feedback connect it right here connect it back to right here okay so currently it's a bit hard to see which one is the moving point so let me just colorize those river point so i'm going to use the color node and set it as yellow it's a bit hard to see is it is there any point let me check yeah they are cannot really just see it let me scale up a point size a little bit right now i can see it so i think i guess these points are the one that i'm looking for is it maybe yellow is a bit too hard to see make it red okay now i'm going back inside the solver um first i'm going to connect with the new node later on i'm going to use it to decide when to stop this for each loop because you don't know how much loop you want to do this one okay so let me just name this stop and later on i'm going to check the detail attribute from this new node to see if the loop can be stopped or not for now let's just ignore this okay no now um the first thing i would like to do here is to check all the points and see if the point can uh would um see if this current point can go or move next as a candidate okay so for example if i look at these points right here you see that there is bunch of neighboring points now i'm going to randomly i mean i'm going to just use a point wrangle meaning i'm going to simultaneously check whether the point can move and you may ask if if it's pot i mean how is it possible to check if the point can be moved when you try to calculate the direction simultaneously well i'm not going to calculate the direction at this point i'm just going to check if the point if the point that i'm going to use um i'm going uh the i'm just going to pick the point as the first candidate to move okay to do that i'm going to for each of the point i'm going to pick the point positions and also get the neighboring point and if there is a neighbor from this point let's say i'm looking at this point and if there's a neighbor point from this point then i'm going to check the point number okay smaller or bigger okay and i am only going to pick i'm going only going to set the uh set it as a candidate when the point number is either smaller or bigger maybe let's say the point if this point number is smaller than those point is going to be used as an x candidate and if you do it for if you are focusing at this point and let's say this point number is smaller than this one then the result the result of this comparison will be the same even if you are checking with focusing at this point because the point number does really change so this point number is always smaller this point number is always larger so even if you do the same process for this point you do get the same result and this one always be used as a first candidate okay so that's kind of um that's is the logic right here in order to choose which candidate will be used uh for the next move then these point maybe this point this point or this point can will be picked now uh one more conditions i guess i need to refer to for these point for this point this point is obviously a point where you need to check but this point is also the one that you also need to check because if this comes to right here and if this one goes to right here then this will crash to each other so these point are all the candidate i mean from this point you have these neighbors i have this point this point and this point as a neighbor and from each of the neighbor points you also want to check the other name the next neighbors from this point and those second neighbors are also the point you als you want to compare with whether the point number is smaller or larger so if if there are any mover points uh if you're focusing on this one and if there are any mover points at this point this point this this this this this and this one then you'll you want to compare all the numbers all the point numbers if it's smaller or not larger and if this one is the least smallest number among all the neighbor points then this can be chosen as a candidate okay so that's the basic logic which one to choose for the next go then if you have chosen the candidate then you can just move it randomly to one of the directions then on the next loop you can then ignore the candidate which has been already being used and then go to the remain points to do the same calculations okay so that's the main logic and that's the hardest one too among this sketch but it's pretty useful um idea i think for many other purposes i think when you want to deal with as many points as much as possible even if you think you can only do it recursively one point at a time but by doing like this you'll be able to pick a collection of a cluster of points all together to you process simultaneously as much as much as possible makes the performance better alright so find let me name this find and go okay and okay so i think i have um forgotten one thing i haven't set any uh groups for the points that i've created as this path so let me go back to apply that group let me leave the solver and let's see where i have set it i think i think i can set it let me see let me check what i have done previously because i don't want to miss it okay where is it actually it seems like it's inside the solver okay well i think um i think i was talking about the one that i have wait a minute um let me check what i did previously okay okay i think well let me just try to i think this one is checking whether i can go or not but the one that i have to do initially is to decide um [Music] let me go back to the original stuff that i did see what i was doing previously so i have this okay okay i forgot to set one group called agent okay for all the grid point so let me do that first the agent in here will be act will be applied to the node point those points on the path and the initial uh group initial agent group should be applied to the node where the mover is standing on so those point those red points position is the one then i'm going to apply the agent group so going back to the init mover i'm going to create another a code set point group to and named as agent at pt num as one okay so to be able to see which node has been applied as an agent i'm going to create another color node to check for agent i'm going to set it as dark red all right so these gradient node are the one that i have just applied the the agent node the agent group okay so going back now i am only going to what i'm going to do now is to look for the agent group so that i can refer to the neighbors i i can also refer to i can also refer to the mover but the mover is not really connected to any like node so it might be i thought it would be easier to check the neighbors by checking the asian node instead which is on the path so that's kind of a reason but but you can do the same thing by choosing the mover group as well if you want you might need a little bit of refrencing reference referring to the original path from the mover group based on the position but i don't want to do that so i'm going to just refer to the agent group all right so let me first get all the neighbors from the current point so end and pts i'm going to say mpts1 because i'm going to get two neighbors one neighbor from this current point and another neighbor from the neighbor of the neighbor okay so you need two recursive neighbors so first neighbor and for each neighbor i'm going to create the loop let's bring up the editor let's name this mpt1 and i am going to check if the neighbor point is actually a agent or not meaning from this point i'm going to check all the neighbors and see if the if it is still if it's agent meaning red okay so i'm going to check it by creating an attribute or variable calling one check using in point group agent at the neighbor point and if it's agent then i have to compare those two numbers whether which one is the smaller point and i'm going to use the smaller one right so if the the tank one is equal to one meaning i have found out the neighbor point to be an agent and also let's say i'm just going to check if it's in agent then i'm going to compare the neighbor point and the current point number then if the neighbor point is smaller which means this neighbor point is smaller then i'll just leave all the process because i only want to apply the attribute when the point number is smaller when the current point number is smaller okay so and i think i sh i also need to stop the process when um this point that i have found out which might not be agent but which is already been taken by other agent for from previous candidate then that that grid that point can also cannot be used as well i haven't really created that value yet but i'm going to name it as a go group okay so i am going to let i'm going to assume that i have this go group to each of the point as well and which indicates that this point can be used can be set as a go to point or not if it's equal to zero then which means it's already been taken you cannot really go there so and go one is equal to endpoint group go at npt1 and i'm gonna check if the the agent or int group the agent is you already been used and the go one is equal to zero i'm not sure if it was okay but and it might be or forgot let's just go with and then i'm going i might going i'm gonna go back later maybe i might need to fix this one later okay now the second loop for the getting the neighbor second neighbors so npts2 is equal to near points neighbors which is pretty much the same as this one and instead of using the current point number i'm going to use this npt1 right here okay and doing another loop which is similar to this one and i should not use variable i but instead something else all right and this one has to be two as well okay now i'm also going to check if this uh neighboring point is in used as an agent uh or already been chosen uh as a go group so i'm going to do the same thing wait a minute i think the goal the goal group has been set for each agent whether the agent has been moved or not wasn't it i think so so it if it has been moved then you can actually you can actually go to that direction so you can kind of ignore it so i guess this is correct checking if the agent is equal to one and if asian has already been moved or not if it has been already if it hasn't been moved then the agent is at this point right now so which means you cannot really go there so you need to end the process okay so i think this is all right i'm going to check the uh the agent group and the gold group for the second neighbor do the same conditional check these one go to bt1 and this one should be okay with pt num because you are only you're comparing with the current point number okay and you only want to operate to this point number if the point number compared to all the other agent never agent is smaller if this one is smaller okay so if you could go further then that means the point number is the smallest then i can set some group here and that is the one go go which means the point has been chosen as a candidate to move all right and since this go group is going to be left out as a cache for all the loop for each feedback loop i also need to have another group set to the same point which is only going to be used at the current loop current iterations in the loop to actually move the point to decide the next point position so i'm going to name this car and go okay forget to say one all right now i think i need one more conditions here in order to stop the process where which is if the current point number has already been chosen as go which means you don't really need to pick it as a next like candidate anymore so maybe i can do that somewhere right here if in point group go for the current point number if the point number has already been chosen as a candidate then i don't really need to do any process for this point so just return it okay i think that's it now by doing this one you should be able to see some groups being chosen for some of the point as a code now to check that i'm going to limit the number of iterations to one so that it's it's a bit easier to see what's going on here okay now let's see i'm going to check which asian point has been chosen as the next go the first candidate now i let me let me check whether i have this go group right here and i can see that some of the point has been chosen as a go which is among this agent group okay now let's try to color these different okay so i am going to set the go and maybe color it to blue to see which one has on being chosen okay it's a bit hard to see but you can see the kind of a gradient point underneath this red point it's a bit rc maybe i can make it yellow probably so i can see that these point which doesn't really have any close neighbors has been chosen as the next candidate these one now this one and this one is close to each other and this one has been chosen instead of this one because the point number for this one is smaller this one doesn't have any neighbors so this one has just been chosen now these one comparing all those in these clusters this one has the least point number so i guess this one has been chosen as the next candidate and this one has been passed for the next iterations okay so this looks good now in the next iterations i what i want to do is to choose from the agent which haven't set it as goal group to decide it as a next candidate but before doing that we also we need to check each of these goal agent a go group to decide which direction should point go to in this case uh the neighbor point number from this point either this point this point or this point from this point this point or this point and so on so let's do that i am going to use another point wrangle okay and i am going to name this connect choose the next agent point number okay and i'm only going to apply this to the one that has this current goal which is the group that i applied previously to those point that i have chosen as a candidate and this current goal is only going to be used inside this uh each iteration and it's going to be reset it at every iterations i think was it i think so right so let's do that so first of all um i'm going to get the neighbor point numbers from those point that i've been chosen and randomly pick uh the direction using some random value so i'm also going to refer to the iteration numbers so that i can create a random seed value based on the iteration numbers so end iterations from the detail get the iteration number and get also get the neighbors neighbor point numbers using the neighbors at pt num and i'm going to loop through all the points inside the neighbors okay get the neighbor point all right and um let's check if the candidate point is being used as an agent or not i mean there is a chance that it's being used as asian like this one if you if you found out this neighbor has already been chosen as an agent then you don't want to go to this way so instead you want to go either this way or this way so let's say if n point agent i a point group zero patient at the neighbor is equal to zero and you also want to check if it has been chosen as the next agent which means i'm going to do it inside this wrangle but after i have decided which way to go i'm going to apply the next agent group to that point okay so that point is going to be preserved reserved for the point to move to so you don't want you don't want to move other point to go to that point so i want i need to check whether the point has only been chosen as a next agent group so endpoint group next agent paper is also equal to zero then you can finally go choose that direction okay now instead of just trying to pick the point randomly directly i'm going to first create an array which contains all the possible points all point numbers where this uh this agent point or move a point can go to in this case this point at this point i'm first going to create a list which contains all these two lists all these two points then from those two point array i'm going to create use the random to pick one of the point numbers so i'm going to name as candidates as an array integer array and append inside candidates the naval point number all right now after having all these array being created i can now use some random values to pick one of the points okay so let's do that um i'm going to create the random values in rand index is equal to random maybe a point number plus or multiplied by some values plus some seed value plus an iteration related value okay this will be enough and then i need to make it as an index currently i have just created the volume between 0 to 1 as a flow value so it has to be the multiplication of the lengths of the candidates and then make it integer by using a floor function all right now this will be the random index now let's uh set let's pick that point now before going into that i might need to remove some of the point number from the candidate as well which is which in this case if there are there's more than one candidates left and well let me let's just ignore it for now i'm going to just pick up a random point we're using this round index so the candidate number is canned is equal to candidates at brand index okay now that i have picked up one of the point i can now set a necessary group information to that point so set point group zero next so i'm going to set the wait a minute not next but next agent next agent to this candidate point as one all right and for as a point attribute to the current node i can then set the the point number in which direction should the agent or should the mover on top of this point should go to so in this case if i have chosen this point then i should i am going to store the point number of this one inside on top of this node point so which looks confusing but set point attrib zero next at npt with the candidate number which is going to be useful later on okay this should not be npt but um pt num the current point number all right now i would like to do the same thing for the mover i want the mover point to have the same information this next point information which could be useful so going to pick the i'm going to search for the mover point which should be on top of this agent node so i can just search for it by using the new point filtering the mover group at p then as soon as i find founded i have i'm going to set point attrib 0 next next candidate all right now there is a chance that the point within those agents well i mean okay i think uh having an agent means that there is always a mover so i think this always work should work okay so other than that i can now reset the current point to have uh current go to be zero and just keep the goal group as a cache to use it later on to check okay but the current goal i don't really need the current go group anymore because this is to decide which point should move and after i have decided it's not really necessary so i'm going to remove that by using set point group zero current goal ptnom to zero right okay so is this enough i think i still need to write something but let's just ignore it for now and go to the next one i'm going to come back later okay now i also need to have an information when to stop the this feedback loop the feedback loop is to is the purpose of the feedback loop is to choose all the points as a candidate to move or not move so all if when all the agent node color becomes yellow in this case all the edge and beca have the go group then that's the timing when you want to stop the loop so let's create that information using attribute attribute triangle um next or count so what i need to do is to count up all those point which doesn't have a goal group yet okay so i can just count the number of agents and number of gold groups and if you subtract those two numbers and if the value is not zero then you still need to loop through you need you still need to do the looping to fill all the points as a candidate so let's get that first of all goes the number of points inside a specific group and points group at inside the goal and the agents is endpoints group zero agent okay now i'm going to calculate the subtraction um so i'm going to create a detail attribute called can go num z code two agents minus girls and i have actually created this one somewhere which isn't outside the solver at this attribute create and okay i think i have i needed to make it as a detail attribute instead of the point attribute so let's make this detail check this one go to the details i have this can go numb can go okay spell mistake can go num okay and has to be an integer all right what's the other one i think i also need to make the other ones to beat an integer this one and this one as well current and the next okay okay so all is good going back and let's see if i have this can go numb right here and this one right here okay so i have just updated this can go num detail attribute by calculating the subtraction between the number of agents and the golds and this should be either positive or zero if it's zero then there's no more every point has been chosen as a candidate if not if it's positive value more than one then more than or equal to one then you still need to loop through now if i look at this one let me just connect this one and look at this point and check the detail attribute it says can go numb is negative one so i think something is wrong okay endpoints group zero goal endpoints group agents okay let me first check if those values are correct okay i had asians something must be wrong okay nothing has been changed that is because i didn't change this to detail that's it okay so i do have these numbers let's see so the currently they can go num is equal to four so i have four points left these point and wait a minute okay so these four points or five points is it looks like five points just say for four not sure why well oh inside this loop it become four so i guess it's already been looping i guess that's the reason okay so so what i want to do next is to stop the loop when this can go num detail attribute becomes zero and to do that i'm going to refer to this first node inside loop the detail expression for this for each end so at this stop condition i'm going to check the detail attribute detail attribute at stop and can go num and if it's equal to zero then that's the timing you want to stop okay now now let's see if i raise this value up you can see that the candidate it's been filled with the yellow color and at some point the loop ends right here so at this point it takes around six loops to fill all the points okay seems to work fine now and the next thing i want to check is in which direction each of the point is trying to go so um i'm going to draw it with a color node i think i guess after leaving all the loop going to set the group as point does this have a point group should be so i'm going to color up this current go which has been chosen as a go but doesn't seem to have any values here okay am i missing something let's see let me see so i have this current go nothing i do have this go oh yeah actually i don't really need to color the current go but because it's only a temporal value so it's not really necessary what i need to draw is the next agent which agent has been chosen so which is this one okay so let's see using the color node i am going to use the next agent maybe set it as a green okay it seems like some of the point which is going set these point has also been chosen as the next agent and i'm not sure if that's the right direction not sure but let's check out okay so um next so this is pretty much the initial process and then by using those information i'm going to try to then finally move the mover point using those informations which is applied to the node and both to the mirror point okay so i am going to use the point wrangle to work it only for the mover point which is used as a pac-man okay and first thing first i'm going to define like how many steps i want to use in order to move from one point to another and that value has been defined right here so i'm going to copy this expression checking the channel from the controller null node i'm going to name this frame and paste that value right here so that i can use it inside of x all right now um load t first i'm going to create a value code t based on the frame value so for every 15 in this case every 20 frames i'm going i would like to create a volume between 0 to 20 i mean 0 to 1 which will be easier to use so to do that first i'm going to get the current frame then calculate the modulus the remains with the step frame or adjust the frame then you'll be able to have a volume between 0 to 19 in this case now i'm going to divide it by a number of total frame number of total step frame which is 20. so in that case you'll be able to have a value in between 0 to 0.99 or something okay so step right or actually what you get is since it starts from one you what you get is actually a volume between 0.01 or something zero point some small value two one okay and i also want to make sure that if t is equal to zero meaning the modulus the calculation modulus becomes zero meaning when the frame is equal to 20 or 40 or 60 i want to make sure that the t is falsely set to 1.0 so that because t equals zero and t equal one in this case will be used similarly okay um in this case i'm going to use it as a position value and i it's a bit um having zero as having zero for t is a bit difficult to deal with in this situations because you need to have if it's zero then you might the point point position of this mover will might jump from one to another from next point to the from previous point to the next point by having this zero value so i'm going to reset to one now now that i have these value i can now um get the current number from the current mover point which haven't really applied to it yet so i have to do it somewhere else but i am going to get the current the point positions which is on the node getting from the current attribute and also get the next point position from the next attribute now i do already have this next attribute inside a mover point but i don't really have this current point so let's create that to do that let's go back outside this over and if i have done it if i have done it previously and i think i do need to create it previously for the initial current value which should be as soon as i have created the mover point and i actually did have this current number set as a current point number to to the mover now that is good but after uh going through the first step frame i need to update this current number somewhere so that should be right before you search for the next point so maybe somewhere around here okay but those uh initial like conditions to search for the current point must not be called when the current frame is equal to one because you have already be you had you have already be you have already set the initial values right here for for the initial setup so except for the first frame i want to do the initial like resetting for all the attributes like the current number and so on and all the other groups related groups so i do need another switch here to ignore only the first frame when the first frame is equal to one then i just want to skip the whole process to go to this one if not then i can do the initial or the reset setup right here so let's do that i am going to go inside solver and let's see what kind of stuff i need to do so first of all i'm going to create the i'm going to create the attribute right attribute battery view to create to reset some of the value some of the attribute values right attribute create okay has to be something like this now the thing that i want to do is to reset the the detail attribute which is called can go known to -1 at each 20 frame a sore step frame essentially i need to do all the stuff that i did somewhere around here inside right here so i have reset the can go numb to negative one and i also would like to delete some of the attribute or the group that has been created which is inside here which is delete group delete which is first of all go let's set it to point group and i also want to delete the current go as well and i also need to recreate the agent group and i don't really need the previous agent group so i can also delete the current agent loop all right now let's recreate the agent group and also the next agent to be set it as zero probably i can delete the next station right here as well okay then oh actually not because the next uh the [Music] the agent group has to be applied to the next asian group so i cannot delete the next agent group right here at this point but instead i'm going to use the point wrangle filtering the next agent and set point group zero asian said that set it to a asian group meaning transferring from next agent to the agent now after i have transferred group then i don't i no longer need this group anymore so i can group delete this next agent so next agent okay what else now i think it's also a good idea to have the previous point number and can be used as information defined in which direction the point has come from which can be used to check which point should be blocked to go so i'm going to [Music] create that previous point number value for the mover and copy it from the current at this point since the current attribute is going to be updated right here inside so the previous one is going to be used as a previous one all right crap so i guess this is pretty much it for the resetting stuff i think now let's connect this back to right here so make sure that this one wait i mean this condition is not good if f is [Music] if f is larger than the current frame is larger than one then you can run this one so i have to switch this one right here this goes to the right so in the first frame this does not run but after the first frame then every 20 frame this will start to run to reset the information okay now going back to some of the code inside the for loop again i need i probably need to use this previous point number information somewhere let's see where was that okay so i think that was inside this next agent where i have decided which agent be used as the next candidate and so this is where i have chosen the candidate or not maybe a previous two so after i have chosen all the candidates and stored it into the array what i want to do next is to get the point number of the move and also get the previous point number which also means the current point number copied to the previous right here and if the candidates include that previous number then that is going to be a problem because these point might not move so you might be you might have a crush between the point which is so i think these are the point which has these problems right here so let's make the condition here if the length of the candidates is more than one okay and i want to check or it could be zero and i want to check the closest move moving point so npt near point zero over at point position then get the previous point number from that mover point which is derived from the current point number and if this candidate has this number then you don't want to move to that point so i am going to remove that by using the remove value from the candidates this might need to be zero yeah more than so more than zero i think okay and there is the chance that the candidate becomes zero length meaning you have nowhere to go anymore okay so in that case if the in that case you can just stop at the current point position meaning the initial candidate numbers to be a pt num but if you found out that the length of the candidate is still more than zero meaning you have at least one item then you can choose one of the point number from the candidates and update it so that it doesn't have to stop at the current point position okay i think it makes sense probably and if i loop this leap leave this loop not sure if it's working by the color let's try to see it in the animation okay so going back to the point wrangle right here i'm going to name this as moving okay now that i have all the necessary informations to calculate the movement i it's time to actually write the fun part in order to move the point from one point to another and i do have i already have the necessary informations which is the from point position to the cur next point position and then i also have this t value so lerping those position with this t i'll be able to get the current point position so vector new plus is equal to lerp from current point position to the next point position using t right now update the point the point position of the mover with this new position and that's probably it now i if you want to make it as a three-dimensional stuff then i also would need to apply some normal direction for the mover as well as the up vector okay so let's also do that almost i'm going to refer to i'm going to reference the geometry coming from the second input which is these original surface right here which have the normal direction at each point now let's sample those normal direction using uv sample second input and using p as a uv value current p as actual value okay now now that i have this normal direction i can now try to set the normal direction with this sample value and i could also set the up vector which i don't really have it right now i think so let's just ignore this for now i'm just going to apply this normal direction for now okay the point has just been moved a little bit because it's at one now let's see if it's going to move as i supposed so you can you can see that the yellow point is the current point number and the green one is the candidate i mean the next point position where the point was trying to move to as as soon as this point comes to this node then the new next agent or next candidate is going to be chosen oops okay something bad happened okay i can see that something weird is happening i can see that the yellow color is increasing with which is not really a problem because i just have to reset the color actually so let's do that somewhere around here color but the movement the area with the movement i think i need to fix somewhere so let's see what is wrong okay so let's set the point all the point colors to white initially and okay let's see what is wrong with these one let me just call out the move mover with the red so that i can see it better okay am i seeing it okay now initially uh probably i shouldn't reset the color right here but i should reset the color somewhere around here okay that should be good now let me check so as soon as it goes to the next point it goes back to the original positions so that's one problem so let's see why which means as soon as it comes here the current point position has not been reset so i think i'm missing some reset function somewhere so let's see where that is okay so let me check the attribute going back to the geometry spreadsheet for i'm only going to check the mover agent mover group which is these one okay so since i'm going to check the number of the group let's say i'm going to focus on this one let's set 86 so 86 this one right here okay now this is a good and i have this next number and the current number now i can see that it's going from 18 to 19 which is correct at this moment 18 18-19 and does this have a previous value not yet because this is the first frame okay now if i go to right here how does this change okay as soon as it comes 21st frame then the current became 18 back again so current didn't really change so that's the problem and the next one seems to be correct so i need to fix that i need to update this current number as soon as it becomes the 21st frame okay i think i missed that so going back and see which where i should do that okay so let me check what i have done previously should be inside uh either this one or this one i'm thinking it should be somewhere in here probably i was missing one node to do that okay so i am going to add additional point group which only look at the mover group so to update the current point number so point wrangle uh init mover and and only look at the mover and what i want to do is to after i have moved the point after i have moved the movement point to the other node the other end of the node i need to get that point number from this node in this case 19 so to do that i'm going to search for the nearest point from the agent group from the current move position then update the current with this found point number which is set as an agent now hopefully this will work and i also need to forget i need i also forgot to reset the previous number as well so let's also do that the previous number is only used inside this for loop so i think i can reset it after as soon as i have left out this loop meaning i can reset the previous value somewhere around here so i can create a attribute point wrangle for the river well probably i don't really need to reset the previous not sure maybe not let's try not to do it and see if they work okay let's go back again and see if the point can move correctly or not okay let's see i'm gonna make this slower okay now i think it's moving correctly and i see one problem here you can see that uh right here it's crushing okay that's not good is it but other than that it looks great it's not really trying to go to the same position at the same time so i think i'm missing one additional conditions try to avoid this intersection crossover okay so i do need to search for the conditions and what kind of condition i need to think about think of okay so so let's say we are starting at this point and i need to say that the point even though the point has moved to the other direction this point cannot go to where the point has already been uh there so i thought i did that but i think it's missing and that value is probably the previous value so i might still need to reset it let's see if i set the value i can fix this so for the movie point i'm going to set the previous value to negative one and see it still works okay now it was at the frame hundred somewhere around here so let's reset the solver and see if you can if you still see the same thing so going back to the hundred okay you still see the same thing so i i guess i need to create the conditions for this one so let's see this should be written right here and probably related to the the previous um information right here as well which i thought i did but it didn't really worked out well did it okay [Music] let me see if the previous point has been set correctly first of all going back to this mover maybe i can check somewhere around here okay somewhere around here and check this one i'm going to activate this one and see if the previous value has been updated correctly for the specific point now in this case let's say 95.95 is the moving point and currently the current number is 67 coming from this point going into the a 58 which is i guess this point it's a bit hard to see because i do see the caches here here but i think it should be correct this is 58 now uh what's the previous one 67 okay and as soon as it comes right here okay i guess i need to go back to the loop to have a bit more durations okay somewhere around here okay why am i seeing these caches okay going back so previous one became at this moment the previous value was 58 so that's correct now going back a little bit becomes okay so as soon as it becomes a hundred one i'm the this code will run this node will run and choose the next candidates and the the thing is that i don't want to choose this one right here and at this moment somewhere around here i need to see what kind of conditions i need to care about so currently so for the 95 the previous number is 67 still at 67. though i actually want to change this but at this moment the current number has not been changed yet i guess okay the current number only changes after it after it becomes 101 which is this one right here okay so the timing is a bit off by one frame so that's kind of a problem wait a minute current value has been chosen right here let's see it's a bit tricky okay [Music] so in that case in that case i actually don't want to move the move to the current point as well not not previous but also the current as well so i'm going to pick the current from the point and also remove that value from the candidates and what else what else and i would also want to check the group number for those points so going back to somewhere around here check the group so this is 80 58 so 58 i have this go group next asian group and agent group okay so i don't want to move to to those um the next station is okay but i don't want to actually go to the where the the other agent is already being used so i guess that's the condition i need to use the thing is i did removed the previous agent right here so okay so that's kind of a bummer probably i would like to create another agent like the previous agent as an information okay yeah that might be the value that i need so let's create that going to point great point wrangle before deleting the agent i am going to transfer from agent to the previous agent so set point group um crev agent now it's getting more complex than i thought but it's fun creating those logics and then i can also remove the group called previous agent somewhere around here rev not this one deleting the crev agent okay so point group preparation all right [Applause] now i can go back to the next agent and i can create the conditions right here if in point group zero rev agent that neighbor is equal to zero okay i think this should work doesn't it all right let's see let's see let's see let's see okay [Music] reset it okay i don't want to see these caches let me reopen this to delete the cache okay now let's check this out if i play it and it was around 100 frames and yeah i think i have just solved it you no longer have this like collision oh wait a minute i still have it okay didn't really solved it after all why is that okay going this way and okay i think i'm missing something i guess i'm missing something here let me check so checking the point number 57 point number 57 what's these group do i have this previous group previous agent so i have this previous agent zero why does that wait a minute so 57 okay so 57 has been chosen as a next asian that's correct as soon as becomes oh wait a minute and this becomes current agent [Music] okay so to avoid these points going to the other side i also need to check if the point is in is the current agent i thought i did do that yeah this is the wait a minute okay i shouldn't use and but instead i should use or that's the reason then in that case i might not need to have this previous agent filter after all let's check okay a lot of tweaking here hopefully this works wait a minute didn't really do that didn't really work so let me also add this another filter wait a minute this is yeah still is okay with the end yeah it's still okay with that filter there's nothing wrong with these okay getting stuck all right what else what else did i was i am missing here if hmm set this candidate to one does it help nope okay okay it's actually not working yes i want okay so this is obviously wrong so let's check this out from the first frame so let's go back like to fix this out and let's start from the first iteration for first feedback iterations okay so these yellow points yellow point is the first candidate and okay so this is initially wrong why is it choosing this point as a moving point that's obviously so wrong all right let's see and let me see why uh i like first of all let me check the numbers so 76 77 78 0.78 what does it look like 1.78 so it is agent yeah so if it's agent is equal to one then it should not be chosen as a candidate anymore but it actually has been chosen somehow and that's the question why i think i'm missing i think i did something wrong somewhere so i have these conditions first i'm checking the neighbors checking all the neighbors in point group agent neighbor is either agent or a next agent and if not if both of them is not included inside this group then i am adding to the candidate now let me have this candidate as an array stored into an attribute to check okay so for the point 95 is it current go is it the point uh not 0.95 at 0.7 i think so let's see so 0.77 i have just applied i have just attached wait a minute okay it says 0.78 this one how's that okay let me see which point has just been chosen let me go back to the zero okay this one fine go okay at this moment this seems like wrong because both of them are chosen as the first candidate that seems wrong so i guess these ones i have something wrong with this one so let's see what's wrong here what's wrong with this one so i am checking the agent which are those two points i think right and i'm getting the neighbors and i'm checking whether it's inside the agent and they go one is equal to zero [Music] it's not return hmm and i'm curling the gogo oh okay probably i need to carry it current go okay that's better okay so actually this was okay now going back to the initial conditions so this is the this is the initial one let me just delete these so that okay so i think this is not the first point but this is the second set of the point has been chosen somehow it's looping going to see single pass okay still well let's look at this current goal although if i increase this number it doesn't really increment does it okay i'm going to color this a bit different i'm also color the go value go group with blue to do the debugging so the blue has been already been chosen but when exactly i might need to remove the stop conditions for a while let's remove this one or i'm just seeing the caches probably that's it all right okay so seems great seems to work fine i'm going to check whether which direction this point has chosen as a next candidate so for these point after i have chosen next agent i am going to color the next agent with green and obviously this has been chosen so that's totally wrong that's the problem so 0.77 going back this one the candidate has been chosen as 68 which is this one 76 this one and 78 this one and somehow this one has all been chosen which is set as an agent should not happened so the condition must be wrong somewhere around here okay okay let's check this out so from point to point now start from the beginning i have retrieved the neighbors let's check everything is correct okay and i have created the empty candidates which is fine i'm looking through all the neighbors getting the neighbor point number and at each shoot spell mistake that's probably it some stupid mistake i made yup all right now now the candidate became left side all right that should be it and i no longer need these and i can go back to this one to add the condition back to stop the for each loop now let's back let's go back and see if things going to work why does this point move to this right here huh okay something weird happened which should which is obviously wrong looks wrong all right what is that what is that okay [Music] what is the current t value if its t value is maybe the current number is wrong for the for this point 96 96 current point number is what is it 78 looks correct next point number is zero that's wrong yeah okay this is wrong and going back the next point the value that i have been setting next is right here meaning something must be wrong here right okay let's see why let's see why the value has been chosen as zero meaning this point haven't used even if it didn't find any place to move let me try to remove this conditions to see if it's going to work yup it worked so obviously this is wrong and i guess i shouldn't delete this candidates the previous number from the candidates think which would remove your own number was it [Music] this means is that you don't want to go to the previously assign position which still should work but uh by making the conditions eq more than one let's see what still has some problem here okay [Music] moving the point getting the previous let's just remove it and see if it still works nope reset nope still still has some problem here huh why is that okay i think i just removed something and what if i move this okay obviously that's wrong if i don't change the candidate which means it stops at its current point positions but it's not happening like that so obviously something is wrong something must be wrong the next number has been applied as the wrong value so [Music] i'm going to check the mover group all these group i'm going to check all the next number okay so some of the value has zero so that those are the one which is wrong which should be having some problem here okay so one is 96 but this moment and this moment this moment looks okay this one hasn't like 78 there's one current why those values are not being updated meaning ah okay i know the problem i have to increase this loop because after i have picked the first candidate i didn't like loop through all the possibilities i have to raise this number up to so that all the points should have this candidate okay so that was the problem and now now that that was the problem i think i can re enable these conditions after all okay finger crossed and okay i still have some problem okay why is that this is so tricky why um but feedback loop just stopped at one so something must be wrong here detail stop can go numb let me check the detail value so it shouldn't stop this condition is not met but kind of actually stop at feedback loop one ah single pass uncheck it all right okay please blue what is happening here huh okay one another thing i am i was fixing the candidate number i think i have to enable this one okay all right is it going i think is it did it jumped oh yeah it's from the first frame so that's fine okay so whenever it is blocked by other agent it stops okay looks good finally finally all right what are these points i'm not sure okay that was just a cache i guess okay so looks good moving great and if i color it based on the variant ramp from attribute variant i can either make it yellow or red based on the type of the agent yellow should be a pacman red it's going to be a ghost okay all right now i think it's working now i'm going to try this out with the three-dimensional geometry okay it's taking a lot of time here but i'm not sure how many people are still listening but just for my for my fun so i guess it's okay all right so let me try with these and see if this could work as well this triangle grid let's reset it oh interesting from the triangle the pass became like um soccer ball and yeah seems to work just fine all right this could be interesting right now i can see that it's working and i can also visualize the normal direction looking great now now that i have the base i can what i need to do now is to just create some simple modeling on by using this point position and let's make this quick let's start from the plane first of all i am going to create the base plane [Music] by doing some extrusions and as a simple base so let's bring this let's connect this to the loop null node let's name this base and going back going down going to refer to that object okay and by doing some simple extrusions i'm going to do the poly extrude to do the extrusion per or just create the thickness or maybe i can stop by in setting for each element and only use the front create like a tile you know make it like .03 or something it doesn't really matter about the numbers it's not really important here here and then offset this backward or to the negative direction to have a little bit of thickness with the side and the back then let's make this reversed okay and this is the base i'm going to color this some maybe set it as white for now okay so let's also create a pacman itself from sphere which is going to be really simple i'm going to make it really simple from a sphere i'm going to make it as a polygon let's say frequency of 3 or something right and i'm just going to do the boolean which is a kind of a brute force modeling but doesn't really matter circle let's make a circle and let's make this y z plane then make this point one as a radius make it a polygon and i want to make it as an open arc where is it maybe make the radius a bit larger and to make it as a okay let's make it as a closed arc and from 60 degrees to 120 degrees okay and i'm going to do just simple boolean first of all extruding this surface by i know two or three having the back side and then move back transfer back by 0.1.5 oops then duty boolean okay so this is going to be the base and let's see if this can be placed on top of this moving or agent position now i i guess the radius of this backward is a bit too large so make this radius 0.5 all right now let's also set the color to yellow or maybe the color will be controlled by the copy to point so let's keep that i'm going to use the copy two points then to the merver to the mover point i'm going to not this one copy the a pac-man only to the murder point so i'm going to set it to mover and based on the variant i want to change the type of the shape so p enable this piece attribute to use this i think i need to create the attribute add point attribute to this primitive or add points so add tree mute create and set the variant to zero for the pacman ryan integer to zero okay now i have these backman facing to the same direction in order to make this facing randomly maybe based on the direction where the point is moving i need to set the up vector okay now let's do the ghost i'm going to make it simple as well starting with the same sphere um i am going to create the kind of a hollowed i don't know wave on the bottom on the on the leg all right so point wrangle so previously the pacman was facing upward like these so same as these for the ghost i'm going to create the leg like this right here or maybe right here i don't know which direction okay to do that let's name this ghost i'm going to use the point wrangle to use some um trigonometry like sine wave to create a wavy like leg so if oops um if at point dot z which is these direction is more than or less than zero then move the z value to a minus 0.5 okay so like these maybe you don't have enough points to create the wavy leg so i'm going to increase the a little bit like this maybe a little bit more okay might be too heavy but let's go let's try with these now uh after doing after setting the point position halfway to the bottom of the which is at this floor i'm going to set it as a wavy pattern by introducing some more sine wave so to use that i'm going to have to create an angle for the wave and i can i i want to change the angle based on the the position of this circle okay and the position of the circle can be determined by the angle of this circle based on the i don't know x axis or something so to get that angle value i can use a function like 8 and 2 based on the bad p y at p dot x that should be the angle and i can increase the angle by multiplying with some the multiplication of two so that you have a continuous wave let's multiply by two by some integer that number okay now i have just created the angle value i can now convert this into a height value to move the point using the sign multiply by an actual height and probably i could this by height plus 1 so that the range becomes from 0 to 2 in this case and multiply by height will give you a value in between 0 to 2 multiplied by height okay let's set the height to 0.1 and now finally i'm going to update the z value with this height add or increment the high value let's see what happens not bad i mean this center area looks a bit too busy but if you look from the side not bad okay it's not bad all right so let's set also set this variant i at variend is equal to one now i'm going to merge it with the pacman shape see what happens with the copy to point okay now starting to look like what i want but it obviously is not that interesting because first of all batman is not faced facing toward the movement ghost is not really moving at all it just looks like sliding so let's also fix that since i am using the copy two point node by introducing one more directional value which is a up vector i'll be able to control the side rotation so let's do that going back to the solver i need to update the mover point with this up vector now i can go back to the initial point initial mover value right here where i can set the initial a up vector which could be random for now so currently the normal direction is up vector i mean the normal direction is facing upward meaning y direction so i want to make the perpendicular direction to that in this case by referring to the neighbor point might be a good idea so for each point where i have created the mover i am going to get the first neighbor point using the neighbor at pt num and zero and then get the direction to this neighbor point get the direction and pause minus current point position and normalize this one then set it us up in a show up vector okay oops what happened huh what is this okay something new had happened okay and i cannot seem to move my mouse anymore let me reopen okay somehow i cannot really touch my houdini anymore i think i need to quit houdini and reopen it let me do that save and quit i don't know what has just happened what is my machine spec well currently i am working with the macintosh i have just bought a muk mini which is running with the m1 processor lands okay i think i don't do the renderings in this machine so if you are just doing the modeling i think it's just fine when i do the modeling i am using the windows machine obviously the spec is ltx 3380 together with the ryzen thread ripper and 32 core which is pretty fast okay what was it it's really rare to crash seems like yeah i found that as well in macintosh it crashes pretty often that's a bummer isn't it or it's just my case i don't know where was i what was i trying to do oh yeah i was updating the normal direction okay and i also need to update this up vector inside here where i was updating the normal aside to that i also want to update the up vector and that is the actual direction where the point is moving to which is this direction n pass minus c pos so let's create that direction vector vector direction is and plus minus c plus normalize and i don't want to just like turn the just i don't i don't want to just like rotate the pac-man or ghost instantly but i do want to have a little bit of like lerp or the feeling of the animation interpolation going from one direction to the other direction so to do that i am going to update the up vector by using the lerp going from the current up vector to the new direction by some let's say point one which will slowly rotate the current the pac-man direction to the new direction using several frames let's see what happens then now you can see that the pacman is facing at each different direction and if i play it i can see that the i rotate like a go car doesn't like a car maybe too slow yeah let me fasten this a little bit i'm going to increase the lerp value a little bit like by 2.2 might be a better value let's check this out okay where did the grid go okay if i play it okay looks looks good now since this is a pacman i want to open and close these mouses of this so to do that i'm just going to procedurally animate the opening which is this angle right here based on the frame value and maybe together with some sine function again so going back to this one i'm going to define the the base angle for the opening let's see pack man mouth angle which is really not a important parameter at all just for fun let's make the maximum 90 and start with 30. okay copy this one going back to this one right here and since the 90 degrees is when the mouse being closed when both of them both of the valley becomes 90 the mouse just closed so make this as a default value and for the minimum value i'm going to do the subtraction for the maximum i'm going to do the addition now paste the angle the base angle multiply by the sine function sine based on the frame multiply by an awesome speed and remap it in between zero to one okay and i'm gonna copy this one to the next one and change the operator to plus now if i play it now i'd be able to see the mouse moving like i wanted to have alright looks good now for the ghost it just looks like sliding so i'm going to also create some simple animation like looks like wiggling maybe rotating we look from the top rotating back and forth these like a wave let's also do that i'm going to create a new transform node somewhere right here for the ghost and do the rotation at z axis in this case so let's say 30 multiplied by sine of frame multiplied by 30 so you'll be able to have a minus 30 to 30 degree rotational angle let's see what happens okay looks weird but okay if you want to set an eye to these ghosts you can also do that i guess by creating adding some sphere but i'm just gonna ignore this i'm just gonna go with these for now okay making ghost all red might be too boring so going back to the color i'm going to um let's see i want the ghost to have a different colors color so going back to the initial value right here where i have created the ghost where was it this one in it over so this is when the value was ghost so for these ones i want to set some random values to each of the ghosts to define the characteristic so let's say setpoint attrib zero call pt and i'm going to create a random value based on the point position plus some seed plus some additional value and fit it remap it in between and 1.0 okay for the pacman i'm just going to set the color as zero set point group i'll set point attribute 0 since i want to make it float all right going back color instead of the bar iron i'm going to use the call and what's wrong oops something has been something must be wrong okay okay now going back to the color node let's set the middle to orange then set these to other colors that are uses of our iron so only the ghost will be affected by these colors and pac-man always remains yellow because it's always zero okay starting to get cute okay looking good now let's also raise this whole character move up a little bit to the normal direction i'm just going to do it right after i have set the color by adding to the normal direction by in this case 0.5 maybe i should have parameterized this as well but for now i think it's fine okay now connecting with the floor i have just created let's make this floor color to some darker color maybe white it's fine okay i think it's working fine just fine now i think it's moving fine so let me try well let me try these out with uh three-dimensional geometry to see if it could still work so even with these triangle grid it's still working there's too many ghosts let's reduce the number of uh whole characters to ten percent okay now there's only one pacman if i want to increase that i can then make it forty percent okay still moving great and it shouldn't touch with anything and as a additional stuff like if you want to create like a bait like you see in the game you can just get the center point off the floor which is this one and add a center point and move it upward i am not going to create an interaction between the bait and the pacman which is which going to take a bit more time to do so just going to create a static bait does it call bait not sure and these should be running with the primitive and pt is equal to at point zero p plus a normal direction multiplied by point five okay and let's set point group zero weight pt with one all right i'm gonna copy some sphere some low poly sphere to those points copy two points to debate now that's obviously too big okay [Music] and these one i'm going to set it as white color so instead this one i'm going to make it a bit darker color all right now let's make the background a little bit lighter okay set all the material call it to be a bit brighter as well and finally i think this is what i wanted to see now yeah i think it's working fine just fine and the interesting i mean the good thing about this process or this method is that this can be run on any chosen geometry i think so it could even run on top of the pick head if you want set the scale of the pickhead so that it can be aligned i'm going to scale this up a little bit somewhere around here somewhere around like this now obviously there are so many like primitives so i think it would might takes a little bit of time to calculate all the available positions for the next go so let's reduce the number of uh ghosts going back to this one set it to 0.25 [Music] and let me also give a little bit of space doesn't really change does it nope didn't really change i guess because there are some really small planes out here and obviously the ball is a bit too big okay and it's a bit too slow if you want to make it faster i think you can just pack these shapes individually these like these to do that i need to set the variant this one and i could also pack this geometry as well and i think this will speed up a little bit not that much okay this geometry is not that interesting make it really simple might be much better okay so that's pretty much it thank you for those who have spent a time a long time with me listening watching i'm not sure if it make sense to you by following these steps i hope it did um and i hope you find it somehow interesting i would like i going to try to make a bit more simpler stuff for the next week okay so if you have any questions please let me know if not i am going to end this life and i will um prepare the video so that how i managed to send this to send a setup to a unreal engine 5 with the attribute maybe i can show that right now a little bit and i'm going to explain the exact a process how i did that explaining from scratch okay so let me see where i have done it where did i do that okay so this is okay so i'm connecting to a unreal five remotely okay there is a bit of weird things happening i think i have replaced some textures or something but vertex animations and causing this irregular animation which is obviously not what i wanted to have but um i'm gonna show you how exactly you can send the uh houdini animation to [Music] the unreal engine five so that this is the correct uh one so what i'm sending here is the additional attribute to use it as for the emission right here that's the and this movement is using the same logic as this pacman that i've created so if you're interest if you have followed pacman then you'll be able to create this rotating box easily as well okay well that's another topic to send the attribute from the houdini to ue5 uh simply basically i'm using the v80 with the custom like um some tweaking because originally it doesn't allow you to bring any additional one so i'm going to show you how you can bring out the additional attribute by yourself as additional informations to render inside embryo for real time which could be useful i think which makes you do similar stuff you do in redshift based on the attribute okay so that's pretty much it and [Music] i'd like to end the tutorial the live stream here okay so thank you very much for all the comments um if you're interested in this kind of tutorial please also join next week at the same time as well i'll be appreciated and i am going to upload the file that i've created today to the github and you can download it from the video description page as always uh so if you're interested in this kind of things please download it and check how it works okay i'm also uh doing the patreon myself so if you are kind enough to support me that will that also be great you can also go to the page from the video description page of this youtube video okay that's it thank you thank you very much and hope to see you next week good night
Info
Channel: Junichiro Horikawa
Views: 1,796
Rating: 4.9565215 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, computational, generative, line drawing, drawing, illustration, fractal, reaction diffusion, celullar automata, simulation, trail, particle, vfx, mitosis, magnetic field, field, volume, rendering, computer graphics, visualization, algorithm, motion graphics, graphics, remesh, quad
Id: rLA0oZudLXg
Channel Id: undefined
Length: 203min 54sec (12234 seconds)
Published: Wed Jun 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.