Beginner in Houdini following Origami tutorial

   2747   5   0
User Avatar
Member
34 posts
Joined: Feb. 2023
Offline
Hi. I am following the tutorial:


I understand the initial part of the tutorial. The instructor group specific edges they want to fold in/out to later plug into a vellum constraint type>Bend Across Triangles

The "problem" he shows is that the constraints are not corresponding to each specific group led in the geometry stream. Proven by attaching a null to the Out_Constraint and displaying no groups. So what is needed is to transfer the group information from the geometry stream plugged in the vellum constraint node to the constraint pink socket, and for that, he uses point wrangler nodes:



I am really lost since I do not know VEX and even using Chat GPT I can not fully understand the explanation. I am wondering if there are other ways to do this without code. I checked the vellum constraint node, and it seems to have a group option to specify edges where to act. So why he isn't using that instead of writing code?

There are high chances, I am aiming to high trying to follow this tutorial, the comments section shows people describing this video as a straight and clear tutorial, but I find it quite overwhelming.

I hope someone can take the time to explain this in a simpler manner in order to understand how to recreate the simulation, which I love. I do not want to do things I do not understand just for the sake of having a nice animation, ultimately I am aiming to expand my portfolio to show things I understand how to reproduce.

Thank you

Attachments:
Screenshot 2023-07-25 103954.png (1.8 MB)

User Avatar
Member
68 posts
Joined: Nov. 2021
Offline
I never had luck using ChatGPT for VEX, it's not trained for that, you probably will have more luck using it for something like python as it's a lot more common.

When writing VEX, there's a tooltip popup for every function as soon as you type the open back after the function. You can also put the marker somewhere in the function and hit F1 to open the Houdini documentation for the specific function. That will definitely help understand VEX code better.

In this code he creates an integer array called "pts" which is essentially a list containing whole numbers specified by the function afterwards. The function primpoints runs over a specified primitive and returns all points related to the primtive. Since the attribute wrangle by itself acts like a forloop, it runs over each primitive of your input stream. The @primnum pseudo-attribute returns the number of the primitive the loop/wrangle is currently running over.

So let's say you have one primitive with three points what's happening in the background is the following:
int pts[]-> create integer array called pts
primpoints -> Returns the list of points on a primitive
(0 -> refers to the input slot of the wrangle (0 - 3 refers to the 1st to 4th input)
@primnum -> pseudo attribute, since we only have 1 primitive it would just return 0, if we had 5 primitives, it would increse from 0 to 4 with each iteration

This would result in an array of [0, 1, 2]which is a list of the point numbers of the primitive since numbering for points etc starts with 0 for the first point

You probably already heard of if-statements in programming which is what happens next.
if -> checks if an argument is true, if so the following code is executed, if false nothing happens (but can be further specified with an "else")
inedgegroup -> checks if an edge is part of a certain group
(1 -> refers to the second input
'fold_in' -> group name of the edge group you want to check for
pts[2] and pts[3]-> items of the array to specify the points ([2]is the third item of the array because we're starting to count from 0), these are two points to specify the edge in between them

now the if statement is complete, so if this is true the following code is executed
i@group_fold_in = 1 -> create a group called "fold_in" and set value to 1 which means put the primitive into the group.

This is a simplified way of writing an if-statement, the longer version would look like this:

if (inedgegroup(1, 'fold_in', pts[2], pts[3])){
    i@group_fold_in = 1;
}

Since it's structured in multiple lines it can be a little bit easier to read for beginners.

I hope this helps you better understand what is happening
Edited by eaniix - July 25, 2023 10:36:06
User Avatar
Member
34 posts
Joined: Feb. 2023
Offline
Thank you for your detailed explanation, it is very helpful.

I am not familiarized what ChatGpt gets to eat, but you will be quite shocked that it explained the VEX parameter close to your description. So I guess, the answer is: Yes, it can explain line by line what is happening. I am not sure if it can code in VEX, but at least it can describe a vex code you load into it.


In the case of the tutorial, I can see there are many primitives shaping the surface. If you write pt 2 and 3 to determine the folding edge, how does it know about the other indexes? Since there are points that go to 129. Honestly by looking at the sim:


I can still not figure out what is happening with those lines of code and the effect on the sim. I see many indexes and I notice visually there are specific points pushing in and creating an inverted pyramid.



I have a question aside from VEX, can you not do this in Houdini without it? Could you specify groups in the vellum constraint node?

I understand it must be really time-consuming and exhausting to clarify this to someone with no knowledge, so feel free to ignore this second message, you were already kind enough to describe the steps.

Thank you

Attachments:
pints.png (490.6 KB)

User Avatar
Member
68 posts
Joined: Nov. 2021
Offline
The array is only listing points related to the primitive it's currently dealing with. So let's say primitive number 802 is made up of point 45, 129 and 567, the array will look like this [45, 129, 567]. pts[n]however calls the first, second or third (and so one) item in the list, so pts[0]would refer to 45, pts[1]to 129 and pts[2]refers to 567, it's just the index of the array which can be any value if printed out. It's all relative to the array that is created for each primitive. It can be hard sometimes to understand this if you don't really see what's going on so instead of just having the VEX-array, you could also write it into an attribute to actually see them in the geometry spreadsheet. You can do that by adding the following line at the end of you code.

i[]@pts = pts;

You can create VEX-variables by first specifying the type and then giving it a name
float name1
int name2
string name3
vector name4

These are only stored in the current wrangle. If you want to visualize them or keep the data in the stream to use it on your geometry, you can create an attribute using the @-sign followed by the name of the attribute. In front of the @ comes the first letter of the type of variable you want it to be, f for float, i for integer etc.

f@name1
i@name2
s@name3
v@name4

Instead of VEX you could also use VOPs which can do the same and is a bit more visual since it's all node-based.

I didn't watch the tutorial so I can't tell what exactly is happening there, all I can say is that the code is used to attach certain primitives to a group.
Edited by eaniix - July 25, 2023 15:50:30
User Avatar
Member
34 posts
Joined: Feb. 2023
Offline
Thanks so much for this. Now I solve one part of the puzzle by understanding pt 2 and 3 are just recipients for whatever index number is allocated in each triangle. Points 2 and 3 describe the edge working as the axis he wants to fold the triangles. So basically, If I imagine the triangle (primitive), points 2 and 3 are just the edge that creates the base of the triangle. That makes sense.

I have one more question if its ok to shoot again? Thank you so much.
User Avatar
Member
68 posts
Joined: Nov. 2021
Offline
I'm glad I could help you understand better what's going on!

Sure, go ahead!
  • Quick Links