public EditorScene(Renderer renderer = null) { Renderer = renderer; #region create background Model background = Game.ModelFactory.CreatePlane(); background.Texture = Renderer?.GetTexture("grid.png"); background.SetColor(new Vector3(1, 1, 0.5f)); background.Transform.Position = new Vector3(0, 0, -5f); float size = 50; background.Transform.Scale = new Vector3(size, size, size); background.TransformUv.Size = size; Doodad back = new Doodad(); back.Models.Add(background); Doodads.Add(back); #endregion }
public virtual void OnLoad(EventArgs e) { _time.Start(); if (!IsHeadless) { Renderer = new Renderer(CanvasSize); // Load textures from file Renderer.Textures.Add("default.png", new TextureFile(Path.Combine(textureFolder, "default.png"))); Renderer.Textures.Add("grid.png", new TextureFile(Path.Combine(textureFolder, "grid.png"))); Renderer.Textures.Add("lineBlur.png", new TextureFile(Path.Combine(textureFolder, "lineBlur.png"))); //Create the default font System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection(); privateFonts.AddFontFile(Path.Combine(fontFolder, "times.ttf")); Default = new Font(privateFonts.Families[0], 14); FontRenderer = new FontRenderer(Default); // Load shaders from file Renderer.Shaders.Add("uber", new Shader( Path.Combine(shaderFolder, "vs_uber.glsl"), Path.Combine(shaderFolder, "fs_uber.glsl"), true)); SoundEnabled = false; if (SoundEnabled) { SoundSystem = new SoundSystem(); SoundSystem.Initialize(); SoundSystem.Start(); } } /*if (programArgs.Length == 1) { Serializer serializer = new Serializer(); Scene scene = serializer.Deserialize(programArgs[0]); scene.SetActiveCamera(new Camera2(scene, new Transform2(new Vector2(), 10), CanvasSize.Width / (float)CanvasSize.Height)); Renderer.AddLayer(scene); Portals.PortalCommon.UpdateWorldTransform(scene); if (programArgs[0].StartsWith(tempLevelPrefix)) { File.Delete(programArgs[0]); } }*/ }
public void Init(Renderer renderer, Size canvasSize) { _renderer = renderer; Camera2 camera = new Camera2( Scene, new Transform2(new Vector2(), 10), canvasSize.Width / (float)canvasSize.Height); Scene.SetActiveCamera(camera); _tankCamera = new TankCamera(camera, null, _controller); Entity entity2 = new Entity(Scene); entity2.AddModel(ModelFactory.CreatePlane(new Vector2(10, 10))); entity2.ModelList[0].SetTexture(_renderer?.Textures["default.png"]); PortalCommon.UpdateWorldTransform(Scene); _renderer?.AddLayer(Scene); }
protected override void Render() { Renderer.Render(rectangle); }