/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> public override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { var device = Game.GraphicsDevice; var cam = Game.GetService <GreatCircleCamera>(); int lastCommand = 0; if (commandQueue.Count > 0) { lastCommand = commandQueue.Dequeue(); } // Calculate positions: ---------------------------------------------------- lay.UseGPU = Config.UseGPU; lay.SpringTension = Config.SpringTension; lay.StepMode = Config.StepMode; lay.Update(lastCommand); // Render: ----------------------------------------------------------------- Params param = new Params(); param.View = cam.GetViewMatrix(stereoEye); param.Projection = cam.GetProjectionMatrix(stereoEye); param.SelectedNode = referenceNodeIndex; render(device, lay, param, gameTime); // Debug output: ------------------------------------------------------------ // var debStr = Game.GetService<DebugStrings>(); // debStr.Add( Color.Yellow, "drawing " + nodeList.Count + " points" ); // debStr.Add( Color.Yellow, "drawing " + edgeList.Count + " lines" ); // debStr.Add( Color.Black, lay.UseGPU ? "Using GPU" : "Not using GPU" ); base.Draw(gameTime, stereoEye); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> public override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { var ds = Game.GetService <DebugStrings>(); ds.Add("{0}", injectionCount); var device = Game.GraphicsDevice; device.ResetStates(); device.SetTargets(null, device.BackbufferColor); int w = device.DisplayBounds.Width; int h = device.DisplayBounds.Height; //var map = "SV_POSITION.xyzw;COLOR0.xyzw;COLOR1.xyzw;TEXCOORD0.xyzw;TEXCOORD1.xyzw;TEXCOORD2.xyzw"; Params param = new Params(); param.View = Matrix.Identity; param.Projection = Matrix.OrthoOffCenterRH(0, w, h, 0, -9999, 9999); param.MaxParticles = 100; param.DeltaTime = gameTime.ElapsedSec; paramsCB.SetData(param); device.VertexShaderConstants[0] = paramsCB; device.GeometryShaderConstants[0] = paramsCB; device.PixelShaderConstants[0] = paramsCB; device.PixelShaderSamplers[0] = SamplerState.LinearWrap; // // Simulate : // device.PipelineState = factory[(int)Flags.SIMULATION]; device.SetupVertexInput(simulationSrcVB, null); device.SetupVertexOutput(simulationDstVB, 0); device.DrawAuto(); // // Inject : // injectionVB.SetData(injectionBufferCPU); device.PipelineState = factory[(int)Flags.INJECTION]; device.SetupVertexInput(injectionVB, null); device.SetupVertexOutput(simulationDstVB, -1); device.Draw(injectionCount, 0); SwapParticleBuffers(); // // Render // paramsCB.SetData(param); device.VertexShaderConstants[0] = paramsCB; device.GeometryShaderConstants[0] = paramsCB; device.PixelShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.RENDER]; device.PixelShaderResources[0] = texture; device.SetupVertexOutput(null, 0); device.SetupVertexInput(simulationSrcVB, null); //device.Draw( Primitive.PointList, injectionCount, 0 ); device.DrawAuto(); //device.Draw( Primitive.PointList, MaxSimulatedParticles, 0 ); ClearParticleBuffer(); base.Draw(gameTime, stereoEye); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> protected override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { base.Draw(gameTime, stereoEye); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> public override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { var device = Game.GraphicsDevice; int w = device.DisplayBounds.Width; int h = device.DisplayBounds.Height; Params param = new Params(); param.View = Matrix.Identity; param.Projection = Matrix.OrthoOffCenterRH(0, w, h, 0, -9999, 9999); param.MaxParticles = 0; param.DeltaTime = gameTime.ElapsedSec; device.ComputeShaderConstants[0] = paramsCB; device.VertexShaderConstants[0] = paramsCB; device.GeometryShaderConstants[0] = paramsCB; device.PixelShaderConstants[0] = paramsCB; device.PixelShaderSamplers[0] = SamplerState.LinearWrap; // // Inject : // injectionBuffer.SetData(injectionBufferCPU); device.Clear(simulationBufferDst, Int4.Zero); device.ComputeShaderResources[1] = injectionBuffer; device.SetCSRWBuffer(0, simulationBufferDst, 0); param.MaxParticles = injectionCount; paramsCB.SetData(param); //device.CSConstantBuffers[0] = paramsCB ; device.PipelineState = factory[(int)Flags.INJECTION]; device.Dispatch(MathUtil.IntDivUp(MaxInjectingParticles, BlockSize)); ClearParticleBuffer(); // // Simulate : // device.ComputeShaderResources[1] = simulationBufferSrc; param.MaxParticles = MaxSimulatedParticles; paramsCB.SetData(param); device.ComputeShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.SIMULATION]; device.Dispatch(MathUtil.IntDivUp(MaxSimulatedParticles, BlockSize)); //*/ SwapParticleBuffers(); // // Render // device.PipelineState = factory[(int)Flags.DRAW]; device.SetCSRWBuffer(0, null); device.PixelShaderResources[0] = texture; device.GeometryShaderResources[1] = simulationBufferSrc; device.Draw(MaxSimulatedParticles, 0); /*var testSrc = new Particle[MaxSimulatedParticles]; * var testDst = new Particle[MaxSimulatedParticles]; * * simulationBufferSrc.GetData( testSrc ); * simulationBufferDst.GetData( testDst );*/ base.Draw(gameTime, stereoEye); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> public override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { var ui = Game.GetService <UserInterface>(); ui.Draw(gameTime, StereoEye.Mono); Game.GraphicsDevice.ClearBackbuffer(Color.Black, 1, 0); var device = Game.GraphicsDevice; var cam = Game.GetService <OrbitCamera>(); var inp = Game.InputDevice; int w = Game.GraphicsDevice.DisplayBounds.Width; int h = Game.GraphicsDevice.DisplayBounds.Height; param.View = cam.GetViewMatrix(stereoEye); param.Projection = cam.GetProjectionMatrix(stereoEye); param.MaxParticles = 0; param.DeltaTime = gameTime.ElapsedSec; param.LinkSize = linkSize; device.ComputeShaderConstants[0] = paramsCB; device.VertexShaderConstants[0] = paramsCB; device.GeometryShaderConstants[0] = paramsCB; device.PixelShaderConstants[0] = paramsCB; device.PixelShaderSamplers[0] = SamplerState.LinearWrap; // Simulate : ------------------------------------------------------------------------ param.MaxParticles = injectionCount; paramsCB.SetData(param); device.ComputeShaderConstants[0] = paramsCB; if (state == State.RUN) { for (int i = 0; i < 20; i++) { // calculate accelerations: --------------------------------------------------- device.SetCSRWBuffer(0, simulationBufferSrc, MaxSimulatedParticles); device.ComputeShaderResources[2] = linksPtrBuffer; device.ComputeShaderResources[3] = linksBuffer; param.MaxParticles = MaxSimulatedParticles; paramsCB.SetData(param); device.ComputeShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.SIMULATION | (int)cfg.IType]; device.Dispatch(MathUtil.IntDivUp(MaxSimulatedParticles, BlockSize)); // move particles: ------------------------------------------------------------ device.SetCSRWBuffer(0, simulationBufferSrc, MaxSimulatedParticles); device.ComputeShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.MOVE | (int)cfg.IType]; device.Dispatch(MathUtil.IntDivUp(MaxSimulatedParticles, BlockSize)); } } // draw points: ------------------------------------------------------------------------ device.PipelineState = factory[(int)Flags.POINT]; device.PixelShaderResources[0] = texture; device.SetCSRWBuffer(0, null); device.GeometryShaderResources[1] = simulationBufferSrc; device.Draw(MaxSimulatedParticles, 0); device.Draw(ParticleList.Count, 0); // draw lines: -------------------------------------------------------------------------- device.PipelineState = factory[(int)Flags.LINE]; device.GeometryShaderResources[1] = simulationBufferSrc; device.GeometryShaderResources[3] = linksBuffer; device.Draw(linkList.Count, 0); ui.Draw(gameTime, stereoEye); // -------------------------------------------------------------------------------------- var sb = Game.GetService <SpriteBatch>(); sb.Begin(); sb.End(); var debStr = Game.GetService <DebugStrings>(); debStr.Add(Color.Yellow, "drawing " + ParticleList.Count + " points"); debStr.Add(Color.Yellow, "drawing " + linkList.Count + " lines"); base.Draw(gameTime, stereoEye); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="stereoEye"></param> public override void Draw(GameTime gameTime, Fusion.Graphics.StereoEye stereoEye) { Game.GraphicsDevice.ClearBackbuffer(Color.White, 1, 0); var device = Game.GraphicsDevice; var cam = Game.GetService <OrbitCamera>(); var inp = Game.InputDevice; int w = Game.GraphicsDevice.DisplayBounds.Width; int h = Game.GraphicsDevice.DisplayBounds.Height; param.View = cam.GetViewMatrix(stereoEye); param.Projection = cam.GetProjectionMatrix(stereoEye); param.MaxParticles = 0; param.DeltaTime = gameTime.ElapsedSec; param.LinkSize = linkSize; device.ComputeShaderConstants[0] = paramsCB; device.VertexShaderConstants[0] = paramsCB; device.GeometryShaderConstants[0] = paramsCB; device.PixelShaderConstants[0] = paramsCB; device.PixelShaderSamplers[0] = SamplerState.LinearWrap; // Simulate : ------------------------------------------------------------------------ // param.MaxParticles = injectionCount; paramsCB.SetData(param); device.ComputeShaderConstants[0] = paramsCB; if (state == State.RUN) { for (int i = 0; i < 10; i++) { // calculate accelerations: --------------------------------------------------- device.SetCSRWBuffer(0, simulationBufferSrc, MaxSimulatedParticles); device.ComputeShaderResources[2] = linksPtrBuffer; device.ComputeShaderResources[3] = linksBuffer; param.MaxParticles = MaxSimulatedParticles; paramsCB.SetData(param); device.ComputeShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.SIMULATION | (int)cfg.IType]; device.Dispatch(MathUtil.IntDivUp(MaxSimulatedParticles, BlockSize)); // move particles: ------------------------------------------------------------ device.SetCSRWBuffer(0, simulationBufferSrc, MaxSimulatedParticles); device.ComputeShaderConstants[0] = paramsCB; device.PipelineState = factory[(int)Flags.MOVE | (int)cfg.IType]; device.Dispatch(MathUtil.IntDivUp(MaxSimulatedParticles, BlockSize)); //*/ } } // ------------------------------------------------------------------------------------ // Render: --------------------------------------------------------------------------- // device.SetCSRWBuffer(0, null); // draw lines: -------------------------------------------------------------------------- if (drawLinks == true) { device.PipelineState = factory[(int)Flags.LINE]; device.GeometryShaderResources[1] = simulationBufferSrc; device.GeometryShaderResources[3] = linksBuffer; device.Draw(linkList.Count, 0); } // draw points: ------------------------------------------------------------------------ device.PipelineState = factory[(int)Flags.POINT]; device.PixelShaderSamplers[0] = SamplerState.AnisotropicWrap; device.PixelShaderResources[0] = texture; device.GeometryShaderResources[1] = simulationBufferSrc; // device.Draw(MaxSimulatedParticles, 0); device.Draw(ParticleList.Count, 0); // -------------------------------------------------------------------------------------- var debStr = Game.GetService <DebugStrings>(); //debStr.Add("Press I to start simulation"); //debStr.Add("Press L to speed up simulation"); //debStr.Add("Press K to slow down simulation"); //debStr.Add("Press Q to pause/unpause"); //if (currentParticle != -1) //{ // if (currentParticle >= 100) // { // debStr.Add(Color.Yellow, "CUSTOMER"); // debStr.Add(Color.Yellow, "links Count " + ParticleList[currentParticle].linksCount); // } // else { // debStr.Add(Color.Yellow, "Asset " + ParticleList[currentParticle].Assets); // debStr.Add(Color.Yellow, "links Count " + ParticleList[currentParticle].linksCount); // debStr.Add(Color.Yellow, "Id " + ParticleList[currentParticle].Id); // } //} var sb = Game.GetService <SpriteBatch>(); //int w = Game.GraphicsDevice.DisplayBounds.Width; //int h = Game.GraphicsDevice.DisplayBounds.Height; sb.Begin(); //sb.DrawSprite(line, w - 50, h - 50, line.Width, line.Height / 3, 0, Color.White); Color col = Color.Red; col.G += 100; col.B += 100; sb.DrawSprite(texture, w - 170, h - 125, 40, 40, 0, Color.Green); sb.DrawSprite(texture, w - 170, h - 95, 40, 40, 0, Color.Blue); sb.DrawSprite(texture, w - 170, h - 65, 40, 40, 0, col); font1.DrawString(sb, "Bank", w - 150, h - 122, Color.Black); font1.DrawString(sb, "Customer", w - 150, h - 91, Color.Black); font1.DrawString(sb, "Bankrupt", w - 150, h - 61, Color.Black); foreach (var plot in Plot1.dataPlot) { plot.Draw(sb, h, 1, w, Plot1.scale, maxArr); } foreach (var plot in Plot2.dataPlot) { plot.Draw(sb, h, 2, w, Plot2.scale, maxArr); } foreach (var plot in Plot3.dataPlot) { plot.Draw(sb, h, 3, w, Plot3.scale, maxArr); } foreach (var plot in Plot4.dataPlot) { plot.Draw(sb, h, 4, w, Plot4.scale, maxArr); } foreach (var plot in Plot5.dataPlot) { plot.Draw(sb, h, 5, w, Plot5.scale, maxArr); } Plot1.Draw(sb, h, 5, w, Plot5.scale, Plot5.maxValue); //bool a = true; //if (locki == true) //{ // for (int i = 0; i < 100; i++) // { // foreach (var plot in dataPlot1) // { // plot.x -= 0.01f; // } // } //} // sb.Restart(); //font1.DrawString(sb, "Lenna Soderberg", 130, 230, Color.Plum); sb.End(); //debStr.Add(Color.Yellow, "drawing " + ParticleList.Count + " points"); //debStr.Add(Color.Yellow, "drawing " + linkList.Count + " lines"); base.Draw(gameTime, stereoEye); }