示例#1
0
文件: World.cs 项目: barronds/XNARTS
        public void RenderWorldLines_Static()
        {
            XSimpleDraw simple_draw_world = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Persistent_Map);

            Vector3 start = new Vector3();
            Vector3 end   = new Vector3();
            Color   k_transparent_black = new Color(0.0f, 0.0f, 0.0f, 0.05f);

            // each cell is 1 unit on edge in world space
            start.Y = 0;
            end.Y   = mMap.mBounds.y;

            for (int x = 0; x <= mMap.mBounds.x; ++x)
            {
                start.X = x;
                end.X   = x;

                simple_draw_world.DrawLine(start, end, k_transparent_black);
            }

            start.X = 0;
            end.X   = mMap.mBounds.x;

            for (int y = 0; y <= mMap.mBounds.y; ++y)
            {
                start.Y = y;
                end.Y   = y;

                simple_draw_world.DrawLine(start, end, k_transparent_black);
            }
        }
示例#2
0
        public void Util_DrawBox(XSimpleDraw simple_draw, Style style, xAABB2 screen_aabb)
        {
            Vector3 lo_x_lo_y = new Vector3(screen_aabb.GetMin(), 0);
            Vector3 hi_x_hi_y = new Vector3(screen_aabb.GetMax(), 0);

            Vector2 size      = screen_aabb.GetSize();
            Vector3 lo_x_hi_y = lo_x_lo_y + new Vector3(0, size.Y, 0);
            Vector3 hi_x_lo_y = lo_x_lo_y + new Vector3(size.X, 0, 0);

            simple_draw.DrawQuad(lo_x_lo_y, hi_x_hi_y, style.mBackgroundColor);

            simple_draw.DrawLine(lo_x_lo_y, hi_x_lo_y, style.mBorderColor);
            simple_draw.DrawLine(hi_x_lo_y, hi_x_hi_y, style.mBorderColor);
            simple_draw.DrawLine(hi_x_hi_y, lo_x_hi_y, style.mBorderColor);
            simple_draw.DrawLine(lo_x_hi_y, lo_x_lo_y, style.mBorderColor);
        }
示例#3
0
            void _IButton.Draw(XSimpleDraw simple_draw)
            {
                // draw border and background, then draw core
                Vector3 lo = new Vector3(mAABB.GetMin(), 2);                   // zero might not be right z
                Vector3 hi = new Vector3(mAABB.GetMax(), 2);

                Color body_color   = mButtonCore.mPressed ? mButtonCore.mPressedColor : mButtonCore.mStyle.mBackgroundColor;
                Color border_color = mButtonCore.mStyle.mBorderColor;

                simple_draw.DrawQuad(lo, hi, body_color);

                simple_draw.DrawLine(lo, mCorner2, border_color);
                simple_draw.DrawLine(mCorner2, hi, border_color);
                simple_draw.DrawLine(hi, mCorner3, border_color);
                simple_draw.DrawLine(mCorner3, lo, border_color);

                mButtonCore.Draw(simple_draw);
            }
示例#4
0
文件: World.cs 项目: barronds/XNARTS
        public void RenderWorldLines_Dynamic(xAABB2 view_aabb)
        {
            XSimpleDraw simple_draw_world = XSimpleDraw.Instance(xeSimpleDrawType.WorldSpace_Transient);

            // calculate color to use based on how much world is being drawn
            const float k_large_view_size = 200;
            const float k_small_view_size = 5;
            float       view_width        = view_aabb.GetMax().X - view_aabb.GetMin().X;
            float       lightness         = view_width > k_large_view_size ? 1.0f :
                                            view_width < k_small_view_size ? 0.0f :
                                            (view_width - k_small_view_size) / (k_large_view_size - k_small_view_size);

            lightness = XMath.Sqrt(lightness);

            Color k_lightest_color = new Color(0.0f, 0.0f, 0.0f, 0.025f);
            Color k_darkest_color  = new Color(0.0f, 0.0f, 0.0f, 0.33f);
            Color result_color     = Color.Lerp(k_darkest_color, k_lightest_color, lightness);

            // each cell is 1 unit on edge in world space
            Vector3 start = new Vector3();
            Vector3 end   = new Vector3();

            start.Y = 0;
            end.Y   = mMap.mBounds.y;

            for (int x = 0; x <= mMap.mBounds.x; ++x)
            {
                start.X = x;
                end.X   = x;

                simple_draw_world.DrawLine(start, end, result_color);
            }

            start.X = 0;
            end.X   = mMap.mBounds.x;

            for (int y = 0; y <= mMap.mBounds.y; ++y)
            {
                start.Y = y;
                end.Y   = y;

                simple_draw_world.DrawLine(start, end, result_color);
            }
        }
示例#5
0
            void _ISelector.Draw(XSimpleDraw simple_draw)
            {
                if (mRenderEnabled)
                {
                    // draw the title and background, buttons will draw themselves
                    Style style        = XUI.Instance().GetStyle(mStyle);
                    Color widget_color = style.mBackgroundColor;
                    Color border_color = style.mBorderColor;

                    Vector3 lo_x_lo_y = new Vector3(mAABB.GetMin(), 1);
                    Vector3 hi_x_hi_y = new Vector3(mAABB.GetMax(), 1);

                    Vector2 size      = mAABB.GetSize();
                    Vector3 lo_x_hi_y = lo_x_lo_y + new Vector3(0, size.Y, 0);
                    Vector3 hi_x_lo_y = lo_x_lo_y + new Vector3(size.X, 0, 0);

                    simple_draw.DrawQuad(lo_x_lo_y, hi_x_hi_y, widget_color);

                    simple_draw.DrawLine(lo_x_lo_y, hi_x_lo_y, border_color);
                    simple_draw.DrawLine(hi_x_lo_y, hi_x_hi_y, border_color);
                    simple_draw.DrawLine(hi_x_hi_y, lo_x_hi_y, border_color);
                    simple_draw.DrawLine(lo_x_hi_y, lo_x_lo_y, border_color);
                }
            }