Exemple #1
0
        public NiObjectNET(NiFile file, BinaryReader reader)
            : base(file, reader)
        {
            Name = new NiString(file, reader);

            if (File.Header.Version <= eNifVersion.VER_2_3)
            {
                throw new Exception("Unsupported Version!");
            }

            if (File.Header.Version >= eNifVersion.VER_3_0 && File.Header.Version <= eNifVersion.VER_4_2_2_0)
            {
                ExtraData    = new NiRef <NiExtraData> [1];
                ExtraData[0] = new NiRef <NiExtraData>(reader.ReadUInt32());
            }

            if (File.Header.Version >= eNifVersion.VER_10_0_1_0)
            {
                var numExtraData = reader.ReadUInt32();
                ExtraData = new NiRef <NiExtraData> [numExtraData];
                for (var i = 0; i < numExtraData; i++)
                {
                    ExtraData[i] = new NiRef <NiExtraData>(reader.ReadUInt32());
                }
            }

            if (File.Header.Version >= eNifVersion.VER_3_0)
            {
                Controller = new NiRef <NiTimeController>(reader.ReadUInt32());
            }
        }
Exemple #2
0
        public Morph(NiFile file, BinaryReader reader, uint numVertices)
        {
            if (file.Version >= eNifVersion.VER_10_1_0_106)
            {
                FrameName = new NiString(file, reader);
            }

            if (file.Version <= eNifVersion.VER_10_1_0_0)
            {
                Keys = new KeyGroup <FloatKey>(reader);
            }

            if (file.Version >= eNifVersion.VER_10_1_0_106 &&
                file.Version <= eNifVersion.VER_10_2_0_0)
            {
                UnkownInt = reader.ReadUInt32();
            }

            if (file.Version >= eNifVersion.VER_20_0_0_4 &&
                file.Version <= eNifVersion.VER_20_1_0_3)
            {
                UnkownInt = reader.ReadUInt32();
            }

            Vectors = new Vector3[numVertices];
            for (var i = 0; i < numVertices; i++)
            {
                Vectors[i] = reader.ReadVector3();
            }
        }
Exemple #3
0
 public NiStringsExtraData(NiFile file, BinaryReader reader)
     : base(file, reader)
 {
     ExtraStringData = new NiString[(int)reader.ReadUInt32()];
     for (var i = 0; i < ExtraStringData.Length; i++)
     {
         ExtraStringData[i] = new NiString(file, reader);
     }
 }
Exemple #4
0
        public NiStringExtraData(NiFile file, BinaryReader reader)
            : base(file, reader)
        {
            if (Version <= eNifVersion.VER_4_2_2_0)
            {
                BytesRemaining = reader.ReadUInt32();
            }

            StringData = new NiString(file, reader);
        }
Exemple #5
0
        public StringKey(BinaryReader reader, eKeyType type)
        {
            Time = reader.ReadSingle();

            if (type != eKeyType.LINEAR_KEY)
            {
                throw new Exception("Invalid eKeyType");
            }

            Value = new NiString(null, reader);
        }
Exemple #6
0
 public NiExtraData(NiFile file, BinaryReader reader)
     : base(file, reader)
 {
     if (File.Header.Version >= eNifVersion.VER_10_0_1_0)
     {
         Name = new NiString(file, reader);
     }
     if (File.Header.Version <= eNifVersion.VER_4_2_2_0)
     {
         NextExtraData = new NiRef <NiExtraData>(reader.ReadUInt32());
     }
 }
Exemple #7
0
        public NiSourceTexture(NiFile file, BinaryReader reader)
            : base(file, reader)
        {
            IsStatic = true;

            UseExternal = reader.ReadBoolean();

            if (UseExternal)
            {
                FileName = new NiString(file, reader);

                if (Version >= eNifVersion.VER_10_1_0_0)
                {
                    reader.ReadUInt32();
                }
            }

            if (!UseExternal)
            {
                if (Version <= eNifVersion.VER_10_0_1_0)
                {
                    reader.ReadByte();
                }

                if (Version >= eNifVersion.VER_10_1_0_0)
                {
                    FileName = new NiString(file, reader);
                }

                InternalTexture = new NiRef <ATextureRenderData>(reader);
            }

            PixelLayout = (ePixelLayout)reader.ReadUInt32();
            UseMipmaps  = (eMipMapFormat)reader.ReadUInt32();
            AlphaFormat = (eAlphaFormat)reader.ReadUInt32();
            IsStatic    = reader.ReadBoolean();

            if (Version >= eNifVersion.VER_10_1_0_106)
            {
                DirectRender = reader.ReadBoolean();
            }

            if (Version >= eNifVersion.VER_20_2_0_7)
            {
                PersistentRenderData = reader.ReadBoolean();
            }
        }
