Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Writing an Obj File
- 'Vectordata is an arry structure of decimals, with X,Y and Z.
- 'Colordata is an array of drawing.color types
- Dim pointstring(vectordata.Count - 1) As String
- For i = 0 To vectordata.Count - 1
- pointstring(i) = "v " & vectordata(i).X.ToString & " " & vectordata(i).Y.ToString & " " & vectordata(i).Z.ToString & " " & colordata(i).R / 255 & " " & colordata(i).G / 255 & " " & colordata(i).B / 255
- Next
- GC.Collect()
- IO.File.WriteAllLines(SaveFileDialog1.FileName, pointstring)
- GC.Collect()
- 'Reading a Obj File
- Dim pointsstring() As String 'The array of lines to read from file
- GC.Collect()
- pointsstring = System.IO.File.ReadAllLines(filelocation)
- GC.Collect()
- points(objectcount) = New List(Of Vector3) 'Vector3 is a structure containing an X,Y and Z
- Dim X1, Y1, Z1 As Single
- For i = 0 To pointsstring.Length - 1
- If pointsstring(i).Length > 2 Then
- If pointsstring(i)(0) = "v" And pointsstring(i)(1) = " " Then
- Dim tempstring = pointsstring(i)
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim XST As String = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim YST As String = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- pointsstring(i) = pointsstring(i).Substring(pointsstring(i).IndexOf(" ") + 1)
- Dim tempint As Integer = pointsstring(i).IndexOf(" ")
- Dim ZST As String
- If tempint <> -1 Then
- ZST = pointsstring(i).Substring(0, pointsstring(i).IndexOf(" "))
- Else
- ZST = pointsstring(i)
- End If
- X1 = XST
- Y1 = YST
- Z1 = ZST
- End If
- End If
- points(objectcount).Add(New Vector3(X1, Y1, Z1))
- Next
- objectcount = objectcount + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement