Exemplo n.º 1
0
        public override void Write(NiHeader header, BinaryWriter writer)
        {
            List <int> blockReferences = header.GetBlockReferences();

            if (blockReferences.Count > 0)
            {
                if (this.controller != -1)
                {
                    this.controller = blockReferences[this.controller];
                }
            }
            base.Write(header, writer);
            if (header.GetVersion() <= 335544325U)
            {
                if (this.name != "")
                {
                    Utils.WriteSizedString(writer, this.name);
                }
                else if (this.nameIdx == -1)
                {
                    Utils.WriteSizedString(writer, "Scene Root");
                }
                else
                {
                    Utils.WriteSizedString(writer, header.GetString((uint)this.nameIdx));
                }
            }
            else
            {
                writer.Write(this.nameIdx);
            }
            writer.Write(this.extraData.Count);
            if (this.extraData.Count > 0)
            {
                for (int index = 0; index < this.extraData.Count; index++)
                {
                    if (blockReferences.Count > 0)
                    {
                        if (this.extraData[index] != -1)
                        {
                            this.extraData[index] = blockReferences[this.extraData[index]];
                        }
                    }
                    writer.Write(this.extraData[index]);
                }
            }
            writer.Write(controller);
        }
Exemplo n.º 2
0
 public override void Read(NiHeader header, BinaryReader reader)
 {
     this.shaderType = reader.ReadUInt32();
     base.Read(header, reader);
     this.shaderFlags1     = reader.ReadUInt32();
     this.shaderFlags2     = reader.ReadUInt32();
     this.uvOffset         = Utils.ReadUVCoord(reader);
     this.uvScale          = Utils.ReadUVCoord(reader);
     this.textureSet       = reader.ReadInt32();
     this.emissiveColor    = Utils.ReadColor3(reader);
     this.emissiveMultiple = reader.ReadSingle();
     if (header.GetVersion() == 335675399U && header.GetUserVersion2() == 130)
     {
         this.wetMaterialIdx = reader.ReadInt32();
         if (this.wetMaterialIdx != -1)
         {
             this.wetMaterialName = header.GetString((uint)this.wetMaterialIdx);
         }
     }
     this.textureClampMode   = reader.ReadUInt32();
     this.alpha              = reader.ReadSingle();
     this.refractionStrength = reader.ReadSingle();
     this.glossiness         = reader.ReadSingle();
     this.specularColor      = Utils.ReadColor3(reader);
     this.specularStrength   = reader.ReadSingle();
     if (header.GetVersion() == 335675399U && header.GetUserVersion2() == 130)
     {
         this.subsurfaceRolloff       = reader.ReadSingle();
         this.unkownFloat1            = reader.ReadSingle();
         this.backlightPower          = reader.ReadSingle();
         this.grayscaleToPaletteScale = reader.ReadSingle();
         this.fresnelPower            = reader.ReadSingle();
         this.wetnessSpecScale        = reader.ReadSingle();
         this.wetnessSpecPower        = reader.ReadSingle();
         this.wetnessMinVar           = reader.ReadSingle();
         this.wetnessEnvMapScale      = reader.ReadSingle();
         this.wetnessFresnelPower     = reader.ReadSingle();
         this.wetnessMetalness        = reader.ReadSingle();
     }
     else
     {
         this.lightingEffect1 = reader.ReadSingle();
         this.lightingEffect2 = reader.ReadSingle();
     }
     if ((int)this.shaderType == 1)
     {
         this.environmentMapScale = reader.ReadSingle();
         if (header.GetVersion() == 335675399U && header.GetUserVersion2() == 130)
         {
             this.unkownEnvMapInt = reader.ReadUInt16();
         }
     }
     else if ((int)this.shaderType == 5)
     {
         this.skinTintColor = Utils.ReadColor3(reader);
         if (header.GetVersion() == 335675399U && header.GetUserVersion2() == 130)
         {
             this.unkownSkinTintInt = reader.ReadUInt32();
         }
     }
     else if ((int)this.shaderType == 6)
     {
         this.hairTintColor = Utils.ReadColor3(reader);
     }
     else if ((int)this.shaderType == 7)
     {
         this.maxPasses = reader.ReadSingle();
         this.scale     = reader.ReadSingle();
     }
     else if ((int)this.shaderType == 11)
     {
         this.parallaxInnerLayerThickness    = reader.ReadSingle();
         this.parallaxRefractionScale        = reader.ReadSingle();
         this.parallaxInnerLayerTextureScale = Utils.ReadUVCoord(reader);
         this.parallaxEnvmapStrength         = reader.ReadSingle();
     }
     else if ((int)this.shaderType == 14)
     {
         this.sparkleParameters = Utils.ReadVector4(reader);
     }
     else
     {
         if ((int)this.shaderType != 16)
         {
             return;
         }
         this.eyeCubemapScale          = reader.ReadSingle();
         this.leftEyeReflectionCenter  = Utils.ReadVector3(reader);
         this.rightEyeReflectionCenter = Utils.ReadVector3(reader);
     }
 }