/// <summary> /// Handle a texture palette, adds it to our collection. /// </summary> /// <returns></returns> private bool HandleTexturePalette() { TexturePalette t = new TexturePalette(); t.Parse(Header); TexturePalettes[t.Index] = t; return(true); }
/// <summary> /// Determines whether the specified <see cref="TexturePalette"/> is equal to the current <see cref="UFLT.Records.TexturePalette"/>. /// </summary> /// <param name='other'> /// The <see cref="TexturePalette"/> to compare with the current <see cref="UFLT.Records.TexturePalette"/>. /// </param> /// <returns> /// <c>true</c> if the specified <see cref="TexturePalette"/> is equal to the current /// <see cref="UFLT.Records.TexturePalette"/>; otherwise, <c>false</c>. /// </returns> public bool Equals(TexturePalette other) { // TODO: Filename could be relative for the current db, e.g if we are supporting multiple db using the same file. Need a way to check if this is so. Maybe convert to absolute addresses? if (!FileName.Equals(other.FileName)) { return(false); } return(true); }
/// <summary> /// Returns the submesh for this face based on material info. /// </summary> /// <param name='f'>The face to find a submesh for.</param> public KeyValuePair <IntermediateMaterial, List <int> > FindOrCreateSubMesh(Face f) { ExternalReference externalRef = null; if (Header.Parent != null) { externalRef = Header.Parent as ExternalReference; } // Fetch palettes MaterialPalette mp = null; if (f.MaterialIndex != -1) { if (externalRef != null) { externalRef.Header.MaterialPalettes.TryGetValue(f.MaterialIndex, out mp); } if (mp == null) { Header.MaterialPalettes.TryGetValue(f.MaterialIndex, out mp); } if (mp == null) { Log.WriteError("Could not find material palette: " + f.MaterialIndex); } } TexturePalette mainTex = null; if (f.TexturePattern != -1) { if (externalRef != null) { externalRef.Header.TexturePalettes.TryGetValue(f.TexturePattern, out mainTex); } if (mainTex == null) { Header.TexturePalettes.TryGetValue(f.TexturePattern, out mainTex); } if (mainTex == null) { Log.WriteError("Could not find texture pattern: " + f.TexturePattern); } } TexturePalette detailTex = null; if (f.DetailTexturePattern != -1) { if (externalRef != null) { externalRef.Header.TexturePalettes.TryGetValue(f.DetailTexturePattern, out detailTex); } if (mainTex == null) { Header.TexturePalettes.TryGetValue(f.DetailTexturePattern, out detailTex); } if (mainTex == null) { Log.WriteError("Could not find detail texture pattern: " + f.DetailTexturePattern); } } // Check locally foreach (KeyValuePair <IntermediateMaterial, List <int> > mesh in SubMeshes) { if (mesh.Key.Equals(mp, mainTex, detailTex, f.Transparency, f.LightMode)) { return(mesh); } } // Create a new submesh IntermediateMaterial im = Header.MaterialBank.FindOrCreateMaterial(f); KeyValuePair <IntermediateMaterial, List <int> > newMesh = new KeyValuePair <IntermediateMaterial, List <int> >(im, new List <int>()); SubMeshes.Add(newMesh); return(newMesh); }