Beispiel #1
0
        public override void Draw(RenderComposer composer)
        {
            composer.SetUseViewMatrix(false);
            composer.RenderSprite(new Vector3(0, 0, 0), Engine.Renderer.CurrentTarget.Size, Color.CornflowerBlue);
            composer.SetUseViewMatrix(true);

            foreach (RopeSimConnection2D p in _connections)
            {
                composer.RenderLine((p.Start.Position + new Vector2(_circleRadius)).ToVec3(), (p.End.Position + new Vector2(_circleRadius)).ToVec3(), Color.White);
            }

            if (_dragging != null)
            {
                Vector2 worldMouse = Engine.Renderer.Camera.ScreenToWorld(Engine.Host.MousePosition);
                composer.RenderLine((_dragging.Position + new Vector2(_circleRadius)).ToVec3(), worldMouse.ToVec3(), Color.Red);
            }

            if (_draggingCut != Vector2.Zero)
            {
                Vector2 worldMouse = Engine.Renderer.Camera.ScreenToWorld(Engine.Host.MousePosition);
                composer.RenderLine(_draggingCut.ToVec3(), worldMouse.ToVec3(), Color.Red);
            }

            foreach (var p in _points)
            {
                composer.RenderCircle(p.Position.ToVec3(), _circleRadius, p.Locked ? Color.Magenta : Color.Black);
            }
        }
Beispiel #2
0
        protected override bool RenderInternal(RenderComposer c)
        {
            var open = true;

            ImGui.SetNextWindowPos(new Vector2(0, 20), ImGuiCond.Always);
            ImGui.SetNextWindowSize(new Vector2(c.CurrentTarget.Size.X, 20));
            ImGui.Begin(Title, ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);

            RenderImGui();

            RenderLayerUI(c);

            ImGui.End();

            Position = Vector3.Zero;
            Size     = c.CurrentTarget.Size;
            if (!open)
            {
                Parent?.RemoveChild(this);
                return(false);
            }

            EditorHelpers.RenderToolGrid(c, Position, Size, new Color(32, 32, 32), 20);

            Vector2 posVec2 = Position.ToVec2();

            c.RenderLine(posVec2 + new Vector2(Size.X / 2, 0), posVec2 + new Vector2(Size.X / 2, Size.Y), Color.White * 0.7f);
            c.RenderLine(posVec2 + new Vector2(0, Size.Y / 2), posVec2 + new Vector2(Size.X, Size.Y / 2), Color.White * 0.7f);

            c.SetUseViewMatrix(true);
            _map?.Render(c);
            c.SetUseViewMatrix(false);

            return(true);
        }
Beispiel #3
0
        public override void Draw(RenderComposer composer)
        {
            Color textCol = new Color(32, 32, 32);

            int    size = 20;
            string text = "The quick brown fox jumped over the lazy dog.";

            composer.SetUseViewMatrix(false);

            composer.RenderSprite(new Vector3(0, 0, 0), Engine.Renderer.CurrentTarget.Size, new Color(240, 240, 240));

            composer.PushModelMatrix(Matrix4x4.CreateScale(1, 1, 1) * Matrix4x4.CreateTranslation(100, 100, 0));

            FontAsset.GlyphRasterizer = GlyphRasterizer.Emotion;
            composer.RenderLine(new Vector3(0, 0, 0), new Vector3(500, 0, 0), Color.Red);
            composer.RenderString(new Vector3(0, 0, 0), textCol, "Emotion Renderer:\n" + text, _font.GetAtlas(size));

            FontAsset.GlyphRasterizer = GlyphRasterizer.EmotionSDFVer3;
            composer.RenderLine(new Vector3(0, 140, 0), new Vector3(500, 140, 0), Color.Red);
            composer.RenderString(new Vector3(0, 140, 0), textCol, "EmotionSDFVer3:\n" + text, _font.GetAtlas(size));

            FontAsset.GlyphRasterizer = GlyphRasterizer.EmotionSDFVer4;
            composer.RenderLine(new Vector3(0, 300, 0), new Vector3(500, 300, 0), Color.Red);
            composer.RenderString(new Vector3(0, 300, 0), textCol, "EmotionSDFVer4:\n" + text, _font.GetAtlas(size));

            FontAsset.GlyphRasterizer = GlyphRasterizer.StbTrueType;
            composer.RenderLine(new Vector3(0, 450, 0), new Vector3(500, 450, 0), Color.Red);
            composer.RenderString(new Vector3(0, 450, 0), textCol, "StbTrueType:\n" + text, _font.GetAtlas(size));

            composer.PopModelMatrix();

            composer.SetUseViewMatrix(true);
        }
