I know this is not directly about Irrlicht, but quite close and maybe someone can open my eyes.
I try to read(and later to write) the vertex list of an MS3D file. I found the make up of the format at http://astronomy.swin.edu.au/~pbourke/g ... ms3dspec.h
So far so good. My problem is that I'm unable to read the float values
Code: Select all
Private Structure ms3d_vertex
Dim flags As Byte ' SELECTED | SELECTED2 | HIDDEN
Dim X, Y, Z As Single
Dim boneId As Char
Dim referenceCount As Byte
End Structure
Private Sub TestLoadMS3D
Dim Header(9) As Byte
Const MSHeader As String = "MS3D000000"
Dim fs As IO.FileStream
Dim br As IO.BinaryReader
Try
fs = New IO.FileStream("c:\TestBox.ms3d", IO.FileMode.Open)
fs.Read(Header, 0, 10)
If System.Text.Encoding.ASCII.GetString(Header) = MSHeader Then
Dim Version As Integer
br = New IO.BinaryReader(fs)
Version = br.ReadInt32
If Version = 4 Then
Dim n, NoOfVertices As Int16
Dim dd As Double
Dim FloatB(3) As Byte
NoOfVertices = br.ReadInt16
Debug.WriteLine(String.Format("NoOfVertices = {0}", NoOfVertices))
For n = 0 To NoOfVertices - 1
Dim Vertex As ms3d_vertex
Vertex.flags = br.ReadByte
fs.Read(FloatB, 0, 4)
Vertex.X = br.ReadSingle ' <- This must be wrong
Vertex.Y = br.ReadSingle ' <- This must be wrong
Vertex.Z = br.ReadSingle ' <- This must be wrong
Vertex.boneId = br.ReadChar
Vertex.referenceCount = br.ReadByte
Debug.WriteLine(String.Format("Vertex {0}: {1}/ {2}/ {3}", n, Vertex.X, Vertex.Y, Vertex.Z))
Next
Else
MessageBox.Show("Wrong version. Must be 4!")
End If
Else
MessageBox.Show("Not a milkshape file!")
End If
Catch ex As Exception
Stop
Finally
Try
fs.Close()
Catch
' nix
End Try
End Try
End Sub
Thanks
Thorsten
[/code]