示例#1
0
        public NiSourceTexture(BinaryReader reader, NiFile file) : base(reader, file)
        {
            UseExternal = reader.ReadByte();

            switch (UseExternal)
            {
            case 1:
                FilePath    = file.Header.Strings[reader.ReadUInt32()];
                UnknownLink = new NiRef <NiObject>(file, reader.ReadInt32());
                break;

            case 0:
                OriginalFilePath = file.Header.Strings[reader.ReadUInt32()];
                PixelData        = new NiRef <NiPixelFormat>(file, reader.ReadInt32());
                break;

            default:
                throw new ArgumentOutOfRangeException($"{UseExternal} is not a vaild source texture option.");
            }

            FormatPrefs = new NiFormatPrefs(reader, file);

            IsStatic = reader.ReadByte();

            PersistRenderData = new NiBoolean(reader);
        }
示例#2
0
        public NiTriShapeData(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            TrianglePointCount = reader.ReadUInt32();

            HasTriangles = new NiBoolean(reader.ReadByte() != 0);

            if (HasTriangles)
            {
                Triangles = new NiTriangle[TriangleCount];
                for (var i = 0; i < TriangleCount; i++)
                {
                    Triangles[i] = new NiTriangle(reader, niFile);
                }
            }

            MatchGroupCount = reader.ReadUInt16();

            MatchGroups = new NiMatchGroup[MatchGroupCount];

            for (var i = 0; i < MatchGroupCount; i++)
            {
                try
                {
                    MatchGroups[i] = new NiMatchGroup(reader, niFile);
                }
                catch
                {
                    return;
                }
            }
        }
示例#3
0
        public NiCamera(BinaryReader reader, NiFile file) : base(reader, file)
        {
            CameraFlags = reader.ReadUInt16();

            FrustumLeft = reader.ReadSingle();

            FrustumRight = reader.ReadSingle();

            FrustumTop = reader.ReadSingle();

            FrustumBottom = reader.ReadSingle();

            FrustumNear = reader.ReadSingle();

            FrustumFar = reader.ReadSingle();

            UseOrthographicProjection = new NiBoolean(reader);

            ViewportLeft = reader.ReadSingle();

            ViewportRight = reader.ReadSingle();

            ViewportTop = reader.ReadSingle();

            ViewportBottom = reader.ReadSingle();

            LODAdjust = reader.ReadSingle();

            Scene = new NiRef <NiAVObject>(file, reader.ReadInt32());

            ScreenPolygonsCount = reader.ReadUInt32();

            ScreenTexturesCount = reader.ReadUInt32();
        }
示例#4
0
        public NiTextureTransformController(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            ShaderMap = new NiBoolean(reader);

            TextureSlot = (TexType)reader.ReadUInt32();

            Operation = (TransformMember)reader.ReadUInt32();
        }
        public PixelFormatComponent(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            Type = (PixelComponent)reader.ReadUInt32();

            Convention = (PixelRepresentation)reader.ReadUInt32();

            BitsPerChannel = reader.ReadByte();

            IsSigned = new NiBoolean(reader);
        }
示例#6
0
        public NiShaderTexDesc(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            HasMap = new NiBoolean(reader);

            if (!HasMap)
            {
                return;
            }
            Map   = new NiTexDesc(reader, niFile);
            MapId = reader.ReadUInt32();
        }
示例#7
0
        public NiDynamicEffect(BinaryReader reader, NiFile file) : base(reader, file)
        {
            SwitchState = new NiBoolean(reader);

            AffectedNodesCount = reader.ReadUInt32();

            AffectedNodes = new NiPtr <NiNode> [AffectedNodesCount];

            for (var i = 0; i < AffectedNodesCount; i++)
            {
                AffectedNodes[i] = new NiPtr <NiNode>(file, reader.ReadInt32());
            }
        }
示例#8
0
        public NiTexDesc(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            Source = new NiRef <NiSourceTexture>(niFile, reader.ReadInt32());

            Flags = reader.ReadInt16();

            HasTextureTransform = new NiBoolean(reader);

            if (!HasTextureTransform)
            {
                return;
            }

            Translation = new NiTexCoord(reader, niFile);

            Scale = new NiTexCoord(reader, niFile);

            Rotation = reader.ReadSingle();

            Method = (TransformMethod)reader.ReadUInt32();

            Center = new NiTexCoord(reader, niFile);
        }
