Esempio n. 1
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);
        }
Esempio n. 2
0
        public void TestDepthFromOtherFrameBuffer()
        {
            Runner.ExecuteAsLoop(_ =>
            {
                FrameBuffer testBuffer = new FrameBuffer(Engine.Renderer.DrawBuffer.Size).WithColor().WithDepth(true);
                var shader             = Engine.AssetLoader.Get <ShaderAsset>("Shaders/DepthTest.xml");

                RenderComposer composer = Engine.Renderer.StartFrame();
                composer.RenderTo(testBuffer);
                composer.ClearFrameBuffer();
                composer.RenderSprite(new Vector3(0, 0, 10), new Vector2(100, 100), Color.Green);
                composer.RenderTo(null);

                composer.SetUseViewMatrix(false);
                composer.SetShader(shader.Shader);
                shader.Shader.SetUniformInt("depthTexture", 1);
                Texture.EnsureBound(testBuffer.DepthTexture.Pointer, 1);
                composer.RenderSprite(new Vector3(0, 0, 0), testBuffer.Texture.Size, Color.White, testBuffer.Texture);
                composer.SetShader();
                composer.SetUseViewMatrix(true);

                composer.RenderSprite(new Vector3(20, 20, 15), new Vector2(100, 100), Color.Blue);
                composer.RenderSprite(new Vector3(10, 10, 0), new Vector2(100, 100), Color.Red);

                Engine.Renderer.EndFrame();
                Runner.VerifyScreenshot(ResultDb.TestDepthFromOtherFrameBuffer);

                testBuffer.Dispose();
            }).WaitOne();
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public void Draw(RenderComposer composer)
        {
            composer.RenderToAndClear(_fbo);
            composer.SetUseViewMatrix(false);
            composer.RenderSprite(new Vector3(0, 0, 0), new Vector2(100, 100), new Color(_currentRedValue, (byte)50, (byte)50));
            composer.RenderTo(null);
            composer.SetUseViewMatrix(true);
            composer.RenderSprite(new Vector3(10, -50, 0), new Vector2(100, 100), new Color(_currentRedValue, (byte)50, (byte)50));

            if (_asyncSample)
            {
                if (_sampleReq == null || _sampleReq.Finished)
                {
                    if (_sampleReq != null && _sampleReq.Finished)
                    {
                        _lastColorResult = new Color(_sampleReq.Data[0], _sampleReq.Data[1], _sampleReq.Data[2], _sampleReq.Data[3]);
                    }
                    _sampleReq = _fbo.SampleAsync(new Rectangle(0, 0, 1, 1), OpenGL.PixelFormat.Rgba);
                }
            }
            else
            {
                byte[] sampleReq = _fbo.Sample(new Rectangle(0, 0, 1, 1), OpenGL.PixelFormat.Rgba);
                _lastColorResult = new Color(sampleReq[0], sampleReq[1], sampleReq[2], sampleReq[3]);
            }

            composer.RenderSprite(new Vector3(-100, -50, 10), new Vector2(100, 100), _lastColorResult);
        }
Esempio n. 6
0
        protected override void RenderContent(RenderComposer composer)
        {
            if (ImGui.Button("Choose File"))
            {
                var explorer = new FileExplorer <TextAsset>(LoadFile);
                Parent.AddWindow(explorer);
            }

            ImGui.Text($"Current File: {_file?.Name ?? "None"}");
            if (_file == null)
            {
                return;
            }
            if (ImGui.Button("Reload"))
            {
                LoadFile(FileExplorer <TextAsset> .ExplorerLoadAsset(_file.Name));
            }

            ImGui.Text("Tile Layers");
            for (var i = 0; i < _map.TiledMap.TileLayers.Count; i++)
            {
                TmxLayer curLayer = _map.TiledMap.TileLayers[i];
                ImGui.Text($"{curLayer.Name} {curLayer.Width}x{curLayer.Height}" + (curLayer.Visible ? "" : " Hidden"));
            }

            composer.SetUseViewMatrix(true);
            composer.Render(_map);
        }
Esempio n. 7
0
        protected override bool RenderInternal(RenderComposer c)
        {
            c.SetUseViewMatrix(false);
            c.RenderSprite(Vector3.Zero, c.CurrentTarget.Size, Color.CornflowerBlue);

            base.RenderInternal(c);
            _ui.Render(c);
            return(true);
        }
Esempio n. 8
0
        public void Draw(RenderComposer composer)
        {
            composer.SetUseViewMatrix(false);

            composer.RenderOutline(_boundingRect, Color.White);

            for (int i = 0; i < _rects.Length; i++)
            {
                if (i > _showing)
                {
                    break;
                }

                var col = (uint)_rects[i].GetHashCode();
                composer.RenderSprite(_rects[i], new Color(col).SetAlpha(255));
            }

            composer.SetUseViewMatrix(true);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        private void RenderGui(RenderComposer composer)
        {
            composer.SetUseViewMatrix(false);
            composer.SetDepthTest(false);

            ImGui.NewFrame();
            ImGui.Begin("InfoBox", ImGuiWindowFlags.AlwaysAutoResize);
            ImGui.Text("Camera " + Engine.Renderer.Camera.Position + " | @z: " + Engine.Renderer.Camera.Zoom);
            ImGui.Text("RenderTileCount [" + _rendered + "]");
            ImGui.End();

            composer.RenderToolsMenu(_menu);
            _menu.Render(composer);

            composer.RenderUI();
        }
Esempio n. 12
0
        public static void RenderToolsMenu(this RenderComposer composer)
        {
            if (ToolsWindowManager == null)
            {
                ToolsWindowManager = new WindowManager();
            }

            composer.SetDepthTest(false);
            composer.SetUseViewMatrix(false);

            ToolsWindowManager.Update();

            ImGui.NewFrame();
            RenderToolsMenu(composer, ToolsWindowManager);
            ToolsWindowManager.Render(composer);
            composer.RenderUI();
        }
Esempio n. 13
0
        public void TestFullScale()
        {
            Runner.ExecuteAsLoop(_ =>
            {
                Engine.Renderer.Camera = new PixelArtCamera(Vector3.Zero);
                Engine.Host.Size       = new Vector2(600, 600);
                DesktopTest.EventualConsistencyHostWait();

                RenderComposer composer = Engine.Renderer.StartFrame();
                composer.SetUseViewMatrix(true);
                composer.RenderSprite(new Vector3(_backgroundSize * -1, 0), _backgroundSize, Color.Black);
                composer.RenderSprite(new Vector3(0, 0, 0), _backgroundSize, Color.CornflowerBlue);
                composer.RenderSprite(new Vector3(0, 0, 0), new Vector2(10, 10), Color.Red);
                composer.RenderSprite(new Vector3(_backgroundSize - new Vector2(10, 10), 0), new Vector2(10, 10), Color.Red);
                Engine.Renderer.EndFrame();

                Runner.VerifyScreenshot(ResultDb.TestFullScale);
            }).WaitOne();
        }
Esempio n. 14
0
 public void Draw(RenderComposer composer)
 {
     composer.SetUseViewMatrix(false);
     composer.RenderSprite(new Vector3(0, 0, 0), Engine.Renderer.CurrentTarget.Size, Color.CornflowerBlue);
     composer.RenderToolsMenu();
 }
Esempio n. 15
0
        public void Render(RenderComposer composer)
        {
            // Disabled the camera and draw on Screen Space instead of World Space
            composer.SetUseViewMatrix(false);
            composer.RenderSprite(
                new Vector3(Vector2.Zero, BackgroundZ),
                new Vector2(1920, 1080),
                Color.White,
                Texture.Texture
                );

            Vector3 Unit1Position;

            if (Unit1OnTheLeft)
            {
                Unit1Position = LeftPosition + new Vector3(Unit1.InteractionOffset, 0);
            }
            else
            {
                Unit1Position = RightPosition + new Vector3(Unit1.InteractionOffset.X * -1, Unit1.InteractionOffset.Y, 0);
            }
            composer.RenderSprite(
                Unit1Position,
                Unit1.PortraitSize,
                Color.White,
                Unit1.TextureAsset.Texture,
                null,
                Unit1OnTheLeft
                );

            Vector3 Unit2Position;

            if (Unit1OnTheLeft)
            {
                Unit2Position = RightPosition + new Vector3(Unit2.InteractionOffset.X * -1, Unit2.InteractionOffset.Y, 0);
            }
            else
            {
                Unit2Position = LeftPosition + new Vector3(Unit2.InteractionOffset, 0);
            }
            composer.RenderSprite(
                Unit2Position,
                Unit2.PortraitSize,
                Color.White,
                Unit2.TextureAsset.Texture,
                null,
                !Unit1OnTheLeft
                );

            if (Unit2.Dialogues != null)
            {
                if (CurrentLetterIndex >= Unit2.Dialogues[0].DialogueLines[0].Length)
                {
                    // Set whenever the user initiates the next line
                    //CurrentLetterIndex = 0;
                    //LastLetterFrame = CurrentFrame;
                    Finished = true;

                    composer.RenderString(
                        new Vector3(760, 900, 12), // 200px left of the center
                        Color.Green,
                        Unit2.Dialogues[0].DialogueLines[0],
                        Font.GetAtlas(FontSize)
                        );
                }
                else
                {
                    composer.RenderString(
                        new Vector3(760, 900, 12),   // 200px left of the center
                        Color.Green,
                        Unit2.Dialogues[0].DialogueLines[0].Substring(0, CurrentLetterIndex + 1),
                        Font.GetAtlas(FontSize)
                        );
                }
            }
        }
Esempio n. 16
0
        protected override bool RenderInternal(RenderComposer c)
        {
            c.SetUseViewMatrix(false);
            c.SetDepthTest(false);

            ImGui.NewFrame();
            ImGui.BeginMainMenuBar();
            GetImGuiMetrics();

            ImGuiIOPtr io = ImGui.GetIO();

            _captureMouse    = io.WantCaptureMouse;
            _captureKeyboard = io.WantCaptureKeyboard;
            _captureText     = io.WantTextInput;

            var fullScreenEditorOpen = false;

            if (Children != null)
            {
                for (var i = 0; i < Children.Count; i++)
                {
                    UIBaseWindow child = Children[i];
                    if (child.Size == c.CurrentTarget.Size)
                    {
                        // todo: maybe something more explicit, like a bool in ImGuiWindow?
                        fullScreenEditorOpen = true;
                    }
                }
            }
            InputTransparent = !_captureMouse && !_captureKeyboard && !fullScreenEditorOpen;

            if (ImGui.BeginMenu("Audio"))
            {
                if (ImGui.MenuItem("Audio Preview"))
                {
                    AddLegacyWindow(new AudioMixer());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Art"))
            {
                if (ImGui.MenuItem("Animation Editor"))
                {
                    AddLegacyWindow(new AnimationEditor());
                }
                if (ImGui.MenuItem("Animation Editor New (WIP)"))
                {
                    AddChild(new Animation2DEditor());
                }
                if (ImGui.MenuItem("Rogue Alpha Remover"))
                {
                    AddLegacyWindow(new RogueAlphaRemoval());
                }
                if (ImGui.MenuItem("Palette Editor"))
                {
                    AddLegacyWindow(new PaletteEditor());
                }
                if (ImGui.MenuItem("Font Preview"))
                {
                    AddLegacyWindow(new FontPreview());
                }
                if (ImGui.MenuItem("PNG Exporter"))
                {
                    AddLegacyWindow(new PngExporter());
                }
                if (ImGui.MenuItem("3D Object Viewer"))
                {
                    AddChild(new Viewer3D());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Gameplay"))
            {
                if (ImGui.MenuItem("Map Editor"))
                {
                    AddChild(new MapEditor());
                }
                if (ImGui.MenuItem("Tmx Viewer"))
                {
                    AddChild(new TmxViewer());
                }
#if DEBUG
                if (ImGui.MenuItem("Collision Viewer"))
                {
                    AddLegacyWindow(new CollisionViewer());
                }
#else
                ImGui.MenuItem("Collision Viewer [Requires DEBUG]");
#endif
                if (ImGui.MenuItem("UI Editor"))
                {
                    AddChild(new UIEditorWindow());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Engine"))
            {
                if (ImGui.MenuItem("Performance Monitor"))
                {
                    AddChild(new PerformanceMonitor());
                }
                if (ImGui.MenuItem("Memory Viewer"))
                {
                    AddLegacyWindow(new MemoryViewer());
                }
#if DEBUG
                if (ImGui.MenuItem("Coroutine Viewer"))
                {
                    AddLegacyWindow(new CoroutineViewer());
                }
#else
                ImGui.MenuItem("Coroutine Viewer [Requires DEBUG]");
#endif
                if (ImGui.MenuItem("Gpu Texture Viewer"))
                {
                    AddLegacyWindow(new GpuTextureViewer());
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Game"))
            {
                if (ImGui.MenuItem("Open Folder"))
                {
                    Process.Start("explorer.exe", ".");
                }

                foreach (KeyValuePair <string, Action <UIBaseWindow> > tool in ToolsManager.CustomToolsFactory)
                {
                    if (ImGui.MenuItem(tool.Key))
                    {
                        tool.Value(this);
                    }
                }

                ImGui.EndMenu();
            }

            ImGui.EndMainMenuBar();

            LegacyWindowManager.Update();
            LegacyWindowManager.Render(c);
            if (Children == null)
            {
                AfterRenderChildren(c);
            }
            return(true);
        }
Esempio n. 17
0
 public void Draw(RenderComposer composer)
 {
     composer.SetUseViewMatrix(false);
     composer.RenderString(Vector3.Zero, Color.White, "Connecting...", _font.GetAtlas(30));
     composer.SetUseViewMatrix(true);
 }
Esempio n. 18
0
        public void RenderStreamMultiPrimitiveBatching()
        {
            var drawVariants = new List <Action <RenderComposer, Vector3> >
            {
                // Quads
                (c, loc) =>
                {
                    for (var i = 0; i < 10; i++)
                    {
                        c.RenderSprite(loc + new Vector3(i * 25, 0, 0), new Vector2(20, 20), Color.Red);
                    }
                },
                // Sequential triangles
                (c, loc) =>
                {
                    for (var i = 0; i < 10; i++)
                    {
                        c.RenderCircle(loc + new Vector3(i * 50, 0, 0), 20, Color.Green);
                    }
                },
                // Triangle fan
                (c, loc) =>
                {
                    Vector2 vec2Loc = loc.ToVec2();
                    var     poly    = new List <Vector2>
                    {
                        vec2Loc + new Vector2(19.4f, 5.4f),
                        vec2Loc + new Vector2(70.9f, 5.4f),
                        vec2Loc + new Vector2(45.1f, 66)
                    };

                    for (var i = 0; i < 10; i++)
                    {
                        c.RenderVertices(poly, Color.Blue);

                        // Offset vertices for the next draw.
                        for (var j = 0; j < poly.Count; j++)
                        {
                            poly[j] += new Vector2(55, 0);
                        }
                    }
                }
            };

            // Draw combinations of variants multiple times.
            var variantsTest = new[]
            {
                new[] { 0, 1, 2 },
                new[] { 2, 1, 0 },
                new[] { 0, 2, 1 },
                new[] { 2, 0, 1 }
            };
            const int drawsPerVariant = 10;

            Runner.ExecuteAsLoop(_ =>
            {
                for (var v = 0; v < variantsTest.Length; v++)
                {
                    int[] variant = variantsTest[v];

                    for (var c = 0; c < drawsPerVariant; c++)
                    {
                        RenderComposer composer = Engine.Renderer.StartFrame();
                        composer.SetUseViewMatrix(false);
                        var brush = new Vector3();
                        for (var i = 0; i < variant.Length; i++)
                        {
                            drawVariants[variant[i]](composer, brush);
                            brush.Y += 100;
                        }

                        composer.SetUseViewMatrix(true);
                        Engine.Renderer.EndFrame();

                        // Verify only on the last run of the variant.
                        if (c == drawsPerVariant - 1)
                        {
                            Runner.VerifyScreenshot(ResultDb.RenderComposerMultiBatchVariant + v);
                        }
                    }
                }
            }).WaitOne();
        }
Esempio n. 19
0
 public void Draw(RenderComposer composer)
 {
     composer.SetUseViewMatrix(false);
     _ui.Render(composer);
 }
Esempio n. 20
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);
        }
Esempio n. 21
0
        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();
        }
Esempio n. 22
0
 public void Draw(RenderComposer composer)
 {
     composer.SetUseViewMatrix(false);
     composer.RenderSprite(Vector3.Zero, composer.CurrentTarget.Size, Color.CornflowerBlue);
 }