private bool Render() { // Clear the buffer to begin the scene. D3D.BeginScene(0f, 0f, 0f, 1f); // Generate the view matrix based on the camera position. Camera.Render(); // Get the world, view, and projection matrices from camera and d3d objects. Matrix viewMatrix = Camera.ViewMatrix; Matrix worldMatrix = D3D.WorldMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Turn on alpha blending. D3D.TurnOnAlphaBlending(); // Put the particle system vertex and index buffers on the graphics pipeline to prepare them for drawing. ParticleSystem.Render(D3D.DeviceContext); // Render the model using the texture shader. if (!ParticleShader.Render(D3D.DeviceContext, ParticleSystem.IndexCount, worldMatrix, viewMatrix, projectionMatrix, ParticleSystem.Texture.TextureResource)) { return(false); } // Turn off alpha blending. D3D.TurnOffAlphaBlending(); // Present the rendered scene to the screen. D3D.EndScene(); return(true); }
//--------------------// #region Engine protected override void OnEngineSet() { base.OnEngineSet(); // Load particle mesh using (var stream = ContentManager.GetFileStream("Meshes", "Engine/Particles.x")) _particleMesh = Mesh.FromStream(Engine.Device, stream, MeshFlags.Managed); // Load particle shader string id = Path.Combine("Shaders", Preset.ParticleTexture); _particleShader = new ParticleShader(XTexture.Get(Engine, id)); }
public void ShutDown() { // Release the camera object. Camera = null; // Release the particle system object. ParticleSystem?.ShutDown(); ParticleSystem = null; // Release the particle shader object. ParticleShader?.ShutDown(); ParticleShader = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }