Beispiel #1
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);
        }
Beispiel #2
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);
            }
        }