How do you construct a mesh from scratch?

How do you construct a mesh from scratch?

muream
Explorer Explorer
1,013 Views
2 Replies
Message 1 of 3

How do you construct a mesh from scratch?

muream
Explorer
Explorer

Hey!
I'm making a Pose Reader component and wanted to draw a cone to visualize the component's behavior properly.
I currently have all the cone vertices in an array, using the construct_mesh node I can show all the points but I can't figure out how to create the actual faces between those points. I bet this is with the face_offset and face_vertex ports but I don't understand how to use them and couldn't find any documentation on that.

Here's a quick video of it in action (the points are connected with a construct_strands node for now)
https://streamable.com/hjw31


I attached the component in its current state. I should have removed any local dependency but if there are any that cause an issue, just tell me and I'll fix that.

Thanks!

Accepted solutions (1)
1,014 Views
2 Replies
Replies (2)
Message 2 of 3

muream
Explorer
Explorer
Accepted solution

I figured it out by going through the different compounds that did that and made a little tutorial on how the construct_mesh node worked. Hopefully it's useful to someone 🙂
https://vimeo.com/358591935

Message 3 of 3

stephen.yee
Autodesk
Autodesk

Great video, thanks for making it Loic!

 

Just wanted to give you a heads up, there is some documentation that describes how the face_offset and face_vertex arrays work. Its a bit buried in the installation directory though. Its located at <bifrost_plugin_install_dir>\plug-ins\bifrost\resources\bif\jsonLibs\doc\getting_started\geometry_basics.md

 

Also, one thing to note (that I will add to the above docs) is that the ordering of the face_vertex elements controls which side of the face is considered the "front". i.e. the direction that the normal points. We use counter-clockwise ordering in Bifrost, which means that if you look at a face head-on, and specify the vertices in a counter-clockwise order, the face will point towards you.

 

twoTriangles.png

In the above example, if we specify the face_vertex array as  0,1,2, 1,3,2  it means the two triangles would point towards us. 

 

If we specified the face_vertex array as: 0,2,1, 3,2,1 then the two triangles would point away from us, into the screen. 

 

For a cube, you usually want the faces pointing towards the outside, i.e. away from the center of the cube. So in your example in the video, the face vertices for that second face should be 4,7,6,5 i.e. downwards. I think that's why the normals come out looking odd. 

 

One easy way to remember this is if you curl the fingers of your right hand in the direction of the face vertices, in the order you specify, then your right thumb will point in the direction of the face normal. 

 

Hopefully that makes sense!

 

0 Likes