Beispiel #4
0
        public void Draw(RenderComposer composer)
        {
            _rendered = 0;

            _drawMemory.Clear();
            var rect = new Rectangle(
                Engine.Renderer.Camera.ScreenToWorld(Vector2.Zero),
                Engine.Renderer.Camera.ScreenToWorld(Engine.Renderer.DrawBuffer.Size) * 2
                // Engine.Configuration.RenderSize * (Engine.Renderer.Scale - (Engine.Renderer.IntScale - 1)) / Engine.Renderer.Camera.Zoom
                );

            quadTree.GetObjects(rect, ref _drawMemory);
            composer.RenderOutline(new Vector3(rect.Position, 0f), rect.Size, Color.CornflowerBlue, 2);
            _rendered = _drawMemory.Count;

            Engine.Log.Info("\t" + "Mouse position \t" + Engine.Host.MousePosition, "TAAAG");
            // ReSharper disable once ForCanBeConvertedToForeach
            for (var i = 0; i < _drawMemory.Count; i++)
            {
                var tile = _drawMemory[i];

                var c = Color.White.ToUint();

                var a    = composer.GetBatch();
                var data = a.GetData(_tileTexture.Texture);
                data[0].Vertex = tile.Vertex0;
                data[0].Color  = c;
                data[0].UV     = Vector2.Zero;

                data[1].Vertex = tile.Vertex1;
                data[1].Color  = c;
                data[1].UV     = new Vector2(1, 0);

                data[2].Vertex = tile.Vertex2;
                data[2].Color  = c;
                data[2].UV     = new Vector2(1, 1);

                data[3].Vertex = tile.Vertex3;
                data[3].Color  = c;
                data[3].UV     = new Vector2(0, 1);
            }

            composer.SetDepthTest(false);
            composer.SetUseViewMatrix(false);
            composer.RenderLine(new Vector2(20, 20), new Vector2(20, 30), Color.Green, 2);
            composer.RenderLine(new Vector2(20, 20), new Vector2(30, 20), Color.Red, 2);
            composer.RenderLine(new Vector3(20, 20, 0), new Vector3(20, 20, 30), Color.Blue, 10);

            RenderGui(composer);
        }
        public void Render(RenderComposer c)
        {
            if (Track == null || _cache == null)
            {
                return;
            }

            for (var i = 1; i < _cache.Length; i++)
            {
                c.RenderLine(_cache[i - 1], _cache[i], Color.Red);
            }

            float progressLine = _cacheWidth * Track.Progress;

            c.RenderLine(new Vector2(progressLine, 0), new Vector2(progressLine, _cacheHeight), Color.Yellow);
        }
Beispiel #6
0
 public override void Render(RenderComposer composer)
 {
     foreach (Collision.LineSegment seg in Segments)
     {
         composer.RenderLine(new Vector3(seg.PointA, 6), new Vector3(seg.PointB, 6), Color.Pink, 2);
     }
 }
Beispiel #7
0
        public static void RenderToolGrid(RenderComposer c, Vector3 position, Vector2 size, Color background, int gridSize)
        {
            c.RenderSprite(position, size, background);

            Vector2 posVec2 = position.ToVec2();

            for (var x = 0; x < size.X; x += gridSize)
            {
                c.RenderLine(posVec2 + new Vector2(x, 0), posVec2 + new Vector2(x, size.Y), Color.White * 0.2f);
            }

            for (var y = 0; y < size.Y; y += gridSize)
            {
                c.RenderLine(posVec2 + new Vector2(0, y), posVec2 + new Vector2(size.X, y), Color.White * 0.2f);
            }
        }