Exemple #8
0
        public NiGeometry(NiFile file, BinaryReader reader)
            : base(file, reader)
        {
            Data = new NiRef <NiGeometryData>(reader);

            if (Version >= eNifVersion.VER_3_3_0_13)
            {
                SkinInstance = new NiRef <NiSkinInstance>(reader);
            }

            if (Version >= eNifVersion.VER_20_2_0_7)
            {
                MaterialNames = new NiString[reader.ReadUInt32()];
                for (var i = 0; i < MaterialNames.Length; i++)
                {
                    MaterialNames[i] = new NiString(file, reader);
                }
                MaterialExtraData = new int[MaterialNames.Length];
                for (var i = 0; i < MaterialNames.Length; i++)
                {
                    MaterialExtraData[i] = reader.ReadInt32();
                }

                ActiveMaterial = reader.ReadInt32();
            }

            if (Version >= eNifVersion.VER_10_0_1_0 &&
                Version <= eNifVersion.VER_20_1_0_3)
            {
                HasShader = reader.ReadBoolean();
                if (HasShader)
                {
                    ShaderName    = new string(reader.ReadChars(reader.ReadInt32()));
                    UnkownInteger = reader.ReadUInt32();
                }
            }

            if (Version == eNifVersion.VER_10_4_0_1)
            {
                reader.ReadUInt32(); //unkown
            }
            if (Version >= eNifVersion.VER_20_2_0_7)
            {
                throw new Exception("unspported data");
            }
        }
Exemple #9
0
        public NiHeader(NiFile file, BinaryReader reader)
        {
            var strLen = 0;

            var startOffset = reader.BaseStream.Position;

            while (reader.ReadByte() != 0x0A)
            {
                strLen++;
            }

            reader.BaseStream.Position = startOffset;

            VersionString = new string(reader.ReadChars(strLen));
            reader.ReadByte(); //skip 0x0A
            var ver = reader.ReadUInt32();

            Version = (eNifVersion)ver;
            if (Version >= eNifVersion.VER_20_0_0_4)
            {
                throw new Exception("NIF Version not supported yet!");
            }
            if (Version >= eNifVersion.VER_10_1_0_0)
            {
                UserVersion = reader.ReadUInt32();
            }
            if (Version >= eNifVersion.VER_3_3_0_13)
            {
                NumBlocks = reader.ReadUInt32();
            }

            if (Version >= eNifVersion.VER_10_1_0_0 && (UserVersion == 10 || UserVersion == 11))
            {
                UserVersion2 = reader.ReadUInt32();
            }

            if (Version == eNifVersion.VER_20_0_0_5)
            {
                throw new VersionNotFoundException("Version 20.0.0.5 not supported!");
            }

            if (Version == eNifVersion.VER_10_0_1_2)
            {
                throw new Exception("NIF Version not supported yet!");
            }

            if (Version >= eNifVersion.VER_10_1_0_0 && (UserVersion == 10 || UserVersion == 11))
            {
                throw new Exception("NIF Version not supported yet!");
            }

            if (Version >= eNifVersion.VER_10_0_1_0)
            {
                var numBlockTypes = reader.ReadUInt16();
                BlockTypes = new NiString[numBlockTypes];
                for (var i = 0; i < numBlockTypes; i++)
                {
                    BlockTypes[i] = new NiString(file, reader);
                }
                BlockTypeIndex = new ushort[NumBlocks];
                for (var i = 0; i < NumBlocks; i++)
                {
                    BlockTypeIndex[i] = reader.ReadUInt16();
                }
            }

            if (Version >= eNifVersion.VER_20_2_0_7)
            {
                throw new Exception("NIF Version not supported yet!");
            }

            if (Version >= eNifVersion.VER_20_1_0_3)
            {
                throw new Exception("NIF Version not supported yet!");
            }

            if (Version >= eNifVersion.VER_10_0_1_0)
            {
                UnkownInt = reader.ReadUInt32();
            }
        }