Beispiel #1
0
 protected void Visualize(Texture texture, EffectTechnique technique, Viewport viewport, bool present = true, bool clear = true)
 {
     XDevice.SetRenderTarget(null);
     XDevice.Viewport = viewport;
     if (clear)
     {
         XDevice.Clear(Color.White);
     }
     MainSampler.SetValue(texture);
     XEffect.CurrentTechnique = technique;
     XEffect.CurrentTechnique.Passes[0].Apply();
     MiniPlane.Draw();
     if (present)
     {
         XDevice.Present();
     }
     XDevice.Viewport = MainViewport;
 }
Beispiel #2
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();
                }
            }
        }