Beispiel #8
0
        protected override bool RenderInternal(RenderComposer c)
        {
            if (!base.RenderInternal(c))
            {
                return(false);
            }

            c.SetClipRect(new Rectangle(Position, Size));
            EditorHelpers.RenderToolGrid(c, Position, Size, _calculatedColor, (int)Maths.RoundClosest(DebugGridSize * GetScale()));
            c.SetClipRect(null);

            Vector2 posVec2 = Position.ToVec2();

            c.RenderLine(posVec2 + new Vector2(Size.X / 2, 0), posVec2 + new Vector2(Size.X / 2, Size.Y), Color.White * 0.7f);
            c.RenderLine(posVec2 + new Vector2(0, Size.Y / 2), posVec2 + new Vector2(Size.X, Size.Y / 2), Color.White * 0.7f);
            return(true);
        }
Beispiel #9
0
        public void Render(RenderComposer c)
        {
            if (Track == null || _cache == null)
            {
                return;
            }

            c.RenderSprite(new Rectangle(0, 0, _cacheWidth, _cacheHeight), new Color(74, 74, 96));

            for (var i = 1; i < _cache.Length; i++)
            {
                c.RenderLine(_cache[i - 1], _cache[i], Color.Red);
            }

            float progressLine = _cacheWidth * Layer.Progress;

            c.RenderLine(new Vector2(progressLine, 0), new Vector2(progressLine, _cacheHeight), Color.Yellow);
        }
Beispiel #10
0
        protected override bool RenderInternal(RenderComposer c)
        {
            base.RenderInternal(c);

            RenderState oldState = c.CurrentState.Clone();

            c.SetState(RenderState.Default);
            c.SetUseViewMatrix(false);
            c.RenderSprite(new Vector3(0, 0, 0), Engine.Renderer.CurrentTarget.Size, Color.CornflowerBlue);
            c.SetUseViewMatrix(true);
            c.ClearDepth();

            //c.RenderLine(new Vector3(short.MinValue, 0, 0), new Vector3(short.MaxValue, 0, 0), Color.Red, snapToPixel: false);
            //c.RenderLine(new Vector3(0, short.MinValue, 0), new Vector3(0, short.MaxValue, 0), Color.Green, snapToPixel: false);
            //c.RenderLine(new Vector3(0, 0, short.MinValue), new Vector3(0, 0, short.MaxValue), Color.Blue, snapToPixel: false);

            c.RenderLine(new Vector3(0, 0, 0), new Vector3(short.MaxValue, 0, 0), Color.Red, snapToPixel: false);
            c.RenderLine(new Vector3(0, 0, 0), new Vector3(0, short.MaxValue, 0), Color.Green, snapToPixel: false);
            c.RenderLine(new Vector3(0, 0, 0), new Vector3(0, 0, short.MaxValue), Color.Blue, snapToPixel: false);

            if (_showTerrain)
            {
                _terrain.Render(c);
            }

            if (DisplayObject.Entity?.AnimationRig != null)
            {
                c.SetShader(_skeletalShader.Shader);
                DisplayObject.RenderAnimated(c, _boneVerticesStream);
                c.SetShader();
            }
            else
            {
                DisplayObject.Render(c);
            }

            c.SetState(oldState);

            _boneVerticesStream?.DoTasks(c);

            return(true);
        }
Beispiel #11
0
        public void Draw(RenderComposer composer)
        {
            // Draw X and Y Axes for easier visual orientation
            composer.RenderLine(new Vector2(-800, 0), new Vector2(800, 0), Color.White, 0.5f);
            composer.RenderLine(new Vector2(0, -800), new Vector2(0, 800), Color.White, 0.5f);

            var ray     = new Ray2D(_rayStart, _rayDirection, 1000f);
            var barrier = new Line(_barrierStart, _barrierEnd);

            composer.RenderLine(ray.Start, ray.End, Color.Green);

            var color = Util.Util.Intersects(ray, barrier, out _crossPoint) ? Color.Red : Color.CornflowerBlue;

            composer.RenderLine(_barrierStart, _barrierEnd, color);

            if (_crossPoint != null)
            {
                composer.RenderSprite(new Vector3(_crossPoint.Value.X - 1, _crossPoint.Value.Y - 1, 5), new Vector2(2f), Color.Magenta);
            }


            DrawGui(composer);
        }
