/// <summary> /// Checks if the texture is valid, and replaces it if needed. /// </summary> public void CheckValid() { if (Internal_Texture == -1) { Texture temp = Engine.GetTexture(Name); Original_InternalID = temp.Original_InternalID; Internal_Texture = Original_InternalID; if (RemappedTo != null) { RemappedTo.CheckValid(); Internal_Texture = RemappedTo.Original_InternalID; } } }
/// <summary> /// Loads the skin for this model. /// </summary> /// <param name="texs">Texture engine.</param> public void LoadSkin(TextureEngine texs) { if (Skinned) { return; } Skinned = true; if (Engine.TheClient.Files.Exists("models/" + Name + ".skin")) { string[] data = Engine.TheClient.Files.ReadText("models/" + Name + ".skin").SplitFast('\n'); int c = 0; foreach (string datum in data) { if (datum.Length > 0) { string[] datums = datum.SplitFast('='); if (datums.Length == 2) { Texture tex = texs.GetTexture(datums[1]); bool success = false; string datic = datums[0].BeforeAndAfter(":::", out string typer); typer = typer.ToLowerFast(); for (int i = 0; i < Meshes.Count; i++) { if (Meshes[i].Name == datic) { if (typer == "specular") { Meshes[i].vbo.Tex_Specular = tex; } else if (typer == "reflectivity") { Meshes[i].vbo.Tex_Reflectivity = tex; } else if (typer == "normal") { Meshes[i].vbo.Tex_Normal = tex; } else if (typer == "") { Meshes[i].vbo.Tex = tex; } else { SysConsole.Output(OutputType.WARNING, "Unknown skin entry typer: '" + typer + "', expected reflectivity, specular, or simply no specification!"); } c++; success = true; } } if (!success) { SysConsole.Output(OutputType.WARNING, "Unknown skin entry " + datums[0]); StringBuilder all = new StringBuilder(Meshes.Count * 100); for (int i = 0; i < Meshes.Count; i++) { all.Append(Meshes[i].Name + ", "); } SysConsole.Output(OutputType.WARNING, "Available: " + all.ToString()); } } } } if (c == 0) { SysConsole.Output(OutputType.WARNING, "No entries in " + Name + ".skin"); } } else { SysConsole.Output(OutputType.WARNING, "Can't find models/" + Name + ".skin!"); } }