public void Render() { ET += 1.0f / 60.0f; RenderBase.SetWorld(Matrix.Identity); vertexShaderSway.Set(); RenderBase.DeviceContext.PixelShader.Set(plantPixelShader); paramsBuffer.Set(2); RenderBase.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; //Draw Fish RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Default; //Console.WriteLine("A"); var di = plantInstanceBuffer.Map(); for (int i = 0; i < plantData.Length; i++) { //Console.WriteLine("B"); ////////var ds = paramsBuffer.Map(); ////////ds.Write(new Vector4(0.0f, plantData[i].W, 0.0f, 1.0f)); ////////ds.Write(ET * plantWaveSpeed[i] + (i % 100) * (i % 100)); ////////paramsBuffer.UnMap(); //RenderBase.SetWorld(Matrix.Scaling(plantData[i].Y) * Matrix.RotationZ(plantData[i].Z) * Matrix.Translation(plantData[i].X, -1.1f, -0.001f * (150 - plantData.Length + i))); di.Write(Matrix.Scaling(plantData[i].Y) * Matrix.RotationZ(plantData[i].Z) * Matrix.Translation(plantData[i].X, -1.1f, -0.001f * (i - plantData.Length * 7 / 10))); di.Write(new Vector4(0.0f, plantData[i].W, 0.0f, ET * plantWaveSpeed[i] + (i % 100) * (i % 100))); //RenderBase.DeviceContext.Draw(plantVertCount, 0); } plantInstanceBuffer.UnMap(); //Console.WriteLine("C"); RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(plantVertexBuffer, Utilities.SizeOf <VertexPositionNormal>(), 0), new VertexBufferBinding(plantInstanceBuffer.Buffer, Utilities.SizeOf <Matrix>() + Utilities.SizeOf <Vector4>(), 0)); RenderBase.DeviceContext.DrawInstanced(plantVertCount, plantData.Length * 7 / 10, 0, 0); { vertexShader.Set(); RenderBase.DeviceContext.PixelShader.Set(pixelShader); RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(floorVertexBuffer, Utilities.SizeOf <VertexPositionNormal>(), 0)); var ds = paramsBuffer.Map(); ds.Write(new Vector4(0.7f, 0.7f, 0.7f, 0.0f)); ds.Write(0); paramsBuffer.UnMap(); //paramsBuffer.Set(2); RenderBase.SetWorld(Matrix.Scaling((16.0f / 9.0f) / 4.0f) * Matrix.Translation(0, -1.0f, 0.0f)); //System.Threading.Thread.Sleep(250); RenderBase.DeviceContext.Draw(floorVertCount, 0); } /*{ * var ds = paramsBuffer.Map(); * ds.Write(new Vector4(1, 1, 1, 1)); * paramsBuffer.UnMap(); * RenderBase.SetWorld(Matrix.Scaling(0.15f) * Matrix.Translation(Input.XInputInput.State[0].RightThumbX / (float)short.MaxValue, Input.XInputInput.State[0].RightThumbY / (float)short.MaxValue, 0));//Matrix.Scaling(0.05f)); * RenderBase.DeviceContext.Draw(3 * 3, 0); * }*/ }
public void Render() { RenderBase.SetWorld(Matrix.Identity); vertexShader.Set(); RenderBase.DeviceContext.PixelShader.Set(pixelShader); paramsBuffer.Set(2); RenderBase.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; //Draw Fish RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Default; RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, Utilities.SizeOf <VertexPositionNormal>(), 0)); foreach (var f in Manager.FoodList) { var ds = paramsBuffer.Map(); ds.Write(f.Color); paramsBuffer.UnMap(); RenderBase.SetWorld(Matrix.Scaling(f.Size.X, f.Size.Y, (f.Size.X + f.Size.Y) / 2.0f) * Matrix.RotationZ(f.Rotation) * Matrix.Translation(f.Position.X, f.Position.Y, 0.0f)); RenderBase.DeviceContext.Draw(vertCount, 0); } /*{ * var ds = paramsBuffer.Map(); * ds.Write(new Vector4(1, 1, 1, 1)); * paramsBuffer.UnMap(); * RenderBase.SetWorld(Matrix.Scaling(0.15f) * Matrix.Translation(Input.XInputInput.State[0].RightThumbX / (float)short.MaxValue, Input.XInputInput.State[0].RightThumbY / (float)short.MaxValue, 0));//Matrix.Scaling(0.05f)); * RenderBase.DeviceContext.Draw(3 * 3, 0); * }*/ }
public void Render(ShaderResourceView tex, float dt) { ET += dt * 0.5f; //CentrePoint = new Vector2((float)Math.Cos(ET * 3.14f) * 1000 + RenderBase.RenderWidth / 2, (float)Math.Sin(ET) * 1000 + RenderBase.RenderHeight / 2); RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); RenderBase.DeviceContext.InputAssembler.SetIndexBuffer(null, (SharpDX.DXGI.Format) 0, 0); vertexShader.Set(); RenderBase.DeviceContext.PixelShader.Set(pixelShader); RenderBase.DeviceContext.PixelShader.SetShaderResource(0, tex); RenderBase.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; //RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.Additive; var ds = cb.Map(); ds.Write(CentrePoint); ds.Write(CutOff); //ds.Write((float)Math.Tan(ET * 0.1f * Math.Tan(ET * 2418.241f)) * 1.0f); ds.Write(Intensity); ds.Write(0); ds = null; cb.UnMap(); cb.Set(3); RenderBase.DeviceContext.Draw(3, 0); //RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.Default; }
private void RenderDebugTri() { //DeviceContext.VertexShader.Set(vertexShader); vertexShader.Set(); DeviceContext.PixelShader.Set(pixelShader); DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; DeviceContext.InputAssembler.SetVertexBuffers(0, new D3D.VertexBufferBinding(triangleVertexBuffer, Utilities.SizeOf <Vector3>(), 0)); DeviceContext.Draw(3, 0); }
public void Render() { RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); RenderBase.DeviceContext.InputAssembler.SetIndexBuffer(null, (SharpDX.DXGI.Format) 0, 0); vertexShader.Set(); RenderBase.DeviceContext.PixelShader.Set(pixelShader); RenderBase.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Additive; var ds = cb.Map(); ds.Write(Manager.FishCount); ds.Write(150.0f * (1 + Input.XInputInput.State[0].LeftTrigger / 255.0f * 5) * (1 - Input.XInputInput.State[0].RightTrigger / 255.0f)); ds.Write(Intensity);//(Input.XInputInput.State[0].LeftThumbY / (float)short.MaxValue + 1.0f) * 0.75f); ds.Write((et += (1.0f / 60.0f)) * 100.0f); for (int i = 0; i < FishManager.MAX_FISH_COUNT; i++) { if (Manager.FishList[i] != null) { ds.Write(Manager.FishList[i].Position); ds.Write(0.0f); ds.Write(1.0f); } else { ds.Write(Vector4.Zero); } } for (int i = 0; i < FishManager.MAX_FISH_COUNT; i++) { if (Manager.FishList[i] != null) { ds.Write(Manager.FishList[i].Color); } else { ds.Write(Vector4.Zero); } } ds = null; cb.UnMap(); cb.Set(1); RenderBase.DeviceContext.Draw(3, 0); RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Default; }
public void Render() { //RenderBase.DeviceContext.Rasterizer.State = RenderBase.RasterizerStates.None; var dt = 1.0f / 60.0f; et += dt; //RenderBase.SetWorld(Matrix.Identity); vertexShader.Set(); RenderBase.DeviceContext.PixelShader.Set(pixelShader); paramsBuffer.Set(2); RenderBase.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Additive; if ((Input.XInputInput.State[0].Buttons & SharpDX.XInput.GamepadButtonFlags.Y) == SharpDX.XInput.GamepadButtonFlags.Y) { //Draw Sight RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(coneVertexBuffer, Utilities.SizeOf <VertexPositionColor>(), 0)); for (int i = 0; i < Manager.FishCount && i == 0; i++) { var fish = Manager.FishList[i]; for (int j = 0; j < fish.Sights.Length; j++) { var ds = paramsBuffer.Map(); if (fish.Sights[j].Color.W == 0.0f) { ds.Write(new Vector4(1, 1, 0, 0.05f)); } else { ds.Write(fish.Sights[j].Color); } ds.Write(0.0f); paramsBuffer.UnMap(); RenderBase.SetWorld(Matrix.Scaling((float)Math.Cos(fish.Sights[j].WidthAngle / 2.0f) * fish.Sights[j].Distance, (float)Math.Sin(fish.Sights[j].WidthAngle / 2.0f) * fish.Sights[j].Distance, 1.0f) * Matrix.RotationZ(fish.Sights[j].MidAngle) * Matrix.Translation(fish.Sights[j].Start.X, fish.Sights[j].Start.Y, 0.0f) * Matrix.RotationZ(fish.Rotation) * Matrix.Translation(fish.Position.X, fish.Position.Y, 0.0f));//Matrix.Scaling(0.05f)); RenderBase.DeviceContext.Draw(3, 0); } } } for (int mi = 0; mi < vertexBuffer.Length; mi++) { RenderBase.DeviceContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer[mi], Utilities.SizeOf <VertexPositionNormal>(), 0)); foreach (var fish in Manager.DeadFish) { if (fish.MeshIndex != mi) { continue; } var ds = paramsBuffer.Map(); ds.Write(fish.Color.X); ds.Write(fish.Color.Y); ds.Write(fish.Color.Z); ds.Write(fish.Color.W * (1.0f + fish.FoodLevel / 3.0f)); ds.Write(fish.FoodLevel * 10.0f); ds.Write(fish.Seed); paramsBuffer.UnMap(); RenderBase.SetWorld(Matrix.Scaling(fish.Size.X, fish.Size.Y, (fish.Size.X + fish.Size.Y) / 2.0f) * Matrix.RotationX(fish.Roll) * Matrix.RotationZ(fish.Rotation) * Matrix.Translation(fish.Position.X, fish.Position.Y, 0.0f));//Matrix.Scaling(0.05f)); RenderBase.DeviceContext.Draw(vertexCount[mi], 0); } //Draw Fish RenderBase.DeviceContext.OutputMerger.BlendState = RenderBase.BlendStates.Default; for (int i = 0; i < Manager.FishCount; i++) { var fish = Manager.FishList[i]; if (fish.MeshIndex != mi) { continue; } var ds = paramsBuffer.Map(); ds.Write(Manager.FishList[i].Color); ds.Write(0); ds.Write(0); paramsBuffer.UnMap(); RenderBase.SetWorld(Matrix.Scaling(fish.Size.X, fish.Size.Y, (fish.Size.X + fish.Size.Y) / 2.0f) * Matrix.RotationX(fish.Roll) * Matrix.RotationZ(fish.Rotation) * Matrix.Translation(fish.Position.X, fish.Position.Y, 0.0f));//Matrix.Scaling(0.05f)); RenderBase.DeviceContext.Draw(vertexCount[mi], 0); } } /*{ * var ds = paramsBuffer.Map(); * ds.Write(new Vector4(1, 1, 1, 1)); * paramsBuffer.UnMap(); * RenderBase.SetWorld(Matrix.Scaling(0.15f) * Matrix.Translation(Input.XInputInput.State[0].RightThumbX / (float)short.MaxValue, Input.XInputInput.State[0].RightThumbY / (float)short.MaxValue, 0));//Matrix.Scaling(0.05f)); * RenderBase.DeviceContext.Draw(3 * 3, 0); * }*/ }