/// <summary>
        /// Handles external reference records.
        /// </summary>
        /// <returns></returns>
        protected bool HandleExternalReference()
        {
            ExternalReference e = new ExternalReference(this);

            e.Parse();
            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);
        }