Пример #1
0
        public void Draw3D()
        {
            if (!ShowingScratchText)
            {
                GraphicsDevice graphics = ScreenManager.Globals.Graphics;

                ScreenManager.Globals.DefaultEffect.VertexColorEnabled = true;
                alphaTester.Projection     = ScreenManager.Globals.DefaultEffect.Projection;
                alphaTester.View           = ScreenManager.Globals.DefaultEffect.View;
                graphics.DepthStencilState = DepthStencilState.Default;

                BlendState newBlendState = new BlendState();
                newBlendState.ColorSourceBlend      = Blend.SourceAlpha;
                newBlendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
                graphics.BlendState = newBlendState;

                RasterizerState newRasterizer = new RasterizerState();
                newRasterizer.CullMode   = CullMode.None;
                graphics.RasterizerState = newRasterizer;
                //ScreenManager.Globals.Graphics.BlendState.ColorSourceBlend = Blend.SourceAlpha;
                //ScreenManager.Globals.Graphics.BlendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
                //ScreenManager.Globals.Graphics.RasterizerState.CullMode = CullMode.None;

                #region Sorting


                depthDrawList.Clear();
                paintersDrawList.Clear();

                foreach (var keyValue in currentSession.Worlds)
                {
                    depthDrawList.AddRange(keyValue.Value.GetDrawables(ScreenManager.Globals.Camera));
                }
                //depthDrawList.Add(new DrawListItem(ScreenManager.Globals.Camera, cursor));
                foreach (GenericMeteor meteor in genericMeteors)
                {
                    depthDrawList.Add(new DrawListItem(ScreenManager.Globals.Camera, meteor));
                }

                if (focused && cursorTarget.Name == "Skaia")
                {
                    depthDrawList.Add(new DrawListItem(ScreenManager.Globals.Camera, ((Skaia)currentSession.Worlds["Skaia"]).Battlefield));
                }

                paintersDrawList.AddRange(depthDrawList);

                if (!ScreenManager.IsMouseVisible)
                {
                    depthDrawList.Add(new DrawListItem(ScreenManager.Globals.Camera, cursor));
                }


                depthDrawList.Sort(DrawListItem.DepthCompare);
                paintersDrawList.Sort(DrawListItem.DistanceCompare);

                #endregion
                graphics.DepthStencilState = DepthStencilState.DepthRead;
                foreach (DrawListItem item in paintersDrawList)
                {
                    item.ListItem.Draw(alphaTester, graphics);
                }
                innerRim.Draw(alphaTester, graphics);
                outerRim.Draw(alphaTester, graphics);

                DepthStencilState newDepthState = new DepthStencilState();
                newDepthState.DepthBufferEnable = true;
                //newDepthState.DepthBufferFunction = CompareFunction.Greater;
                newDepthState.DepthBufferWriteEnable = true;
                graphics.DepthStencilState           = newDepthState;
                innerRim.Draw(alphaTester, graphics);
                outerRim.Draw(alphaTester, graphics);
                foreach (DrawListItem item in depthDrawList)
                {
                    if (item.ListItem is Spirograph)
                    {
                        item.ListItem.Draw(ScreenManager.Globals.DefaultEffect, graphics);
                    }
                    else
                    {
                        item.ListItem.Draw(alphaTester, graphics);
                    }
                }
            }
        }
Пример #2
0
 public virtual void Draw(Effect effect, GraphicsDevice graphics)
 {
     plane.Draw(effect, graphics);
 }