public static void RenderAllSplits(Device device, EEDCamera Camera, DVector3 ShadowVector, KDtree KDT, List<GameObject> ObjInCam)
        {
            for (int t = 0; t < ObjInCam.Count; t++)
                if (ObjInCam[t] != null)
                {
                    ObjInCam[t].StartSplit = -1;
                    ObjInCam[t].StopSplit = -1;
                }
            //string title = "";
            GenerateSplit(Camera, ShadowVector);
            for (int i = 0; i < SplitsNumber; i++)
            {
                DMatrix Inv = DMatrix.Invert(Conversion.ToDoubleMatrix(LightViewProjMatrix * CropMatrices[i]));
                Vector3 View = Conversion.ToVector3(DVector3.Transform(new DVector3(0, 0, 1), Inv) - DVector3.Transform(new DVector3(0, 0, 0), Inv));
                Vector3 Right = Conversion.ToVector3(DVector3.Transform(new DVector3(1, 0, 0), Inv) - DVector3.Transform(new DVector3(0, 0, 0), Inv));
                Vector3 Up = Conversion.ToVector3(DVector3.Transform(new DVector3(0, 1, 0), Inv) - DVector3.Transform(new DVector3(0, 0, 0), Inv));
                BoundingFrustum BF = new BoundingFrustum(View, Right, Up);

                ObjInSplites[i] =

                    //KDT.GetBody(new DVector3(), ShadowDistance);
                    KDT.GetBodyInCamera(NewCamPositions[i], BF);

                //title += "  "  + ObjInSplites[i].Count;
            }
            //Program.form.Text = title;
            RenderTargetView RTV_ = null;
            device.ImmediateContext.OutputMerger.SetTargets(SMArrayDSV, RTV_);

            device.ImmediateContext.ClearDepthStencilView(SMArrayDSV, DepthStencilClearFlags.Depth, 1.0f, 0);

            device.ImmediateContext.Rasterizer.SetViewports(SMArrayV);

            for (int i = 0; i < SplitsNumber; i++)
            {
                for (int y = 0; y < ObjInSplites[i].Count; y++)
                {
                    GameObject GO = ObjInSplites[i][y];
                    if (GO != null)
                    {
                        int Start = i;
                        int Stop = i;

                        if (i < SplitsNumber)
                        {
                            for (int j = i + 1; j < SplitsNumber; j++)
                            {
                                //Перебор последующих срезов
                                if (ObjInSplites[j].Contains(GO))
                                {
                                    Stop = j;
                                    ObjInSplites[j].Remove(GO);
                                }
                            }
                        }
                        //Draw
                        GO.StartSplit = Start;
                        GO.StopSplit = Stop;

                        GO.DrawPSSMSplit(device, NewShadowPos, LightViewProjMatrix, CropMatrices, Start, Stop);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public static void DrawKDTree(KDtree KD, Vector3 Color)
 {
     if (KD != null && KD.Root != null)
     RecursyKD(KD.Root, Color);
 }
Exemplo n.º 3
0
        public void Draw(float TimeMili, Device device, DeviceContext context)
        {
            if (RebderCube)
            {
                RebderCube = false;
                SkyBox.RenderCubemap();
            }

            Random R = new Random(2);
            for (int i = 0; i < 0; i+=2)
            {
                DVector3 t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500));
                LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1);
                t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500));
                LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(0, 0, 1, 1), TC2);

            }

            LensBatching.DrawLens(Camera.position + Conversion.ToDoubleVector(-LightDirection)*Camera.farClip*0.95f, new Vector2(1000, 1000), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1);

            KDtree KDT = new KDtree(20, AllObjects);
            List<GameObject> InCam = KDT.GetBodyInCamera(Camera.position, Camera.LcameraFrustum);

            DebugDraw.ResetLine();

            //Depth
            device.ImmediateContext.OutputMerger.SetTargets(DepthMapStencilView, DepthTarget);
            device.ImmediateContext.ClearDepthStencilView(DepthMapStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);
            context.ClearRenderTargetView(DepthTarget, new Color4(1.0f, 0.0f, 0.0f, 1.0f));
            for (int i = 0; i < InCam.Count; i++) if (InCam[i] != null) InCam[i].DrawDepth(device, Camera);

            PSSMsHelper.RenderAllSplits(device, Camera, Conversion.ToDoubleVector(LightDirection), KDT, InCam);
            //
            DrawHelper.OcclusionTest(device, Camera, DepthSRV);
            //
            context.Rasterizer.SetViewports(Program.viewport);
            context.OutputMerger.SetTargets(DepthStencilView, HDRTarget);
            context.ClearRenderTargetView(HDRTarget, new Color4(0.5f, 0.5f, 1.0f, 1.0f));
            context.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);

            //DebugDraw.AddLine(new DebugLine(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0)));
            //DebugDraw.DrawAABB(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0));
            //DebugDraw.DrawKDTree(KDT, new Vector3(1, 0, 0));
            //DebugDraw.DrawLocator(new DVector3(50, 50, 0), 5, new Vector3(0, 1, 0));
            SkyBox.Draw(TimeMili, device, context, Camera);

            /*
            for (int i = 0; i < InCam.Count; i++)
                if (InCam[i] != null)
                    InCam[i].Draw(device, Camera, Light, LightDirection);
            */

            PSSMsHelper.RenderObj(TimeMili, device, Camera, LightDirection, Light.Color, InCam);

            for (int i = 0; i < InCam.Count; i++)
                if (InCam[i] != null)
                    InCam[i].DrawEffects(device, Camera);

            LensBatching.BatchingDrawLens(device, Camera, DepthSRV);

            DebugDraw.Draw(device, Camera);

            /*
            foreach (GSSprite TS_ in TS)
            {
                TS_.Render(device, Camera, DepthSRV);
            }
            */

            //context.OutputMerger.SetTargets(renderTarget);
            //HDRSRV
            //DepthSRV
            QuadScreen.FinalRender(device, TimeMili, context, HDRSRV, DepthSRV, renderTarget);
            /*
            Int64 TStart = Program.HiTimer.Value;
            Int64 TStop = Program.HiTimer.Value;
            float Time = Program.HiTimer.Tick2Mili(TStop - TStart);
            Program.form.Text = Time.ToString();*/
        }