Пример #1
0
    public void Flush(Stream framedStream)
    {
        var frame = new FramedStream(framedStream, 6);

        frame.Flush();
        framedStream.Received(1).Flush();
    }
Пример #2
0
    public void SeekBegin(Stream framedStream)
    {
        framedStream.Position = 3;
        var frame = new FramedStream(framedStream, 6, doDispose: false);

        frame.Seek(10, SeekOrigin.Begin);
        framedStream.Position.Should().Be(13);
    }
            public FramedStream ReadFile(String name)
            {
                ImageArchiveEntry entry  = myFileDict[name];
                FramedStream      stream = new FramedStream(myStream);

                stream.PushFrame(entry.Offset, entry.Size);
                return(stream);
            }
Пример #4
0
    public void FramedStreamShorter(Stream framedStream)
    {
        framedStream.Length.Returns(4);
        var frame = new FramedStream(framedStream, 6);

        frame.Length.Should().Be(4);
        frame.Position.Should().Be(0);
    }
Пример #5
0
        public SectionHeader(FramedStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            Type = (SectionType)reader.ReadUInt32();
            Size = reader.ReadUInt32();
            reader.ReadUInt16(); // Unknown
            Version = reader.ReadUInt16();
        }
Пример #6
0
 public Section(FramedStream stream)
 {
     stream.PushFrame(12);
     Header = new SectionHeader(stream);
     stream.PopFrame();
     stream.PushFrame(Header.Size);
     Data = SectionData.FromStream(Header, stream);
     stream.PopFrame();
 }
        public MaterialListSectionData( SectionHeader header, FramedStream stream )
        {
            Section data = new Section( stream );
            MaterialCount = BitConverter.ToUInt32( ( data.Data as DataSectionData ).Value, 0 );
            Materials = new MaterialSectionData[ MaterialCount ];

            for ( int i = 0; i < MaterialCount; ++i )
                Materials[ i ] = new Section( stream ).Data as MaterialSectionData;
        }
Пример #8
0
 public Section( FramedStream stream )
 {
     stream.PushFrame( 12 );
     Header = new SectionHeader( stream );
     stream.PopFrame();
     stream.PushFrame( Header.Size );
     Data = SectionData.FromStream( Header,  stream );
     stream.PopFrame();
 }
Пример #9
0
    public void WriteOutOfRange(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var    frame = new FramedStream(framedStream, 6, doDispose: false);
        Action act   = () => frame.Write(Array.Empty <byte>(), 0, 7);

        act.Should().Throw <ArgumentOutOfRangeException>();
    }
Пример #10
0
    public void FramedStreamUnknown(Stream framedStream)
    {
        framedStream.Length.Returns(-1);
        framedStream.Position = 0;
        var frame = new FramedStream(framedStream, 6);

        frame.Length.Should().Be(6);
        frame.Position.Should().Be(0);
    }
Пример #11
0
    public void FramedStreamShorterDueToPos(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 8;
        var frame = new FramedStream(framedStream, 6);

        frame.Length.Should().Be(2);
        frame.Position.Should().Be(0);
    }
Пример #12
0
    public void FramedPositionSet(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var frame = new FramedStream(framedStream, 6);

        frame.Position += 2;
        framedStream.Position.Should().Be(2);
    }
