Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Saving my custom file type, a collection of points with colors
- Dim index As Integer = NumericUpDown1.Value
- If vectordata.Count = 0 Then 'Vectordata is an array (list) of a structure that contains X,Y, and Z
- MsgBox("Nothing to save")
- Return
- End If
- Dim bytes As List(Of Byte) = New List(Of Byte)
- For i = 0 To vectordata(index).Count - 1
- Dim pointX() As Byte = BitConverter.GetBytes(vectordata(index)(i).X)
- Dim pointY() As Byte = BitConverter.GetBytes(vectordata(index)(i).Y)
- Dim pointZ() As Byte = BitConverter.GetBytes(vectordata(index)(i).Z)
- bytes.Add(pointX(0))
- bytes.Add(pointX(1))
- bytes.Add(pointX(2))
- bytes.Add(pointX(3))
- bytes.Add(pointY(0))
- bytes.Add(pointY(1))
- bytes.Add(pointY(2))
- bytes.Add(pointY(3))
- bytes.Add(pointZ(0))
- bytes.Add(pointZ(1))
- bytes.Add(pointZ(2))
- bytes.Add(pointZ(3))
- bytes.Add(colordata(index)(i).R)
- bytes.Add(colordata(index)(i).G)
- bytes.Add(colordata(index)(i).B)
- Next
- Dim bytez(bytes.Count - 1) As Byte
- For i = 0 To bytes.Count - 1
- bytez(i) = bytes(i)
- Next
- GC.Collect()
- IO.File.WriteAllBytes(SFD1.FileName, bytez)
- GC.Collect()
- 'Reading my custom file type
- Dim filelocation() As String = OFD1.FileNames 'OFD1 is the openfiledialog that is enabled for multiple files
- Dim bytez() As Byte
- For i2 = 0 To filelocation.Length - 1
- If System.IO.File.Exists(filelocation(i2)) = True Then
- GC.Collect()
- bytez = System.IO.File.ReadAllBytes(filelocation(i2))
- GC.Collect()
- vectordata.Add(New List(Of Vector3))
- colordata.Add(New List(Of Color))
- vectordata(currentframe) = New List(Of Vector3)
- colordata(currentframe) = New List(Of Color)
- rotatedata.Add(New Vector3(0, 0, 0))
- translatedata.Add(New Vector3(0, 0, 0))
- For i = 0 To bytez.Length - 1 Step 15
- Dim Px As Single = BitConverter.ToSingle(bytez, i + 0)
- Dim Py As Single = BitConverter.ToSingle(bytez, i + 4)
- Dim Pz As Single = BitConverter.ToSingle(bytez, i + 8)
- Dim Pc As Color = Color.FromArgb(bytez(i + 12), bytez(i + 13), bytez(i + 14))
- vectordata(currentframe).Add(New Vector3(Px, Py, Pz))
- colordata(currentframe).Add(Pc)
- Next
- currentframe = currentframe + 1
- End If
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement