Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NiTexturingProperty"/> class.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="reader">The reader.</param>
 public NiTexturingProperty(NiFile file, BinaryReader reader) : base(file, reader)
 {
     if (base.Version <= eNifVersion.VER_10_0_1_2 || base.Version >= eNifVersion.VER_20_1_0_3)
     {
         this.Flags = reader.ReadUInt16();
     }
     if (base.Version <= eNifVersion.VER_20_0_0_5)
     {
         this.ApplyMode = reader.ReadUInt32();
     }
     this.TextureCount = reader.ReadUInt32();
     if (reader.ReadBoolean(Version))
     {
         this.BaseTexture = new TexDesc(file, reader);
     }
     if (reader.ReadBoolean(Version))
     {
         this.DarkTexture = new TexDesc(file, reader);
     }
     if (reader.ReadBoolean(Version))
     {
         this.DetailTexture = new TexDesc(file, reader);
     }
     if (reader.ReadBoolean(Version))
     {
         this.GlossTexture = new TexDesc(file, reader);
     }
     if (reader.ReadBoolean(Version))
     {
         this.GlowTexture = new TexDesc(file, reader);
     }
     if (reader.ReadBoolean(Version))
     {
         this.BumpMapTexture    = new TexDesc(file, reader);
         this.BumpMapLumaScale  = reader.ReadSingle();
         this.BumpMapLumaOffset = reader.ReadSingle();
         this.BumpMapMatrix     = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
         reader.ReadSingle();
     }
     if (reader.ReadBoolean(Version))
     {
         this.Decal0Texture = new TexDesc(file, reader);
     }
     if (base.Version >= eNifVersion.VER_10_0_1_0)
     {
         this.NumShaderTextures = reader.ReadUInt32();
         int num = 0;
         while ((long)num < (long)((ulong)this.NumShaderTextures))
         {
             if (reader.ReadBoolean(Version))
             {
                 new TexDesc(file, reader);
                 reader.ReadUInt32();
             }
             num++;
         }
     }
 }
Exemplo n.º 2
0
        /*
         * Sets a new texture to the specified texture slot.  Overwrites any
         * texture that's already there.
         * \param[in] slot The type of texture slot to set a new texture for.
         * \param[in] tex_index The index of the texture to set the specified slot
         * to.  Must be an index from the same MatTexCollection that holds this
         * material wrapper.
         */
        public void SetTextureIndex(TexType slot, uint tex_index)
        {
            //Get the texture from the creator.  This will cause an exception if it fails.
            var tw = _creator.GetTexture(tex_index);

            if (texing_prop != null)
            {
                var td = new TexDesc();
                td.source = tw.src_tex;
                texing_prop.SetTexture((int)slot, td);
            }
            if (tex_prop != null && slot == TexType.BASE_MAP)
            {
                tex_prop.SetImage(tw.image);
            }
            //TODO:  Figure out which slots are what in NiMultiTextureProperty so this can be implemented for that too
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NiTexturingProperty"/> class.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="reader">The reader.</param>
        public NiTexturingProperty(NiFile file, BinaryReader reader) : base(file, reader)
		{
			if (base.Version <= eNifVersion.VER_10_0_1_2 || base.Version >= eNifVersion.VER_20_1_0_3)
			{
				this.Flags = reader.ReadUInt16();
			}
			if (base.Version <= eNifVersion.VER_20_0_0_5)
			{
				this.ApplyMode = reader.ReadUInt32();
			}
			this.TextureCount = reader.ReadUInt32();
			if (reader.ReadBoolean(Version))
			{
				this.BaseTexture = new TexDesc(file, reader);
			}
			if (reader.ReadBoolean(Version))
			{
				this.DarkTexture = new TexDesc(file, reader);
			}
			if (reader.ReadBoolean(Version))
			{
				this.DetailTexture = new TexDesc(file, reader);
			}
			if (reader.ReadBoolean(Version))
			{
				this.GlossTexture = new TexDesc(file, reader);
			}
			if (reader.ReadBoolean(Version))
			{
				this.GlowTexture = new TexDesc(file, reader);
			}
			if (reader.ReadBoolean(Version))
			{
				this.BumpMapTexture = new TexDesc(file, reader);
				this.BumpMapLumaScale = reader.ReadSingle();
				this.BumpMapLumaOffset = reader.ReadSingle();
				this.BumpMapMatrix = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
				reader.ReadSingle();
			}
			if (reader.ReadBoolean(Version))
			{
				this.Decal0Texture = new TexDesc(file, reader);
			}
			if (base.Version >= eNifVersion.VER_10_0_1_0)
			{
				this.NumShaderTextures = reader.ReadUInt32();
				int num = 0;
				while ((long)num < (long)((ulong)this.NumShaderTextures))
				{
					if (reader.ReadBoolean(Version))
					{
						new TexDesc(file, reader);
						reader.ReadUInt32();
					}
					num++;
				}
			}
		}