@jordy1989 wrote:
Hi all,
I got a list with vertices and a list with faces.
In each list the X, Y and Z or 3 items after each other.
Same with the faces. For example. In the face list a triangle is faces(0), faces(1) and faces(2).I got this code to convert it to a STL.
But something is going wrong and I am just staring blind to a screen...If someone got the time please take a quick look:
Dim x As Integer = 0
Dim y As Integer = 1
Dim z As Integer = 2
Dim filename As String = "testScan.stl"
Dim stlString As New StringBuilder
stlString.AppendLine("solid " & filename)
For i = 0 To Faces.Count - 1 Step 3Dim face1 As Integer = Faces(i) Dim face2 As Integer = Faces(i + 1) Dim face3 As Integer = Faces(i + 2) Dim p1() As Single = {vertices(face1 + x), vertices(face1 + y), vertices(face1 + z)} Dim p2() As Single = {vertices(face2 + x), vertices(face2 + y), vertices(face2 + z)} Dim p3() As Single = {vertices(face3 + x), vertices(face3 + y), vertices(face3 + z)} stlString.AppendLine("facet normal 0.0 0.0 0.0") stlString.AppendLine(" outer loop") stlString.AppendLine(" vertex " & p1(x).ToString.Replace(",", ".") & " " & p1(y).ToString.Replace(",", ".") & " " & p1(z).ToString.Replace(",", ".")) stlString.AppendLine(" vertex " & p2(x).ToString.Replace(",", ".") & " " & p2(y).ToString.Replace(",", ".") & " " & p2(z).ToString.Replace(",", ".")) stlString.AppendLine(" vertex " & p3(x).ToString.Replace(",", ".") & " " & p3(y).ToString.Replace(",", ".") & " " & p3(z).ToString.Replace(",", ".")) stlString.AppendLine(" endloop") stlString.AppendLine("endfacet")
Next
stlString.AppendLine("endsolid " & filename)
Posts: 3
Participants: 2