Beispiel #12
0
        protected override bool RenderInternal(RenderComposer c)
        {
            base.RenderInternal(c);

            bool focused = IsWithin(Controller?.InputFocus);

            if (focused && _cursorOn)
            {
                Vector2 cursorDrawStart = _layouter.GetPenLocation() + new Vector2(_scaledCursorDistance, 0);
                var     top             = new Vector3(X + cursorDrawStart.X, Y + cursorDrawStart.Y, Z);
                var     bottom          = new Vector3(X + cursorDrawStart.X, Y + cursorDrawStart.Y + _atlas.FontHeight, Z);

                c.RenderLine(top, bottom, _calculatedColor);
            }

            return(true);
        }
Beispiel #13
0
        private void RenderAnimationPreview(RenderComposer c)
        {
            AnimatedSprite             currentFileContext = _currentAsset !.Content !;
            SpriteAnimationFrameSource frameSource        = currentFileContext.FrameSource;

            if (_animatedPreviewInvalidated)
            {
                var size = new Vector2();
                for (var i = 0; i < frameSource.GetFrameCount(); i++)
                {
                    Rectangle frameUV = frameSource.GetFrameUV(i);

                    size.X = MathF.Max(size.X, frameUV.Width);
                    size.Y = MathF.Max(size.Y, frameUV.Height);
                }

                if (size.X > size.Y)
                {
                    size.Y = size.X;
                }
                else if (size.Y > size.X)
                {
                    size.X = size.Y;
                }

                size *= 2;

                GLThread.ExecuteGLThreadAsync(() =>
                {
                    if (_animatedPreviewFb == null)
                    {
                        _animatedPreviewFb = new FrameBuffer(size).WithColor();
                    }
                    else
                    {
                        _animatedPreviewFb.Resize(size, true);
                    }
                });

                _animatedPreviewInvalidated = false;
            }

            if (_animatedPreviewFb != null)
            {
                c.RenderToAndClear(_animatedPreviewFb);

                Vector2 size = _animatedPreviewFb.Size;
                c.RenderSprite(Vector3.Zero, size, new Color(32, 32, 32));
                c.RenderLine(new Vector2(0, size.Y / 2), new Vector2(size.X, size.Y / 2), Color.White * 0.2f);
                c.RenderLine(new Vector2(size.X / 2, 0), new Vector2(size.X / 2, size.Y), Color.White * 0.2f);

                if (_animatedPreviewAnchorMode)
                {
                    // Draw a shadow of the previous frame.
                    if (_frameAnchor != 0)
                    {
                        _controller.GetRenderDataForFrame(_frameAnchor - 1, out Vector3 renderPosSh, out Texture textureSh, out Rectangle uvSh);
                        renderPosSh = renderPosSh.RoundClosest();
                        c.RenderSprite((size / 2f).RoundClosest().ToVec3() + renderPosSh, uvSh.Size, Color.White * 0.3f, textureSh, uvSh);
                    }

                    _controller.GetRenderDataForFrame(_frameAnchor, out Vector3 renderPos, out Texture texture, out Rectangle uv);
                    renderPos = renderPos.RoundClosest();
                    c.RenderSprite((size / 2f).RoundClosest().ToVec3() + renderPos, uv.Size, Color.White, texture, uv);
                }
                else
                {
                    _controller.GetRenderData(out Vector3 renderPos, out Texture texture, out Rectangle uv);
                    renderPos = renderPos.RoundClosest();
                    c.RenderSprite((size / 2f).RoundClosest().ToVec3() + renderPos, uv.Size, Color.White, texture, uv);
                }

                c.RenderTo(null);
            }
        }
