public override void Save(string fileName) { for (int leg = 0; leg < 2; leg++) { //Averaging XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetB : SingleTargetA); XDevice.Clear(Color.Black); DepthSampler.SetValue(ExCoreTick[leg] ? ExCoreTargetA[leg] : ExCoreTargetB[leg]); XEffect.CurrentTechnique = PolarAvgTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); //Gauss-filtering :D for (int i = 0; i < 16; i++) { XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetA : SingleTargetB); DepthSampler.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); XEffect.CurrentTechnique = VGaussTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); SingleTargetTick = !SingleTargetTick; XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetA : SingleTargetB); DepthSampler.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); XEffect.CurrentTechnique = HGaussTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); SingleTargetTick = !SingleTargetTick; } XDevice.SetRenderTarget(null); STLScreenshot(SingleTargetTick ? SingleTargetB : SingleTargetA, Path.ChangeExtension(fileName, leg + ".stl"), "Created by KinectScan.", MinY.GetValueSingle(), MaxHeight.GetValueSingle()); } }
public GameController(IInputDevice directInput, InputMapperBase mapper) { this.inputDevice = directInput; this.mapper = mapper; scpDevice = new ScpDevice(); xInput = new XDevice(directInput, mapper); running = false; }
private void VisualizeAxes(EffectTechnique technique) { VertexPositionColor[] VPC = new VertexPositionColor[10]; VPC[0] = new VertexPositionColor(new Vector3(0, -0.1f, 0), Color.Yellow); VPC[1] = new VertexPositionColor(new Vector3(0, 0.1f, 0), Color.Yellow); VPC[2] = new VertexPositionColor(new Vector3(0.1f, 0f, 0), Color.Yellow); VPC[3] = new VertexPositionColor(new Vector3(-0.1f, 0f, 0), Color.Yellow); VPC[4] = new VertexPositionColor(new Vector3(0, 0f, 0.1f), Color.Yellow); VPC[5] = new VertexPositionColor(new Vector3(0, 0f, -0.1f), Color.Yellow); VPC[6] = new VertexPositionColor(new Vector3(-CoreY, -1, CoreX), Color.Green); VPC[7] = new VertexPositionColor(new Vector3(-CoreY, 1, CoreX), Color.Green); VPC[8] = new VertexPositionColor(new Vector3(-CoreY, -1, -CoreX), Color.Red); VPC[9] = new VertexPositionColor(new Vector3(-CoreY, 1, -CoreX), Color.Red); LinesVertexBuffer.SetData <VertexPositionColor>(VPC); XDevice.SetVertexBuffer(LinesVertexBuffer); XEffect.CurrentTechnique = technique; XEffect.CurrentTechnique.Passes[0].Apply(); XDevice.DrawPrimitives(PrimitiveType.LineList, 0, 5); }
private void ProcessProbes(Texture2D depthTexture) { if (ProbesOn) { if (DownloadComplete) { DownloadComplete = false; Probes.Refresh(); } if (FrameID % ProbeInterval == 0 && !ProbeDownloadInProgress) { XDevice.SetRenderTarget(GPUDownloadCache); XDevice.Clear(ClearOptions.Target, Microsoft.Xna.Framework.Color.Black, 0f, 0); XDevice.DepthStencilState = DepthStencilState.Default; XDevice.RasterizerState = RasterizerState.CullNone; XEffect.CurrentTechnique = ReprojectionOutputTechnique; EFDepthTexture.SetValue(depthTexture); XEffect.CurrentTechnique.Passes[0].Apply(); Plane.Draw(); XDevice.SetRenderTarget(null); GPUDownloadARE.Set(); } } }
private void VisualizeModel(int leg) { HorizantalAngle = ManualHorizantalAngle - mainRotation; //Model visualization if (ViewMode == Views.Special && SpecialView == SpecialViews.CoreModel && (VisualizedLeg == 2 || VisualizedLeg == leg)) { //Averaging XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetB : SingleTargetA); XDevice.Clear(Color.Black); DepthSampler.SetValue(ExCoreTick[leg] ? ExCoreTargetA[leg] : ExCoreTargetB[leg]); XEffect.CurrentTechnique = PolarAvgTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); //Gauss-filtering for (int i = 0; i < GaussIterations; i++) { XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetA : SingleTargetB); DepthSampler.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); XEffect.CurrentTechnique = VGaussTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); SingleTargetTick = !SingleTargetTick; XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetA : SingleTargetB); DepthSampler.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); XEffect.CurrentTechnique = HGaussTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); SingleTargetTick = !SingleTargetTick; } //Polar to Cartesian XDevice.SetRenderTarget(Vector4Target); XDevice.Clear(Color.Black); DepthSampler.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); XEffect.CurrentTechnique = PolarToCartesianTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); //Draw model XDevice.SetRenderTarget(null); if (leg == 0 || VisualizedLeg != 2) { XDevice.Clear(Color.White); } XDevice.DepthStencilState = DepthStencilState.Default; XDevice.RasterizerState = RasterizerState.CullNone; MainSampler.SetValue(Vector4Target); Matrix gridWorldViewProj = SetModelVisualizationProjection(VisualizedLeg == 2 ? leg : 2); XEffect.CurrentTechnique = PolarModelTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MaxiPlane.Draw(); ModelTransform.SetValue(gridWorldViewProj); VisualizeAxes(SimpleColorModelTechnique); if (leg == 1 || VisualizedLeg != 2) { XDevice.Present(); } } }
protected override void ProcessLeg(int leg, bool visualize, Viewport viewport, bool present, bool clear) { //Visualizing axes if (ViewMode == Views.Special && SpecialView == SpecialViews.CorePosition && leg == VisualizedLeg) { Visualize(SingleTargetTick ? SingleTargetA : SingleTargetB, SignedDepthVisualizationTechnique, MainViewport, false); SetModelProjection(-mainRotation + SplitPlaneAngle + MathHelper.PiOver2); VisualizeAxes(ColorModelTechnique); XDevice.Present(); } //Polar reprojection XDevice.RasterizerState = new RasterizerState() { ScissorTestEnable = true, CullMode = CullMode.CullCounterClockwiseFace }; XDevice.SetRenderTarget(SingleTargetTick ? SingleTargetB : SingleTargetA); XDevice.Clear(Color.Black); DepthSampler.SetValue(SingleTargetTick ? SingleTargetA : SingleTargetB); CorePos.SetValue(new Vector3(CoreY, 0, leg == 0 ? -CoreX : CoreX)); SetExCoreReprojection(mainRotation); XEffect.CurrentTechnique = PolarOutputTechnique; for (int half = 0; half < 2; half++) { XDevice.ScissorRectangle = ExCoreTargetClippingRectangles[half]; FiShift.SetValue(half == 0 ? 0f : 1f); XEffect.CurrentTechnique.Passes[0].Apply(); MaxiPlane.Draw(); } if (ViewMode == Views.Special && SpecialView == SpecialViews.CoreReprojection && visualize) { XDevice.SetRenderTarget(null); XDevice.Viewport = viewport; if (clear) { XDevice.Clear(Color.White); } XEffect.CurrentTechnique = PolarDisplayTechnique; for (int half = 0; half < 2; half++) { XDevice.ScissorRectangle = MainTargetClippingRectangles[half]; FiShift.SetValue(half == 0 ? 0f : 1f); XEffect.CurrentTechnique.Passes[0].Apply(); MaxiPlane.Draw(); } if (present) { XDevice.Present(); } XDevice.Viewport = MainViewport; } XDevice.RasterizerState = RasterizerState.CullCounterClockwise; //Polar sum XDevice.SetRenderTarget(ExCoreTick[leg] ? ExCoreTargetA[leg] : ExCoreTargetB[leg]); if (NextExCoreClear[leg]) { XDevice.Clear(ClearOptions.Target, Color.Black, 1, 0); NextExCoreClear[leg] = false; } else { DepthSamplerA.SetValue(SingleTargetTick ? SingleTargetB : SingleTargetA); DepthSamplerB.SetValue(ExCoreTick[leg] ? ExCoreTargetB[leg] : ExCoreTargetA[leg]); XEffect.CurrentTechnique = PolarAddTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); } //Averaged visualization if (ViewMode == Views.Special && SpecialView == SpecialViews.CorePolarDepth && visualize) { XDevice.SetRenderTarget(null); XDevice.Viewport = viewport; if (clear) { XDevice.Clear(Color.White); } DepthSampler.SetValue(ExCoreTick[leg] ? ExCoreTargetA[leg] : ExCoreTargetB[leg]); XEffect.CurrentTechnique = PolarAvgDisplayTechnique; XEffect.CurrentTechnique.Passes[0].Apply(); MiniPlane.Draw(); if (present) { XDevice.Present(); } XDevice.Viewport = MainViewport; } VisualizeModel(leg); ExCoreTick[leg] = !ExCoreTick[leg]; }