public Bitmap GetCombo(MaterialTextureInfo tex, int coord) { string refract = (tex.RefractTextures != null && tex.RefractTextures.Length > coord) ? tex.RefractTextures[coord] : "black"; Texture trefr = TEngine.GetTexture(refract, TWidth); Bitmap bmprefr = trefr.SaveToBMP(); string reflect = (tex.ReflectTextures != null && tex.ReflectTextures.Length > coord) ? tex.ReflectTextures[coord] : "black"; Texture trefl = TEngine.GetTexture(reflect, TWidth); Bitmap bmprefl = trefl.SaveToBMP(); string specular = (tex.SpecularTextures != null && tex.SpecularTextures.Length > coord) ? tex.SpecularTextures[coord] : "black"; Texture tspec = TEngine.GetTexture(specular, TWidth); Bitmap bmpspec = tspec.SaveToBMP(); string glowing = (tex.GlowingTextures != null && tex.GlowingTextures.Length > coord) ? tex.GlowingTextures[coord] : "black"; Texture tglow = TEngine.GetTexture(glowing, TWidth); Bitmap bmpglow = tglow.SaveToBMP(); Bitmap combo = Combine(bmpspec, bmprefl, bmprefr, bmpglow); bmprefr.Dispose(); bmprefl.Dispose(); bmpspec.Dispose(); bmpglow.Dispose(); return(combo); }
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; } } }
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'); 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 typer; string datic = datums[0].BeforeAndAfter(":::", out 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!"); } 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()); } } } } } else { SysConsole.Output(OutputType.WARNING, "Can't find models/" + Name + ".skin!"); } }
/// <summary> /// Called when the window is loading, only to be used by the startup process. /// </summary> void Window_Load(object sender, EventArgs e) { SysConsole.Output(OutputType.INIT, "Window generated!"); DPIScale = Window.Width / CVars.r_width.ValueF; SysConsole.Output(OutputType.INIT, "DPIScale is " + DPIScale + "!"); SysConsole.Output(OutputType.INIT, "Loading base textures..."); PreInitRendering(); Textures = new TextureEngine(); Textures.InitTextureSystem(this); ItemFrame = Textures.GetTexture("ui/hud/item_frame"); SysConsole.Output(OutputType.INIT, "Loading shaders..."); Shaders = new ShaderEngine(); GLVendor = GL.GetString(StringName.Vendor); CVars.s_glvendor.Value = GLVendor; GLVersion = GL.GetString(StringName.Version); CVars.s_glversion.Value = GLVersion; GLRenderer = GL.GetString(StringName.Renderer); CVars.s_glrenderer.Value = GLRenderer; SysConsole.Output(OutputType.INIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer); if (GLVendor.ToLowerFast().Contains("intel")) { SysConsole.Output(OutputType.INIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')"); Shaders.MCM_GOOD_GRAPHICS = false; } Shaders.InitShaderSystem(this); View3D.CheckError("Load - Shaders"); SysConsole.Output(OutputType.INIT, "Loading rendering helper..."); Rendering = new Renderer(Textures, Shaders); Rendering.Init(); SysConsole.Output(OutputType.INIT, "Preparing load screen..."); Texture load_screen = Textures.GetTexture("ui/menus/loadscreen"); load_screen.Bind(); Shaders.ColorMultShader.Bind(); Establish2D(); Rendering.RenderRectangle(0, 0, Window.Width, Window.Height); Window.SwapBuffers(); SysConsole.Output(OutputType.INIT, "Loading block textures..."); TBlock = new TextureBlock(); TBlock.Generate(this, CVars, Textures); View3D.CheckError("Load - Textures"); SysConsole.Output(OutputType.INIT, "Loading fonts..."); Fonts = new GLFontEngine(Shaders); Fonts.Init(this); FontSets = new FontSetEngine(Fonts); FontSets.Init(this); View3D.CheckError("Load - Fonts"); SysConsole.Output(OutputType.INIT, "Loading animation engine..."); Animations = new AnimationEngine(); SysConsole.Output(OutputType.INIT, "Loading model engine..."); Models = new ModelEngine(); Models.Init(Animations, this); SysConsole.Output(OutputType.INIT, "Loading general graphics settings..."); CVars.r_vsync.OnChanged += onVsyncChanged; onVsyncChanged(CVars.r_vsync, null); CVars.r_cloudshadows.OnChanged += onCloudShadowChanged; View3D.CheckError("Load - General Graphics"); SysConsole.Output(OutputType.INIT, "Loading UI engine..."); UIConsole.InitConsole(); // TODO: make this non-static InitChatSystem(); View3D.CheckError("Load - UI"); SysConsole.Output(OutputType.INIT, "Preparing rendering engine..."); InitRendering(); View3D.CheckError("Load - Rendering"); SysConsole.Output(OutputType.INIT, "Loading particle effect engine..."); Particles = new ParticleHelper(this) { Engine = new ParticleEngine(this) }; SysConsole.Output(OutputType.INIT, "Preparing mouse, keyboard, and gamepad handlers..."); KeyHandler.Init(); GamePadHandler.Init(); View3D.CheckError("Load - Keyboard/mouse"); SysConsole.Output(OutputType.INIT, "Building the sound system..."); Sounds = new SoundEngine(); Sounds.Init(this, CVars); View3D.CheckError("Load - Sound"); SysConsole.Output(OutputType.INIT, "Building game world..."); BuildWorld(); View3D.CheckError("Load - World"); SysConsole.Output(OutputType.INIT, "Preparing networking..."); Network = new NetworkBase(this); RegisterDefaultEntityTypes(); View3D.CheckError("Load - Net"); SysConsole.Output(OutputType.INIT, "Playing background music..."); BackgroundMusic(); CVars.a_musicvolume.OnChanged += onMusicVolumeChanged; CVars.a_musicpitch.OnChanged += onMusicPitchChanged; CVars.a_music.OnChanged += onMusicChanged; CVars.a_echovolume.OnChanged += OnEchoVolumeChanged; OnEchoVolumeChanged(null, null); SysConsole.Output(OutputType.INIT, "Setting up screens..."); TheMainMenuScreen = new MainMenuScreen(this); TheGameScreen = new GameScreen(this); TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this); SysConsole.Output(OutputType.INIT, "Preparing inventory..."); InitInventory(); SysConsole.Output(OutputType.INIT, "Showing main menu..."); ShowMainMenu(); SysConsole.Output(OutputType.INIT, "Trying to grab RawGamePad..."); try { RawGamePad = new XInput(); } catch (Exception ex) { SysConsole.Output(OutputType.INIT, "Failed to grab RawGamePad: " + ex.Message); } View3D.CheckError("Load - Final"); SysConsole.Output(OutputType.INIT, "Ready and looping!"); }
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'); 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 typer; string datic = datums[0].BeforeAndAfter(":::", out 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!"); } 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()); } } } } } else { SysConsole.Output(OutputType.WARNING, "Can't find models/" + Name + ".skin!"); } }