Пример #13
0
    public void PositionSet(Stream framedStream)
    {
        framedStream.Position = 3;
        var frame = new FramedStream(framedStream, 6, doDispose: false);

        frame.Position += 10;
        frame.Position.Should().Be(10);
        framedStream.Position.Should().Be(13);
    }
        public TextureNativeSectionData( SectionHeader header, FramedStream stream )
        {
            SectionHeader dataHeader = new SectionHeader( stream );
            BinaryReader reader = new BinaryReader( stream );

            PlatformID = reader.ReadUInt32();
            FilterFlags = (Filter) reader.ReadUInt16();
            WrapV = (WrapMode) reader.ReadByte();
            WrapU = (WrapMode) reader.ReadByte();
            DiffuseName = reader.ReadString( 32 );
            AlphaName = reader.ReadString( 32 );
            Format = (RasterFormat) reader.ReadUInt32();

            if ( PlatformID == 9 )
            {
                String dxt = reader.ReadString( 4 );
                switch ( dxt )
                {
                    case "DXT1":
                        Compression = CompressionMode.DXT1; break;
                    case "DXT3":
                        Compression = CompressionMode.DXT3; break;
                    default:
                        Compression = CompressionMode.None; break;
                }
            }
            else
                Alpha = reader.ReadUInt32() == 0x1;

            Width = reader.ReadUInt16();
            Height = reader.ReadUInt16();
            BPP = (byte) ( reader.ReadByte() >> 3 );
            MipMapCount = reader.ReadByte();
            RasterType = reader.ReadByte();

            if ( RasterType != 0x4 )
                throw new Exception( "Unexpected RasterType, expected 0x04." );

            if ( PlatformID == 9 )
                Alpha = ( reader.ReadByte() & 0x1 ) == 0x1;
            else
                Compression = (CompressionMode) reader.ReadByte();

            ImageDataSize = reader.ReadUInt32();
            if ( ( Format & RasterFormat.ExtMipMap ) != 0 )
            {
                ImageLevelData = new byte[ MipMapCount ][];
                for ( int i = 0; i < MipMapCount; ++i )
                    ImageLevelData[ i ] = reader.ReadBytes( (int) ImageDataSize >> ( 2 * i ) );
            }
            else
            {
                ImageLevelData = new byte[ 1 ][];
                ImageLevelData[ 0 ] = reader.ReadBytes( (int) ImageDataSize );
            }
        }
Пример #15
0
    public void SeekEnd(Stream framedStream)
    {
        framedStream.Position = 3;
        framedStream.Length.Returns(10);
        var frame = new FramedStream(framedStream, 6, doDispose: false);

        frame.Seek(-3, SeekOrigin.End);
        frame.Position.Should().Be(3);
        framedStream.Position.Should().Be(6);
    }
Пример #16
0
        public ClumpSectionData( SectionHeader header, FramedStream stream )
        {
            DataSectionData dat = (DataSectionData) new Section( stream ).Data;
            if ( dat == null )
                return;

            ObjectCount = BitConverter.ToUInt32( dat.Value, 0 );
            var frameList = new Section( stream );
            GeometryList = (GeometryListSectionData) new Section( stream ).Data;
        }
Пример #17
0
    public void ReadAll(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var       frame  = new FramedStream(framedStream, 6, doDispose: false);
        const int offset = 5;

        byte[] b = new byte[10];
        frame.Read(b, offset, (int)frame.Length);
        framedStream.Received(1).Read(b, offset, (int)frame.Length);
    }
Пример #18
0
        public TextureSectionData(SectionHeader header, FramedStream stream)
        {
            SectionHeader dataHeader = new SectionHeader(stream);
            BinaryReader  reader     = new BinaryReader(stream);

            FilterMode = (TextureNativeSectionData.Filter)reader.ReadUInt16();
            var unk = reader.ReadUInt16(); // Unknown

            TextureName = (new Section(stream).Data as StringSectionData).Value;
            MaskName    = (new Section(stream).Data as StringSectionData).Value;
        }
Пример #19
0
        public GeometryListSectionData(SectionHeader header, FramedStream stream)
        {
            DataSectionData data = (DataSectionData) new Section(stream).Data;

            GeometryCount = BitConverter.ToUInt32(data.Value, 0);
            Geometry      = new GeometrySectionData[GeometryCount];

            for (int i = 0; i < GeometryCount; ++i)
            {
                Geometry[i] = (GeometrySectionData) new Section(stream).Data;
            }
        }
Пример #20
0
    public void FramedPositionIncrement(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var frame = new FramedStream(framedStream, 6);

        frame.Length.Should().Be(6);
        frame.Position.Should().Be(0);
        framedStream.Position = 6;
        frame.Length.Should().Be(6);
        frame.Position.Should().Be(6);
    }
Пример #21
0
    public void Write(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var       frame  = new FramedStream(framedStream, 6, doDispose: false);
        const int offset = 5;
        const int count  = 3;

        byte[] b = new byte[10];
        frame.Write(b, offset, count);
        framedStream.Received(1).Write(b, offset, 3);
    }