Beispiel #14
0
        protected override void RenderContent(RenderComposer composer)
        {
            List <Collision.CollisionDebugData> lastCollision = Collision.LastCollision;

            if (SelectedCollision > lastCollision.Count - 1 || SelectedCollision < 0)
            {
                SelectedCollision = 0;
            }

            composer.SetUseViewMatrix(true);

            int bestWeightInClusterIdx = -1;
            var bestWeight             = float.MinValue;

            for (var i = 0; i < lastCollision.Count; i++)
            {
                Collision.CollisionDebugData current = lastCollision[i];
                if (current == null)
                {
                    if (bestWeightInClusterIdx != -1)
                    {
                        ImGui.Text($"    Best: {bestWeightInClusterIdx}");
                    }
                    bestWeightInClusterIdx = -1;
                    bestWeight             = int.MinValue;

                    ImGui.NewLine();
                    continue;
                }

                if (current.Weight > bestWeight)
                {
                    bestWeightInClusterIdx = i;
                    bestWeight             = current.Weight;
                }

                if (SelectedCollision == i)
                {
                    ImGui.Text($"Collision {i}");

                    composer.RenderLine(ref current.Line, Color.Red);
                    Vector2 middleOfLine = current.Line.PointOnLineAtDistance(current.Line.Length() / 2);
                    composer.RenderLine(current.Line.Start, current.Line.Start + current.LineNormal * 10f, Color.Yellow);
                    composer.RenderLine(middleOfLine, middleOfLine + current.LineNormal * 10f, Color.Yellow);
                    composer.RenderLine(current.Line.End, current.Line.End + current.LineNormal * 10f, Color.Yellow);
                }
                else
                {
                    if (ImGui.Button($"Collision  {i}"))
                    {
                        SelectedCollision = i;
                    }
                }
            }

            if (bestWeightInClusterIdx != -1)
            {
                ImGui.Text($"    Best: {bestWeightInClusterIdx}");
            }

            composer.SetUseViewMatrix(false);

            if (lastCollision.Count == 0)
            {
                return;
            }
            Collision.CollisionDebugData selected = lastCollision[SelectedCollision];
            if (selected == null)
            {
                return;
            }

            ImGui.NewLine();
            ImGui.Text($"Surface {selected.Line.GetHashCode()} {selected.Line.Start}-{selected.Line.End}");
            ImGui.Text($"Weight {selected.Weight}");
            ImGui.Text($"Movement {selected.Movement}");
            ImGui.Text(selected.CollisionType);
        }
 public void Render(RenderComposer composer)
 {
     composer.RenderLine(new Vector3(PointA, 6), new Vector3(PointB, 6), Color.Red, 2);
 }
        public void Draw(RenderComposer composer)
        {
            foreach (Decoration bg in Backgrounds)
            {
                bg.Render(composer);
            }

            foreach (Decoration dec in BackgroundDecorations)
            {
                if (IsTransformOnSreen(dec))
                {
                    dec.Render(composer);
                }
            }

            foreach (Unit unit in Units)
            {
                if (IsTransformOnSreen(unit))
                {
                    unit.Render(composer);
                }
            }

            foreach (Collision.LineSegment plat in CollisionPlatforms)
            {
                plat.Render(composer);
            }

            // Draw Magic Flows
            foreach (MagicFlow mf in MagicFlows)
            {
                mf.Render(composer);
            }

            // Render Scene Changers
            for (int i = 0; i < SceneChangers.Count; i++)
            {
                SceneChangers[i].Render(composer);
            }

            // Render the player
            Player.Render(composer);

            foreach (Decoration dec in ForegroundDecorations)
            {
                if (IsTransformOnSreen(dec))
                {
                    dec.Render(composer);
                }
            }

            // Draw the room ceiling
            composer.RenderLine(new Vector3(0, 0, 15), new Vector3(LoadedRoom.Size.X, 0, 6), Color.Cyan, 1);

            // Draw camera position (probably the center of the screen)
            composer.RenderCircle(Engine.Renderer.Camera.Position, 1, Color.Cyan);

            // Display the current interaction
            if (CurrentInteration != null)
            {
                CurrentInteration.Render(composer);
            }

            // Draw DebugObjects' CollisionBoxes
            for (int i = 0; i < DebugObjects.Count; i++)
            {
                DebugObject debugObj = DebugObjects[i];
                debugObj.RenderObjectRectange(composer);
            }

            // Disabled the camera and draw on Screen Space instead of World Space
            composer.SetUseViewMatrix(false);

            // Draw DebugObjects
            for (int i = 0; i < DebugObjects.Count; i++)
            {
                DebugObject  debugObj             = DebugObjects[i];
                int          fontSize             = 18;
                float        debugObjDisplayWidth = debugObj.LongestLine.Length * 8; // Magic number
                TextureAsset textureAsset         = Engine.AssetLoader.Get <TextureAsset>("Textures/better-transparent-black.png");
                composer.RenderSprite(
                    new Vector3(debugObjDisplayWidth * i, 0, 15),
                    new Vector2(debugObjDisplayWidth, Engine.Configuration.RenderSize.Y),
                    Color.White,
                    textureAsset.Texture
                    );
                composer.RenderString(
                    new Vector3(debugObjDisplayWidth * i, 0, 15),
                    Color.Red,
                    debugObj.ToString(),
                    Engine.AssetLoader.Get <FontAsset>("Fonts/Calibri 400.ttf").GetAtlas(fontSize)
                    );
            }

            // Draw circle on mouse pointer
            composer.RenderCircle(new Vector3(Engine.InputManager.MousePosition, 15), 3, Color.Red, true);
            // Draw mouse coordinates
            composer.RenderString(
                new Vector3(20, Engine.Configuration.RenderSize.Y - 80, 15),
                Color.Red,
                Engine.InputManager.MousePosition.ToString(),
                Engine.AssetLoader.Get <FontAsset>("Fonts/Calibri 400.ttf").GetAtlas(18)
                );


            // Enable the camera again
            composer.SetUseViewMatrix(true);

            // Render the Emotion Tools UI
            //composer.RenderToolsMenu();
        }
