Beispiel #1
0
        protected void Read(BinaryReader reader)
        {
            Name = reader.ReadStringIso(40);
            ParentName = reader.ReadStringIso(40);

            var textureCount = reader.ReadInt32();
            for (var i = 0; i < textureCount; i++) {
                var textureIndex = reader.ReadInt32();
                if (textureIndex < 0 || textureIndex >= _rsmRoot.TexturesPaths.Count) {
                    throw new Exception("Invalid texture index #" + textureIndex);
                }

                Textureids.Add(textureIndex);
            }

            OffsetMatrix = new Matrix(
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                0, 0, 0, 0
            );

            // @TODO: First was pos_
            Position2 = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Rotationangle = reader.ReadSingle();
            Rotationaxis = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Scale = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

            var vertexCount = reader.ReadInt32();
            for (var i = 0; i < vertexCount; i++) {
                var vertex = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                VerticePositions.Add(vertex);
            }

            var texCoordCount = reader.ReadInt32();
            for (var i = 0; i < texCoordCount; i++) {
                if (_rsmRoot.FileHeader.Version.Version >= 0x0102) {
                    reader.ReadSingle();
                }

                var texCoord = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                TextureCoordinats.Add(texCoord);
            }

            var faceCount = reader.ReadInt32();
            for (var i = 0; i < faceCount; i++) {
                var face = new ModelMeshFace(reader);
                Faces.Add(face);
            }

            var frameCount = reader.ReadInt32();
            for (var i = 0; i < frameCount; i++) {
                var frame = new ModelAnimationFrame(reader);
                Frames.Add(frame);
            }
        }
Beispiel #2
0
        protected void Read(BinaryReader reader)
        {
            Name       = reader.ReadStringIso(40);
            ParentName = reader.ReadStringIso(40);

            var textureCount = reader.ReadInt32();

            for (var i = 0; i < textureCount; i++)
            {
                var textureIndex = reader.ReadInt32();
                if (textureIndex < 0 || textureIndex >= _rsmRoot.TexturesPaths.Count)
                {
                    throw new Exception("Invalid texture index #" + textureIndex);
                }

                Textureids.Add(textureIndex);
            }

            OffsetMatrix = new Matrix(
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0,
                0, 0, 0, 0
                );

            // @TODO: First was pos_
            Position2     = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Position      = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Rotationangle = reader.ReadSingle();
            Rotationaxis  = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            Scale         = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

            var vertexCount = reader.ReadInt32();

            for (var i = 0; i < vertexCount; i++)
            {
                var vertex = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                VerticePositions.Add(vertex);
            }

            var texCoordCount = reader.ReadInt32();

            for (var i = 0; i < texCoordCount; i++)
            {
                if (_rsmRoot.FileHeader.Version.Version >= 0x0102)
                {
                    reader.ReadSingle();
                }

                var texCoord = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                TextureCoordinats.Add(texCoord);
            }

            var faceCount = reader.ReadInt32();

            for (var i = 0; i < faceCount; i++)
            {
                var face = new ModelMeshFace(reader);
                Faces.Add(face);
            }

            var frameCount = reader.ReadInt32();

            for (var i = 0; i < frameCount; i++)
            {
                var frame = new ModelAnimationFrame(reader);
                Frames.Add(frame);
            }
        }