示例#9
0
        public NiTriStripsData(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            StripsCount = reader.ReadUInt16();

            StripsLengths = reader.ReadUInt16();

            HasPoints = new NiBoolean(reader);

            if (!HasPoints)
            {
                return;
            }
            Points = new ushort[StripsCount][];

            for (var i = 0; i < StripsCount; i++)
            {
                Points[i] = new ushort[StripsLengths];
                for (var j = 0; j < StripsLengths; j++)
                {
                    Points[i][j] = reader.ReadUInt16();
                }
            }
        }
示例#10
0
        public NiPixelFormat(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            PixelFormat = (PixelFormat)reader.ReadUInt32();

            BitsPerPixel = reader.ReadByte();

            RendererHint = reader.ReadUInt32();

            ExtraData = reader.ReadUInt32();

            Flags = reader.ReadByte();

            Tiling = (PixelTiling)reader.ReadUInt32();

            SRGBSpace = new NiBoolean(reader);

            Channels = new PixelFormatComponent[4];

            for (var i = 0; i < 4; i++)
            {
                Channels[i] = new PixelFormatComponent(reader, niFile);
            }
        }
示例#11
0
        public SkinPartition(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            VerticesCount = reader.ReadUInt16();

            TrianglesCount = reader.ReadUInt16();

            BonesCount = reader.ReadUInt16();

            StripsCount = reader.ReadUInt16();

            WeightsPerVertex = reader.ReadUInt16();

            Bones = new ushort[BonesCount];
            for (var i = 0; i < BonesCount; i++)
            {
                Bones[i] = reader.ReadUInt16();
            }

            HasVertexMap = new NiBoolean(reader);

            if (HasVertexMap)
            {
                VertexMap = new ushort[VerticesCount];

                for (var i = 0; i < VerticesCount; i++)
                {
                    VertexMap[i] = reader.ReadUInt16();
                }
            }

            HasVertexWeights = new NiBoolean(reader);

            if (HasVertexWeights)
            {
                VertexWeights = new float[VerticesCount, WeightsPerVertex];

                for (var i = 0; i < VerticesCount; i++)
                {
                    for (var j = 0; j < WeightsPerVertex; j++)
                    {
                        VertexWeights[i, j] = reader.ReadSingle();
                    }
                }
            }

            StripsLengths = new ushort[StripsCount];
            for (var i = 0; i < StripsCount; i++)
            {
                StripsLengths[i] = reader.ReadUInt16();
            }

            HasFaces = new NiBoolean(reader);

            if (HasFaces && StripsCount != 0)
            {
                Strips = new ushort[StripsCount, StripsLengths.Length];

                for (var i = 0; i < StripsCount; i++)
                {
                    for (var j = 0; j < StripsLengths.Length; j++)
                    {
                        Strips[i, j] = reader.ReadUInt16();
                    }
                }
            }

            if (HasFaces && StripsCount == 0)
            {
                Triangles = new NiTriangle[TrianglesCount];

                for (var i = 0; i < TrianglesCount; i++)
                {
                    Triangles[i] = new NiTriangle(reader, niFile);
                }
            }

            HasBoneIndices = new NiBoolean(reader);

            if (!HasBoneIndices)
            {
                return;
            }
            {
                BoneIndices = new byte[VerticesCount, WeightsPerVertex];

                for (var i = 0; i < VerticesCount; i++)
                {
                    for (var j = 0; j < WeightsPerVertex; j++)
                    {
                        BoneIndices[i, j] = reader.ReadByte();
                    }
                }
            }
        }
        public NiBoolInterpolator(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            Value = new NiBoolean(reader);

            Data = new NiRef <NiBoolData>(niFile, reader.ReadInt32());
        }