Пример #22
0
        public MaterialListSectionData(SectionHeader header, FramedStream stream)
        {
            Section data = new Section(stream);

            MaterialCount = BitConverter.ToUInt32((data.Data as DataSectionData).Value, 0);
            Materials     = new MaterialSectionData[MaterialCount];

            for (int i = 0; i < MaterialCount; ++i)
            {
                Materials[i] = new Section(stream).Data as MaterialSectionData;
            }
        }
        public TextureDictionarySectionData( SectionHeader header, FramedStream stream )
        {
            SectionHeader dataHeader = new SectionHeader( stream );
            BinaryReader reader = new BinaryReader( stream );

            TextureCount = reader.ReadUInt16();
            Textures = new TextureNativeSectionData[ TextureCount ];
            reader.ReadUInt16(); // Unknown

            for ( int i = 0; i < TextureCount; ++i )
                Textures[ i ] = new Section( stream ).Data as TextureNativeSectionData;
        }
        public MaterialSplit( UInt16 offset, FramedStream stream )
        {
            Offset = offset;
            BinaryReader reader = new BinaryReader( stream );
            VertexCount = (UInt16) reader.ReadUInt32();
            FaceIndices = new UInt16[ VertexCount + 1 ];
            MaterialIndex = (UInt16) reader.ReadUInt32();

            for ( int i = 0; i < VertexCount; ++i )
                FaceIndices[ i ] = (UInt16) reader.ReadUInt32();

            FaceIndices[ VertexCount++ ] = 0xffff;
        }
        public TextureDictionarySectionData(SectionHeader header, FramedStream stream)
        {
            SectionHeader dataHeader = new SectionHeader(stream);
            BinaryReader  reader     = new BinaryReader(stream);

            TextureCount = reader.ReadUInt16();
            Textures     = new TextureNativeSectionData[TextureCount];
            reader.ReadUInt16(); // Unknown

            for (int i = 0; i < TextureCount; ++i)
            {
                Textures[i] = new Section(stream).Data as TextureNativeSectionData;
            }
        }
Пример #26
0
        public ClumpSectionData(SectionHeader header, FramedStream stream)
        {
            DataSectionData dat = (DataSectionData) new Section(stream).Data;

            if (dat == null)
            {
                return;
            }

            ObjectCount = BitConverter.ToUInt32(dat.Value, 0);
            var frameList = new Section(stream);

            GeometryList = (GeometryListSectionData) new Section(stream).Data;
        }
        public MaterialSplit(UInt16 offset, FramedStream stream)
        {
            Offset = offset;
            BinaryReader reader = new BinaryReader(stream);

            VertexCount   = (UInt16)reader.ReadUInt32();
            FaceIndices   = new UInt16[VertexCount + 1];
            MaterialIndex = (UInt16)reader.ReadUInt32();

            for (int i = 0; i < VertexCount; ++i)
            {
                FaceIndices[i] = (UInt16)reader.ReadUInt32();
            }

            FaceIndices[VertexCount++] = 0xffff;
        }
Пример #28
0
        public MaterialSectionData( SectionHeader header, FramedStream stream )
        {
            SectionHeader dataHeader = new SectionHeader( stream );
            BinaryReader reader = new BinaryReader( stream );

            reader.ReadUInt32(); // Unknown
            Colour = new Color4( reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte() );
            var unk = reader.ReadUInt32(); // Unknown
            TextureCount = reader.ReadUInt32();
            Textures = new TextureSectionData[ TextureCount ];
            reader.ReadSingle(); // Unknown
            reader.ReadSingle(); // Unknown
            reader.ReadSingle(); // Unknown

            for ( int i = 0; i < TextureCount; ++i )
                Textures[ i ] = new Section( stream ).Data as TextureSectionData;
        }
        public MaterialSplitSectionData( SectionHeader header, FramedStream stream )
        {
            BinaryReader reader = new BinaryReader( stream );

            TriangleStrip = reader.ReadUInt32() == 1;
            SplitCount = reader.ReadUInt32();
            MaterialSplits = new MaterialSplit[ SplitCount ];
            FaceCount = reader.ReadUInt32();

            IndexCount = 0;
            for ( UInt16 i = 0; i < SplitCount; ++i )
            {
                MaterialSplits[ i ] = new MaterialSplit( IndexCount, stream );
                IndexCount += MaterialSplits[ i ].VertexCount;
            }

            if ( FaceCount + SplitCount != IndexCount )
                throw new Exception( "Bad model format" );
        }
