Create Mesh Simple

Hi team, can I know any issue with this code ? I have some confuse with example from team.

I’m try create some mesh but it not show :face_with_monocle:

List<Base> baseMeshes = new List<Base>();
// Triangle 1
var vertices = new List<double> { 0, 0, 0, 1, 0, 0, 0, 1, 0, };
var faces = new List<int> { 0, 1, 2,};

// Append Triangle 2 vertices
vertices = new List<double> {  0, 0, 0, 0, 0, 1, 1, 1, 0 } ;
faces = new List<int> { 3, 4, 5,  } ;

Objects.Geometry.Mesh baseMesh = new Objects.Geometry.Mesh( vertices, faces );
baseMeshes.Add( baseMesh );
string streamId = "db5902deb6";
// send list baseMeshes to speckle
Base data = new Base();
data["@baseMeshes"] = baseMeshes;
Console.WriteLine("Done with Send Data To Speckle");
string send = await Helpers.Send(streamId, data, "test").ConfigureAwait(false);

Any help apprecitate

Your Faces list needs to be fomulated differently.

for Vertices [ 0,0,0, 1,0,2, 3,3,3 ... ]

should have a Faces of [ 3, 0, 3, 6 ... ]

to break that down the set of four figures

n, V1, V2, V3 = number of vertices for the face followed by the starting index for each vertex X, Y Z

so for a quad face:

[ 4, 0, 3, 6, 9 ]

1 Like

Thank for quick help, I guess it must easier :joy::

 List<Base> baseMeshes = new List<Base>();

            // Triangle 1
            var vertices1 = new List<double> { 0, 0, 0, 1, 0, 0, 0, 1, 0 };
            var faces1 = new List<int> { 0, 1, 2 };

            // Triangle 2
            var vertices2 = new List<double> { 0, 0, 0, 0, 0, 1, 1, 1, 0 };
            var faces2 = new List<int> { 3, 4, 5 };

            Objects.Geometry.Mesh baseMesh1 = new Objects.Geometry.Mesh(vertices1, faces1);
            Objects.Geometry.Mesh baseMesh2 = new Objects.Geometry.Mesh(vertices2, faces2);

            baseMeshes.Add(baseMesh1);
            baseMeshes.Add(baseMesh2);

            string streamId = "db5902deb6";

            // send list baseMeshes to speckle
            Base data = new Base();
            data["@baseMeshes"] = baseMeshes;
            Console.WriteLine("Done with Send Data To Speckle");
            string send = await Helpers.Send(streamId, data, "test").ConfigureAwait(false);

It is still your faces array that needs work.

 // Triangle 1
var vertices1 = new List<double> { 0, 0, 0, 1, 0, 0, 0, 1, 0 };
var faces1 = new List<int> { 3, 0, 3, 6 };

// Triangle 2
var vertices2 = new List<double> { 0, 0, 0, 0, 0, 1, 1, 1, 0 };
var faces2 = new List<int> { 3, 0, 3, 6 };
1 Like

Thank you @jonathon , Now I understand the meaning now. :smiling_face_with_three_hearts:

1 Like