示例#13
0
        public NiTexturingProperty(BinaryReader reader, NiFile file) : base(reader, file)
        {
            Flags = reader.ReadInt16();

            TextureCount = reader.ReadUInt32();

            HasBaseTexture = new NiBoolean(reader);

            if (HasBaseTexture)
            {
                BaseTexture = new NiTexDesc(reader, file);
            }

            HasDarkTexture = new NiBoolean(reader);

            if (HasDarkTexture)
            {
                DarkTexture = new NiTexDesc(reader, file);
            }

            HasDetailTexture = new NiBoolean(reader);

            if (HasDetailTexture)
            {
                DetailTexture = new NiTexDesc(reader, file);
            }

            HasGlossTexture = new NiBoolean(reader);

            if (HasGlossTexture)
            {
                GlossTexture = new NiTexDesc(reader, file);
            }

            HasGlowTexture = new NiBoolean(reader);

            if (HasGlowTexture)
            {
                GlowTexture = new NiTexDesc(reader, file);
            }

            if (TextureCount > 5)
            {
                HasBumpMapTexture = new NiBoolean(reader);
                if (!HasBumpMapTexture)
                {
                    goto Normal;
                }

                BumpMapTexture    = new NiTexDesc(reader, file);
                BumpMapLumaScale  = reader.ReadSingle();
                BumpMapLumaOffset = reader.ReadSingle();
                BumpMapMatrix     = new NiMatrix2X2(reader, file);
            }

Normal:
            if (TextureCount > 6)
            {
                HasNormalTexture = new NiBoolean(reader);
                if (!HasNormalTexture)
                {
                    goto Parallax;
                }

                NormalTexture = new NiTexDesc(reader, file);
            }

Parallax:
            if (TextureCount > 7)
            {
                HasParallaxTexture = new NiBoolean(reader);
                if (!HasParallaxTexture)
                {
                    goto Shader;
                }

                ParallaxTexture = new NiTexDesc(reader, file);
                ParallaxOffset  = reader.ReadSingle();
            }

Shader:
            ShaderTexturesCount = reader.ReadUInt32();

            for (var i = 0; i < ShaderTexturesCount; i++)
            {
                ShaderTextures[i] = new NiShaderTexDesc(reader, file);
            }
        }
示例#14
0
        public NiGeometryData(BinaryReader reader, NiFile niFile) : base(reader, niFile)
        {
            if ((int)niFile.Header.NifVersion >= 0x0A020000)
            {
                GroupId = reader.ReadInt32();
            }

            VerticesCount = reader.ReadUInt16();

            if ((int)niFile.Header.NifVersion >= 0x0A010000)
            {
                KeepFlags     = reader.ReadByte();
                CompressFlags = reader.ReadByte();
            }

            HasVertices = new NiBoolean(reader);
            if (HasVertices)
            {
                Vertices = new NiVector3[VerticesCount];
                for (uint i = 0; i < VerticesCount; i++)
                {
                    Vertices[i] = new NiVector3(reader, niFile);
                }
            }

            if ((int)niFile.Header.NifVersion >= 0x0A000100 &&
                !((int)niFile.Header.NifVersion >= 0x14020007 && niFile.Header.UserVersion >= 11))
            {
                NumUvSets = reader.ReadUInt16();
            }

            HasNormals = new NiBoolean(reader);
            if (HasNormals)
            {
                Normals = new NiVector3[VerticesCount];
                for (uint i = 0; i < VerticesCount; i++)
                {
                    Normals[i] = new NiVector3(reader, niFile);
                }
            }

            if ((int)niFile.Header.NifVersion >= 0x0A010000)
            {
                if (HasNormals && (NumUvSets & 61440) != 0)
                {
                    Tangents = new NiVector3[VerticesCount];
                    for (uint i = 0; i < VerticesCount; i++)
                    {
                        Tangents[i] = new NiVector3(reader, niFile);
                    }

                    BitTangents = new NiVector3[VerticesCount];
                    for (uint i = 0; i < VerticesCount; i++)
                    {
                        BitTangents[i] = new NiVector3(reader, niFile);
                    }
                }
            }

            Center = new NiVector3(reader, niFile);
            Radius = reader.ReadSingle();

            HasVertexColors = new NiBoolean(reader);
            if (HasVertexColors)
            {
                VertexColors = new NiColor4[VerticesCount];
                for (uint i = 0; i < VerticesCount; i++)
                {
                    VertexColors[i] = new NiColor4(reader, niFile);
                }
            }

            if ((int)niFile.Header.NifVersion <= 0x04020200)
            {
                NumUvSets = reader.ReadUInt16();
            }

            if ((int)niFile.Header.NifVersion <= 0x04000002)
            {
                HasUv = new NiBoolean(reader);
            }

            Uv = new NiTexCoord[(NumUvSets & 63) | (0 & 1)][];
            for (uint i = 0; i < Uv.Length; i++)
            {
                Uv[i] = new NiTexCoord[VerticesCount];
                for (uint j = 0; j < VerticesCount; j++)
                {
                    Uv[i][j] = new NiTexCoord(reader, niFile);
                }
            }

            if ((int)niFile.Header.NifVersion >= 0x0A000100 && niFile.Header.UserVersion < 12)
            {
                Consistency = (ConsistencyType)reader.ReadUInt16();
            }

            if ((int)niFile.Header.NifVersion >= 0x14000004 && niFile.Header.UserVersion < 12)
            {
                var blockNum = reader.ReadUInt32();
                AdditionData = new NiRef <AbstractAdditionalGeometryData>(niFile, (int)blockNum);
            }
        }