Пример #30
0
        public InstPlacement( FramedStream stream )
        {
            BinaryReader reader = new BinaryReader( stream );

            float posX = -reader.ReadSingle();
            float posZ = reader.ReadSingle();
            float posY = reader.ReadSingle();
            Position = new Vector3( posX, posY, posZ );
            float rotX = -reader.ReadSingle();
            float rotZ = reader.ReadSingle();
            float rotY = reader.ReadSingle();
            float rotW = reader.ReadSingle();
            Rotation = new Quaternion( rotX, rotY, rotZ, rotW );
            ObjectID = reader.ReadUInt32();
            Object = ItemManager.GetObject( ObjectID );
            CellID = (UInt16) reader.ReadInt32();
            LODIndex = reader.ReadInt32();
            IsLOD = false;
        }
Пример #31
0
        public TextureDictionary( String name, FramedStream stream )
        {
            Name = name;

            Section sec = new Section( stream );
            TextureDictionarySectionData data = sec.Data as TextureDictionarySectionData;

            myDiffuseTextures = new Dictionary<string, Texture2D>();
            myMaskTextures = new Dictionary<string, Texture2D>();

            foreach ( TextureNativeSectionData tex in data.Textures )
            {
                Texture2D t2d = new Texture2D( tex );
                if ( tex.DiffuseName.Length > 0 && !myDiffuseTextures.ContainsKey( tex.DiffuseName ) )
                    myDiffuseTextures.Add( tex.DiffuseName, t2d );
                if ( tex.AlphaName.Length > 0 && !myMaskTextures.ContainsKey( tex.AlphaName ) )
                    myMaskTextures.Add( tex.AlphaName, t2d );
            }
        }
Пример #32
0
        public Model( String name, FramedStream stream )
        {
            Name = name;

            List<GeometrySectionData> geos = new List<GeometrySectionData>();
            while ( stream.CanRead )
            {
                SectionHeader header = new SectionHeader( stream );
                if ( header.Type == SectionType.Clump )
                {
                    ClumpSectionData data = SectionData.FromStream<ClumpSectionData>( header, stream );
                    if( data.GeometryList != null )
                        geos.AddRange( data.GeometryList.Geometry );
                }
                break;
            }
            myGeometry = geos.ToArray();

            VertexBuffer = null;
        }
