Beispiel #1
0
        // Private Methods
        private void Read(MDChunk model, MDNode node, BinaryReader reader)
        {
            _subMeshPointerTableOffset = reader.ReadUInt32();
            if (_subMeshPointerTableOffset == 0)
            {
                return;
            }

            reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _subMeshPointerTableOffset, SeekOrigin.Begin);
            _numSubmeshes = reader.ReadUInt16();
            _numUnknown = reader.ReadUInt16();
            _subMeshPointerArray = new uint[_numSubmeshes];

            if (_numSubmeshes == 0 && _numUnknown == 0)
            {
                return;
            }

            for (int i = 0; i < _numSubmeshes; i++)
            {
                _subMeshPointerArray[i] = reader.ReadUInt32();
            }

            _subMeshes = new IMDSubMesh[_numSubmeshes];
            for (int i = 0; i < _numSubmeshes; i++)
            {
                reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _subMeshPointerArray[i], SeekOrigin.Begin);
                _subMeshes[i] = MDSubMeshFactory.Get(model, node, reader);
            }
        }
Beispiel #2
0
        // Private Methods
        private void Read(MDChunk model, MDNode node, BinaryReader reader)
        {
            _subMeshPointerTableOffset = reader.ReadUInt32();
            if (_subMeshPointerTableOffset == 0)
            {
                return;
            }

            reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _subMeshPointerTableOffset, SeekOrigin.Begin);
            _numSubmeshes        = reader.ReadUInt16();
            _numUnknown          = reader.ReadUInt16();
            _subMeshPointerArray = new uint[_numSubmeshes];

            if (_numSubmeshes == 0 && _numUnknown == 0)
            {
                return;
            }

            for (int i = 0; i < _numSubmeshes; i++)
            {
                _subMeshPointerArray[i] = reader.ReadUInt32();
            }

            _subMeshes = new IMDSubMesh[_numSubmeshes];
            for (int i = 0; i < _numSubmeshes; i++)
            {
                reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _subMeshPointerArray[i], SeekOrigin.Begin);
                _subMeshes[i] = MDSubMeshFactory.Get(model, node, reader);
            }
        }
Beispiel #3
0
        // Methods
        public static IMDSubMesh Get(MDChunk model, MDNode node, BinaryReader reader)
        {
            IntPtr ptr  = (IntPtr)reader.BaseStream.Position;
            uint   type = reader.ReadUInt32();

            switch (type)
            {
            case 1:
                return(new MDSubMeshType1(model, node, ptr, reader));

            case 2:
                return(new MDSubMeshType2(model, node, ptr, reader));

            default:
                return(null);
            }
        }
Beispiel #4
0
        // Private Methods
        private void Read(BinaryReader reader)
        {
            offset  = (int)reader.BaseStream.Position - HEADER_SIZE;
            _unused = reader.ReadUInt32();
            _addressRelocTableOffset = reader.ReadInt32();
            _addressRelocTableSize   = reader.ReadInt32();
            _unk1                  = reader.ReadUInt32();
            _unk2                  = reader.ReadUInt32();
            _nodeArrayOffset       = reader.ReadUInt32();
            _materialArrayOffset   = reader.ReadUInt32();
            _unk3                  = reader.ReadUInt32();
            _nodeNameSectionOffset = reader.ReadUInt32();

            reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _nodeArrayOffset, SeekOrigin.Begin);
            _numNodes = reader.ReadUInt32();
            reader.AlignPosition(16);
            long nodeArrayPos = reader.BaseStream.Position;

            reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _materialArrayOffset, SeekOrigin.Begin);
            _numMaterials = reader.ReadUInt32();
            _materials    = new MDMaterial[_numMaterials];
            for (int i = 0; i < _numMaterials; i++)
            {
                _materials[i] = new MDMaterial(reader);
            }

            if (_nodeNameSectionOffset != 0)
            {
                reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _nodeNameSectionOffset, SeekOrigin.Begin);
                _nodeNameSection = new NDNM(_numNodes, reader);
            }

            _nodes = new MDNode[_numNodes];
            for (int i = 0; i < _numNodes; i++)
            {
                reader.BaseStream.Seek(nodeArrayPos + (i * MDNode.SIZE), SeekOrigin.Begin);
                _nodes[i] = new MDNode(this, reader);
            }

            for (int i = 0; i < _numNodes; i++)
            {
                _nodes[i].ReadMeshes(this, reader);
            }
        }
Beispiel #5
0
        // Private Methods
        private void Read(BinaryReader reader)
        {
            offset = (int)reader.BaseStream.Position - HEADER_SIZE; 
            _unused = reader.ReadUInt32();
            _addressRelocTableOffset = reader.ReadInt32();
            _addressRelocTableSize = reader.ReadInt32();
            _unk1 = reader.ReadUInt32();
            _unk2 = reader.ReadUInt32();
            _nodeArrayOffset = reader.ReadUInt32();
            _materialArrayOffset = reader.ReadUInt32();
            _unk3 = reader.ReadUInt32();
            _nodeNameSectionOffset = reader.ReadUInt32();

            reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _nodeArrayOffset, SeekOrigin.Begin);
            _numNodes = reader.ReadUInt32();
            reader.AlignPosition(16);
            long nodeArrayPos = reader.BaseStream.Position;

            reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _materialArrayOffset, SeekOrigin.Begin);
            _numMaterials = reader.ReadUInt32();
            _materials = new MDMaterial[_numMaterials];
            for (int i = 0; i < _numMaterials; i++)
            {
                _materials[i] = new MDMaterial(reader);
            }

            if (_nodeNameSectionOffset != 0)
            {
                reader.BaseStream.Seek(offset + DATA_START_ADDRESS + _nodeNameSectionOffset, SeekOrigin.Begin);
                _nodeNameSection = new NDNM(_numNodes, reader);
            }

            _nodes = new MDNode[_numNodes];
            for (int i = 0; i < _numNodes; i++)
            {
                reader.BaseStream.Seek(nodeArrayPos + (i * MDNode.SIZE), SeekOrigin.Begin);
                _nodes[i] = new MDNode(this, reader);
            }

            for (int i = 0; i < _numNodes; i++)
            {
                _nodes[i].ReadMeshes(this, reader);
            }
        }
Beispiel #6
0
 // Constructors
 internal MDMesh(MDChunk model, MDNode node, BinaryReader reader)
 {
     Read(model, node, reader);
 }
Beispiel #7
0
 // Constructors
 internal MDMesh(MDChunk model, MDNode node, BinaryReader reader)
 {
     Read(model, node, reader);
 }
Beispiel #8
0
 // Constructors
 internal MDSubMeshType2(MDChunk model, MDNode node, IntPtr ptr, BinaryReader reader)
 {
     _node = node;
     InternalRead(model, reader);
     _material = model.Materials[_materialID];
 }
Beispiel #9
0
 // Constructors
 internal MDSubMeshType2(MDChunk model, MDNode node, IntPtr ptr, BinaryReader reader)
 {
     _node = node;
     InternalRead(model, reader);
     _material = model.Materials[_materialID];
 }