Advertisement
Brandan

Untitled

Oct 3rd, 2014
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.28 KB | None | 0 0
  1.  
  2.     Structure ObjFacesInfo
  3.         Dim CurrNormalIdx As Int16
  4.         Dim TextureIdx As Int16
  5.         Dim Flags As UInt16
  6.         Dim NumPoints As Byte
  7.         Dim PolyDrawMode As SByte
  8.         Dim X As List(Of Single) '4!
  9.         Dim Y As List(Of Single) '4!
  10.         Dim PointOffsets As List(Of SByte) '4!
  11.         Dim BaseNormalIdxs As List(Of Byte) '4!
  12.         Dim UVCursorInfo As Byte
  13.         Dim General As Byte
  14.         Dim BucketAdj As SByte
  15.         Dim BldgConstructFlags As Byte
  16.     End Structure
  17.  
  18.     Private Sub Load_FacesInfo(ByVal filepath)
  19.         Dim reader As New BinaryReader(File.Open(filepath, FileMode.Open))
  20.         Dim TABPG As New TabPage
  21.         Dim DGV As New DataGridView
  22.         Dim Objects As New List(Of ObjFacesInfo)
  23.         Dim ObjCount = 0
  24.         While ((reader.BaseStream.Position = reader.BaseStream.Length) = False)
  25.             Dim SingleObj As New ObjFacesInfo
  26.             SingleObj.PointOffsets = New List(Of SByte)
  27.             SingleObj.BaseNormalIdxs = New List(Of Byte)
  28.             SingleObj.X = New List(Of Single)
  29.             SingleObj.Y = New List(Of Single)
  30.             Dim object_reader As New BinaryReader(New MemoryStream(reader.ReadBytes(60))) ' Read 54 bytes
  31.             SingleObj.CurrNormalIdx = object_reader.ReadInt16
  32.             SingleObj.TextureIdx = object_reader.ReadInt16
  33.             SingleObj.Flags = object_reader.ReadUInt16
  34.             SingleObj.NumPoints = object_reader.ReadByte
  35.             SingleObj.PolyDrawMode = object_reader.ReadSByte
  36.             For i As Integer = 0 To 3
  37.                 SingleObj.X.Add(object_reader.ReadSingle)
  38.                 SingleObj.Y.Add(object_reader.ReadSingle)
  39.             Next
  40.             For i As Integer = 0 To 7
  41.                 SingleObj.PointOffsets.Add(object_reader.ReadSByte)
  42.             Next
  43.             For i As Integer = 0 To 7
  44.                 SingleObj.BaseNormalIdxs.Add(object_reader.ReadByte)
  45.             Next
  46.             SingleObj.UVCursorInfo = object_reader.ReadByte
  47.             SingleObj.General = object_reader.ReadByte
  48.             SingleObj.BucketAdj = object_reader.ReadSByte
  49.             SingleObj.BldgConstructFlags = object_reader.ReadByte
  50.             ObjCount = ObjCount + 1
  51.             Objects.Add(SingleObj)
  52.         End While
  53.         DGV.Dock = DockStyle.Fill
  54.         DGV.Name = "DataGridView1"
  55.         DGV.Columns.Add("CurrNormalIdx", "CurrNormalIdx")
  56.         DGV.Columns.Add("TextureIdx", "TextureIdx")
  57.         DGV.Columns.Add("Flags", "Flags")
  58.         DGV.Columns.Add("NumPoints", "NumPoints")
  59.         DGV.Columns.Add("PolyDrawMode", "PolyDrawMode")
  60.  
  61.         For i As Integer = 1 To 4
  62.             DGV.Columns.Add("X" & i, "X" & i)
  63.             DGV.Columns.Add("Y" & i, "Y" & i)
  64.         Next
  65.  
  66.         For i As Integer = 1 To 8
  67.             DGV.Columns.Add("PointOffsets" & i, "PointOffsets" & i)
  68.         Next
  69.         For i As Integer = 1 To 8
  70.             DGV.Columns.Add("BaseNormalIdxs", "BaseNormalIdxs")
  71.         Next
  72.         DGV.Columns.Add("UVCursorInfo", "UVCursorInfo")
  73.         DGV.Columns.Add("General", "General")
  74.         DGV.Columns.Add("BucketAdj", "BucketAdj")
  75.         DGV.Columns.Add("BldgConstructFlags", "BldgConstructFlags")
  76.         For Each obj In Objects
  77.             DGV.Rows.Add(obj.CurrNormalIdx, obj.TextureIdx, obj.Flags, obj.NumPoints, obj.PolyDrawMode, _
  78.                        obj.X(0), obj.Y(0), obj.X(1), obj.Y(1), obj.X(2), obj.Y(2), obj.X(3), obj.Y(3), _
  79.                        obj.PointOffsets(0), obj.PointOffsets(1), obj.PointOffsets(2), obj.PointOffsets(3), obj.PointOffsets(4), obj.PointOffsets(5), obj.PointOffsets(6), obj.PointOffsets(7), _
  80.                        obj.BaseNormalIdxs(0), obj.BaseNormalIdxs(1), obj.BaseNormalIdxs(2), obj.BaseNormalIdxs(3), obj.BaseNormalIdxs(4), obj.BaseNormalIdxs(5), obj.BaseNormalIdxs(6), obj.BaseNormalIdxs(7), _
  81.                        obj.UVCursorInfo, obj.General, obj.BucketAdj, obj.BldgConstructFlags)
  82.         Next
  83.         TABPG.Controls.Add(DGV)
  84.         TABPG.Text = filepath
  85.         TabControl.TabPages.Add(TABPG)
  86.         For Each row As DataGridViewRow In DGV.Rows
  87.             row.HeaderCell.Value = row.Index.ToString()
  88.         Next
  89.         DGV.RowHeadersWidth = 60
  90.         Status.Text = ObjCount & " Objects Loaded!"
  91.         AddEventHandlers(DGV)
  92.         reader.Close()
  93.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement