示例#1
0
        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();
                }
            }
        }
示例#2
0
        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];
        }