Beispiel #17
0
        public void LineDrawing()
        {
            Runner.ExecuteAsLoop(_ =>
            {
                RenderComposer composer = Engine.Renderer.StartFrame();

                composer.PushModelMatrix(Matrix4x4.CreateTranslation(200, 200, 0));

                // Diagonal Lines
                composer.RenderLine(new Vector3(10, 10, 0), new Vector3(50, 50, 0), Color.White);
                composer.RenderLine(new Vector3(50, 50, 0), new Vector3(100, 100, 0), Color.White, 2);
                composer.RenderLine(new Vector3(100, 100, 0), new Vector3(150, 150, 0), Color.White, 3);

                // Horizontal lines
                // 100 pixels long
                composer.RenderLine(new Vector3(100, 10, 0), new Vector3(200, 10, 0), Color.White);
                composer.RenderLine(new Vector3(100, 20, 0), new Vector3(200, 20, 0), Color.White, 2);
                composer.RenderLine(new Vector3(100, 30, 0), new Vector3(200, 30, 0), Color.White, 3);
                composer.RenderLine(new Vector3(100, 40, 0), new Vector3(200, 40, 0), Color.White, 4);

                // Vertical
                // 100 pixels high
                composer.RenderLine(new Vector3(10, 100, 0), new Vector3(10, 200, 0), Color.White);
                composer.RenderLine(new Vector3(20, 100, 0), new Vector3(20, 200, 0), Color.White, 2);
                composer.RenderLine(new Vector3(30, 100, 0), new Vector3(30, 200, 0), Color.White, 3);
                composer.RenderLine(new Vector3(40, 100, 0), new Vector3(40, 200, 0), Color.White, 4);

                // Test lines in all 2d directions. Z would only be visible with a 3d. camera.
                composer.RenderArrow(new Vector3(0, 0, 0), new Vector3(10, 0, 0), Color.Red);
                composer.RenderArrow(new Vector3(0, 0, 0), new Vector3(0, 10, 0), Color.Green);
                composer.RenderArrow(new Vector3(0, 0, 0), new Vector3(0, 0, 10), Color.Blue);

                // Lines must be at least 1 pixel thick.
                composer.RenderArrow(new Vector3(10, 0, 0), new Vector3(100, 0, 0), Color.Red, 0.1f);
                composer.RenderArrow(new Vector3(0, 10, 0), new Vector3(0, 100, 0), Color.Green, 0.1f);
                composer.RenderArrow(new Vector3(0, 0, 10), new Vector3(0, 0, 100), Color.Blue, 0.1f);

                composer.PopModelMatrix();
                Engine.Renderer.EndFrame();

                Runner.VerifyScreenshot(ResultDb.LineDrawing);
            }).WaitOne();
        }