Пример #1
0
        // Private Methods
        private void Read(MDChunk model, BinaryReader reader)
        {
            _flag1       = reader.ReadUInt32();
            _flag2       = reader.ReadUInt32();
            _index       = reader.ReadInt32();
            _parentIndex = reader.ReadInt32();
            _rotation    = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _position = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _scale = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _meshBoundingBoxOffset      = reader.ReadUInt32();
            _meshOffset = reader.ReadUInt32();
            _unk1       = reader.ReadUInt32();
            _unk2       = reader.ReadUInt32();

            _localMatrix  = Matrix4.CreateRotationX(_rotation.X) * Matrix4.CreateRotationY(_rotation.Y) * Matrix4.CreateRotationZ(_rotation.Z);
            _localMatrix *= Matrix4.CreateScale(_scale);
            _localMatrix *= Matrix4.CreateTranslation(_position);
            _worldMatrix  = _localMatrix;

            if (_parentIndex != -1)
            {
                Parent        = model.Nodes[_parentIndex];
                _worldMatrix *= Parent.WorldMatrix;
            }

            if (model.NodeNameSection != null)
            {
                _name = Array.Find(model.NodeNameSection.Names, n => n.ID == _index).Name;
            }

            if (_meshBoundingBoxOffset != 0)
            {
                reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _meshBoundingBoxOffset, SeekOrigin.Begin);
                _bbox     = new MDBoundingBox();
                _bbox.Min = reader.ReadVector3();
                _bbox.Max = reader.ReadVector3();
            }
        }
Пример #2
0
        // Private Methods
        private void Read(MDChunk model, BinaryReader reader)
        {
            _flag1 = reader.ReadUInt32();
            _flag2 = reader.ReadUInt32();
            _index = reader.ReadInt32();
            _parentIndex = reader.ReadInt32();
            _rotation = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _position = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _scale = reader.ReadVector3();
            reader.BaseStream.Position += 4;
            _meshBoundingBoxOffset = reader.ReadUInt32();
            _meshOffset = reader.ReadUInt32();
            _unk1 = reader.ReadUInt32();
            _unk2 = reader.ReadUInt32();

            _localMatrix = Matrix4.CreateRotationX(_rotation.X) * Matrix4.CreateRotationY(_rotation.Y) * Matrix4.CreateRotationZ(_rotation.Z);
            _localMatrix *= Matrix4.CreateScale(_scale);
            _localMatrix *= Matrix4.CreateTranslation(_position);
            _worldMatrix = _localMatrix;

            if (_parentIndex != -1)
            {
                Parent = model.Nodes[_parentIndex];
                _worldMatrix *= Parent.WorldMatrix;
            }

            if (model.NodeNameSection != null)
            {
                _name = Array.Find(model.NodeNameSection.Names, n => n.ID == _index).Name;
            }

            if (_meshBoundingBoxOffset != 0)
            {
                reader.BaseStream.Seek((uint)model.offset + MDChunk.DATA_START_ADDRESS + _meshBoundingBoxOffset, SeekOrigin.Begin);
                _bbox = new MDBoundingBox();
                _bbox.Min = reader.ReadVector3();
                _bbox.Max = reader.ReadVector3();
            }
        }