/// <summary> /// Create the geometry and the VBO (vertex and index buffers) /// for light-geoemtry /// Call it once in the scene initialization /// </summary> private void CreateQuadBuffer() { this.deferredLightingVariables = new DeferredLightingVariables(this.renderHost.Effects); var vertices = new[] { new Vector4(-1.0f, -1.0f, 0.0f, 1.0f), new Vector4(+1.0f, -1.0f, 0.0f, 1.0f), new Vector4(+1.0f, +1.0f, 0.0f, 1.0f), new Vector4(-1.0f, +1.0f, 0.0f, 1.0f), }; int[] indices = { 0, 1, 2, 2, 3, 0 }; this.screenQuad = new LightGeometryData() { IndexBuffer = this.device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), indices), VertexBuffer = this.device.CreateBuffer(BindFlags.VertexBuffer, Vector4.SizeInBytes, vertices), IndexCount = indices.Length, }; }
/// <summary> /// Create the geometry and the VBO (vertex and index buffers) /// for light-geoemtry /// Call it once in the scene initialization /// </summary> private void CreateSphereBuffer() { this.deferredLightingVariables = new DeferredLightingVariables(this.renderHost.Effects); #if EXERCISE // TODO 2: // - generate a sphere mesh using the MeshBuilder() // - fill the screenSphere struct #else var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 1.0); MeshGeometry3D meshGeometry = b1.ToMeshGeometry3D(); var vertices = meshGeometry.Positions.Select(p => new Vector4(p, 1.0f)).ToArray(); int[] indices = meshGeometry.Indices; this.screenSphere = new LightGeometryData() { IndexBuffer = this.device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), indices), VertexBuffer = this.device.CreateBuffer(BindFlags.VertexBuffer, Vector4.SizeInBytes, vertices), IndexCount = meshGeometry.Indices.Length, }; #endif }