Пример #33
0
        public MaterialSectionData(SectionHeader header, FramedStream stream)
        {
            SectionHeader dataHeader = new SectionHeader(stream);
            BinaryReader  reader     = new BinaryReader(stream);

            reader.ReadUInt32();           // Unknown
            Colour = new Color4(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
            var unk = reader.ReadUInt32(); // Unknown

            TextureCount = reader.ReadUInt32();
            Textures     = new TextureSectionData[TextureCount];
            reader.ReadSingle(); // Unknown
            reader.ReadSingle(); // Unknown
            reader.ReadSingle(); // Unknown

            for (int i = 0; i < TextureCount; ++i)
            {
                Textures[i] = new Section(stream).Data as TextureSectionData;
            }
        }
Пример #34
0
        public static T FromStream <T>(SectionHeader header, FramedStream stream)
            where T : SectionData
        {
            if (myDataTypes == null)
            {
                FindTypes();
            }

            T data = null;

            if (myDataTypes.ContainsKey(header.Type))
            {
                Type            t    = myDataTypes[header.Type];
                ConstructorInfo cons = t.GetConstructor(new Type[] { typeof(SectionHeader), typeof(FramedStream) });
                if (cons != null)
                {
                    data = (T)cons.Invoke(new object[] { header, stream });
                }
            }
            return(data);
        }
Пример #35
0
        public InstPlacement(FramedStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            float posX = -reader.ReadSingle();
            float posZ = reader.ReadSingle();
            float posY = reader.ReadSingle();

            Position = new Vector3(posX, posY, posZ);
            float rotX = -reader.ReadSingle();
            float rotZ = reader.ReadSingle();
            float rotY = reader.ReadSingle();
            float rotW = reader.ReadSingle();

            Rotation = new Quaternion(rotX, rotY, rotZ, rotW);
            ObjectID = reader.ReadUInt32();
            Object   = ItemManager.GetObject(ObjectID);
            CellID   = (UInt16)reader.ReadInt32();
            LODIndex = reader.ReadInt32();
            IsLOD    = false;
        }
        public MaterialSplitSectionData(SectionHeader header, FramedStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            TriangleStrip  = reader.ReadUInt32() == 1;
            SplitCount     = reader.ReadUInt32();
            MaterialSplits = new MaterialSplit[SplitCount];
            FaceCount      = reader.ReadUInt32();

            IndexCount = 0;
            for (UInt16 i = 0; i < SplitCount; ++i)
            {
                MaterialSplits[i] = new MaterialSplit(IndexCount, stream);
                IndexCount       += MaterialSplits[i].VertexCount;
            }

            if (FaceCount + SplitCount != IndexCount)
            {
                throw new Exception("Bad model format");
            }
        }
Пример #37
0
        public TextureDictionary(String name, FramedStream stream)
        {
            Name = name;

            Section sec = new Section(stream);
            TextureDictionarySectionData data = sec.Data as TextureDictionarySectionData;

            myDiffuseTextures = new Dictionary <string, Texture2D>();
            myMaskTextures    = new Dictionary <string, Texture2D>();

            foreach (TextureNativeSectionData tex in data.Textures)
            {
                Texture2D t2d = new Texture2D(tex);
                if (tex.DiffuseName.Length > 0 && !myDiffuseTextures.ContainsKey(tex.DiffuseName))
                {
                    myDiffuseTextures.Add(tex.DiffuseName, t2d);
                }
                if (tex.AlphaName.Length > 0 && !myMaskTextures.ContainsKey(tex.AlphaName))
                {
                    myMaskTextures.Add(tex.AlphaName, t2d);
                }
            }
        }
Пример #38
0
        public Model(String name, FramedStream stream)
        {
            Name = name;

            List <GeometrySectionData> geos = new List <GeometrySectionData>();

            while (stream.CanRead)
            {
                SectionHeader header = new SectionHeader(stream);
                if (header.Type == SectionType.Clump)
                {
                    ClumpSectionData data = SectionData.FromStream <ClumpSectionData>(header, stream);
                    if (data.GeometryList != null)
                    {
                        geos.AddRange(data.GeometryList.Geometry);
                    }
                }
                break;
            }
            myGeometry = geos.ToArray();

            VertexBuffer = null;
        }
Пример #39
0
    public void ReadOutOfRange()
    {
        byte[] bufIn = new byte[10];
        for (byte i = 0; i < 10; i++)
        {
            bufIn[i] = i;
        }

        var framedStream = new MemoryStream(bufIn);
        var frame        = new FramedStream(framedStream, 6, doDispose: false);

        byte[] buf = new byte[100];
        frame.Read(buf, 0, 7)
        .Should().Be(6);
        for (byte i = 0; i < 6; i++)
        {
            buf[i].Should().Be(i);
        }

        for (int i = 6; i < 100; i++)
        {
            buf[i].Should().Be(0);
        }
    }
Пример #40
0
        public GeometrySectionData( SectionHeader header, FramedStream stream )
        {
            SectionHeader dataHeader = new SectionHeader( stream );
            BinaryReader reader = new BinaryReader( stream );

            Flags = (GeometryFlag) reader.ReadUInt16();
            reader.ReadUInt16(); // Unknown
            FaceCount = reader.ReadUInt32();
            VertexCount = reader.ReadUInt32();
            FrameCount = reader.ReadUInt32();

            if ( dataHeader.Version == 4099 )
            {
                Ambient = reader.ReadSingle();
                Diffuse = reader.ReadSingle();
                Specular = reader.ReadSingle();
            }

            if ( ( Flags & GeometryFlag.Colors ) != 0 )
            {
                Colours = new Color4[ VertexCount ];
                for ( int i = 0; i < VertexCount; ++i )
                {
                    byte r = reader.ReadByte();
                    byte g = reader.ReadByte();
                    byte b = reader.ReadByte();
                    byte a = reader.ReadByte();
                    Colours[ i ] = new Color4( r, g, b, a );
                }
            }

            if ( ( Flags & GeometryFlag.TexCoords ) != 0 )
            {
                TexCoords = new Vector2[ VertexCount ];
                for ( int i = 0; i < VertexCount; ++i )
                    TexCoords[ i ] = reader.ReadVector2();
            }

            Faces = new FaceInfo[ FaceCount ];
            for ( int i = 0; i < FaceCount; ++i )
                Faces[ i ] = new FaceInfo( reader );

            BoundingSphere = new BoundingSphere( reader );

            HasPosition = reader.ReadUInt32();
            HasNormals = reader.ReadUInt32();

            if ( HasPosition > 1 || HasNormals > 1 )
                throw new Exception( "Well there you go" );

            Vertices = new Vector3[ VertexCount ];
            for ( int i = 0; i < VertexCount; ++i )
                Vertices[ i ] = reader.ReadVector3();

            if ( ( Flags & GeometryFlag.Normals ) != 0 )
            {
                Normals = new Vector3[ VertexCount ];
                for ( int i = 0; i < VertexCount; ++i )
                    Normals[ i ] = reader.ReadVector3();
            }

            Materials = ( new Section( stream ).Data as MaterialListSectionData ).Materials;

            SectionHeader extHeader = new SectionHeader( stream );
            MaterialSplitSectionData msplits = new Section( stream ).Data as MaterialSplitSectionData;
            MaterialSplits = msplits.MaterialSplits;
            FaceCount = msplits.FaceCount;
            IndexCount = msplits.IndexCount;

            foreach ( MaterialSplit mat in MaterialSplits )
                mat.Material = Materials[ mat.MaterialIndex ];
        }
Пример #41
0
 public DataSectionData(SectionHeader header, FramedStream stream)
 {
     Value = new byte[header.Size];
     stream.Read(Value, 0, (int)header.Size);
 }
Пример #42
0
        public GeometrySectionData(SectionHeader header, FramedStream stream)
        {
            SectionHeader dataHeader = new SectionHeader(stream);
            BinaryReader  reader     = new BinaryReader(stream);

            Flags = (GeometryFlag)reader.ReadUInt16();
            reader.ReadUInt16(); // Unknown
            FaceCount   = reader.ReadUInt32();
            VertexCount = reader.ReadUInt32();
            FrameCount  = reader.ReadUInt32();

            if (dataHeader.Version == 4099)
            {
                Ambient  = reader.ReadSingle();
                Diffuse  = reader.ReadSingle();
                Specular = reader.ReadSingle();
            }

            if ((Flags & GeometryFlag.Colors) != 0)
            {
                Colours = new Color4[VertexCount];
                for (int i = 0; i < VertexCount; ++i)
                {
                    byte r = reader.ReadByte();
                    byte g = reader.ReadByte();
                    byte b = reader.ReadByte();
                    byte a = reader.ReadByte();
                    Colours[i] = new Color4(r, g, b, a);
                }
            }

            if ((Flags & GeometryFlag.TexCoords) != 0)
            {
                TexCoords = new Vector2[VertexCount];
                for (int i = 0; i < VertexCount; ++i)
                {
                    TexCoords[i] = reader.ReadVector2();
                }
            }

            Faces = new FaceInfo[FaceCount];
            for (int i = 0; i < FaceCount; ++i)
            {
                Faces[i] = new FaceInfo(reader);
            }

            BoundingSphere = new BoundingSphere(reader);

            HasPosition = reader.ReadUInt32();
            HasNormals  = reader.ReadUInt32();

            if (HasPosition > 1 || HasNormals > 1)
            {
                throw new Exception("Well there you go");
            }

            Vertices = new Vector3[VertexCount];
            for (int i = 0; i < VertexCount; ++i)
            {
                Vertices[i] = reader.ReadVector3();
            }

            if ((Flags & GeometryFlag.Normals) != 0)
            {
                Normals = new Vector3[VertexCount];
                for (int i = 0; i < VertexCount; ++i)
                {
                    Normals[i] = reader.ReadVector3();
                }
            }

            Materials = (new Section(stream).Data as MaterialListSectionData).Materials;

            SectionHeader            extHeader = new SectionHeader(stream);
            MaterialSplitSectionData msplits   = new Section(stream).Data as MaterialSplitSectionData;

            MaterialSplits = msplits.MaterialSplits;
            FaceCount      = msplits.FaceCount;
            IndexCount     = msplits.IndexCount;

            foreach (MaterialSplit mat in MaterialSplits)
            {
                mat.Material = Materials[mat.MaterialIndex];
            }
        }
Пример #43
0
 public DataSectionData( SectionHeader header, FramedStream stream )
 {
     Value = new byte[ header.Size ];
     stream.Read( Value, 0, (int) header.Size );
 }
Пример #44
0
 public StringSectionData( SectionHeader header, FramedStream stream )
 {
     Value = UnicodeEncoding.UTF8.GetString( stream.ReadBytes( (int) header.Size ) ).TrimNullChars();
 }