/// <summary> /// Method to setup the rendering device. /// Also initalizes all other variables used. /// </summary> /// <param name="panel">Panel to be used for rendering.</param> public ResourceManager(Panel panel) { setupDevice(panel); camera = new Camera(ref device); camera.SetCamera((float)panel.Width, (float)panel.Height); mesh = new List <Model>(); lights = new List <LightObj>(); // Add two blank meshes. One for the ground plane and one for the first model loaded. groundPlane = new GroundPlane(device, effect); mesh.Add(new Model(device, effect)); // Add the 3 lights. lights.Add(new LightObj(device, effect, true)); lights.Add(new LightObj(device, effect, false)); lights.Add(new LightObj(device, effect, false)); renderer = new Render(ref device, ref effect, ref mesh, ref groundPlane, panel.Width, panel.Height); }
private Render renderer; // Class to render the scene. #endregion Fields #region Constructors /// <summary> /// Method to setup the rendering device. /// Also initalizes all other variables used. /// </summary> /// <param name="panel">Panel to be used for rendering.</param> public ResourceManager(Panel panel) { setupDevice(panel); camera = new Camera(ref device); camera.SetCamera((float)panel.Width, (float)panel.Height); mesh = new List<Model>(); lights = new List<LightObj>(); // Add two blank meshes. One for the ground plane and one for the first model loaded. groundPlane = new GroundPlane(device, effect); mesh.Add(new Model(device, effect)); // Add the 3 lights. lights.Add(new LightObj(device, effect, true)); lights.Add(new LightObj(device, effect, false)); lights.Add(new LightObj(device, effect, false)); renderer = new Render(ref device, ref effect, ref mesh, ref groundPlane, panel.Width, panel.Height); }
/// <summary> /// Constructor to initalize references and build the render targets. /// </summary> /// <param name="device">Copy of the rendering device.</param> /// <param name="effect">Copy of the effect class.</param> /// <param name="mesh">Reference of the list of models.</param> /// <param name="width">Width of the rendering panel.</param> /// <param name="height">Height of the rendering panel.</param> public Render(ref Device device, ref Effect effect, ref List <Model> mesh, ref GroundPlane groundPlane, int width, int height) { this.device = device; this.effect = effect; this.mesh = mesh; this.groundPlane = groundPlane; this.width = width; this.height = height; showLights = false; shadowMapSize = 512; blackMat = new Material(); whiteMat = new Material(); blackMat.Ambient = blackMat.Diffuse = blackMat.Emissive = Color.Black; whiteMat.Ambient = whiteMat.Diffuse = whiteMat.Emissive = Color.White; // Setup the RenderToSurface class and create the render target textures. surfRender = new RenderToSurface(device, width, height, Format.X8R8G8B8, true, DepthFormat.D16); renderedGlow = new Texture(device, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); renderedScene = new Texture(device, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowHelp = new RenderToSurface(device, shadowMapSize, shadowMapSize, Format.X8R8G8B8, true, DepthFormat.D16); shadowMap = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowMap2 = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowMap3 = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); //lightTexture = TextureLoader.FromFile(device, "lightbulb.png"); MemoryStream loMS = new MemoryStream(); global::ModelViewer.Properties.Resources.lightbulb.Save(loMS, System.Drawing.Imaging.ImageFormat.Png); loMS.Seek(0, 0); lightTexture = TextureLoader.FromStream(device, loMS); }
private int width; // Width of the screen. #endregion Fields #region Constructors /// <summary> /// Constructor to initalize references and build the render targets. /// </summary> /// <param name="device">Copy of the rendering device.</param> /// <param name="effect">Copy of the effect class.</param> /// <param name="mesh">Reference of the list of models.</param> /// <param name="width">Width of the rendering panel.</param> /// <param name="height">Height of the rendering panel.</param> public Render(ref Device device, ref Effect effect, ref List<Model> mesh, ref GroundPlane groundPlane, int width, int height) { this.device = device; this.effect = effect; this.mesh = mesh; this.groundPlane = groundPlane; this.width = width; this.height = height; showLights = false; shadowMapSize = 512; blackMat = new Material(); whiteMat = new Material(); blackMat.Ambient = blackMat.Diffuse = blackMat.Emissive = Color.Black; whiteMat.Ambient = whiteMat.Diffuse = whiteMat.Emissive = Color.White; // Setup the RenderToSurface class and create the render target textures. surfRender = new RenderToSurface(device, width, height, Format.X8R8G8B8, true, DepthFormat.D16); renderedGlow = new Texture(device, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); renderedScene = new Texture(device, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowHelp = new RenderToSurface(device, shadowMapSize, shadowMapSize, Format.X8R8G8B8, true, DepthFormat.D16); shadowMap = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowMap2 = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); shadowMap3 = new Texture(device, shadowMapSize, shadowMapSize, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); //lightTexture = TextureLoader.FromFile(device, "lightbulb.png"); MemoryStream loMS = new MemoryStream(); global::ModelViewer.Properties.Resources.lightbulb.Save(loMS, System.Drawing.Imaging.ImageFormat.Png); loMS.Seek(0, 0); lightTexture = TextureLoader.FromStream(device, loMS); }