public override void Render(RenderComposer composer) { // Render composer.RenderOutline( Position, Size, Color.Pink, 2 ); }
public void RenderDebug(RenderComposer c) { c.RenderOutline(Bounds, Color.Blue); if (ChildNodes == null) { return; } for (var i = 0; i < ChildNodes.Length; i++) { WorldTree2DNode node = ChildNodes[i]; node.RenderDebug(c); } }
protected override void AfterRenderChildren(RenderComposer c) { #if false { if (MouseFocus != null) { c.RenderOutline(MouseFocus.Bounds, Color.Red); } c.RenderSprite(new Rectangle(Engine.Host.MousePosition.X, Engine.Host.MousePosition.Y, 1, 1), Color.Pink); } #endif base.AfterRenderChildren(c); }
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); }
protected override void RenderContent(RenderComposer composer) { Vector2 offset = ImGui.GetWindowPos(); offset.Y += ImGui.GetWindowHeight(); _lastOffset = offset; composer.RenderSprite(new Vector3(offset, 0), _anim.Texture.Size * _parent.Scale, Color.White, _anim.Texture); for (var i = 0; i < _anim.Frames.Length; i++) { composer.RenderOutline(new Vector3(offset + _anim.Frames[i].Position * _parent.Scale, 1), _anim.Frames[i].Size * _parent.Scale, _holdingIdx == i ? Color.Green : Color.Red); composer.RenderString(new Vector3(offset + _anim.Frames[i].Position * _parent.Scale, 1), Color.Red, i.ToString(), _font.GetAtlas(15 * _parent.Scale)); } ImGui.Text(_holdingIdx == -1 ? "Click on a rectangle to change it's position." : $"Select new position for frame {_holdingIdx}!"); }
public void Render(RenderComposer c) { var colorMultiplier = (byte)(_mouseDragging ? 100 : 50); c.RenderOutline(Rect, Color); if (_anchor == 5) { c.RenderSprite(Rect, Color.Add(Color, colorMultiplier).SetAlpha(colorMultiplier)); } c.RenderCircle(Rect.Position.ToVec3(), 2, _anchor == 1 ? Color.Add(Color, colorMultiplier) : Color, true); c.RenderCircle(Rect.TopRight.ToVec3(), 2, _anchor == 2 ? Color.Add(Color, colorMultiplier) : Color, true); c.RenderCircle(Rect.BottomRight.ToVec3(), 2, _anchor == 3 ? Color.Add(Color, colorMultiplier) : Color, true); c.RenderCircle(Rect.BottomLeft.ToVec3(), 2, _anchor == 4 ? Color.Add(Color, colorMultiplier) : Color, true); }
public override void Render(RenderComposer composer) { // If she's in a magic flow render her as a circle if (IsMagicFlowActive) { composer.RenderCircle(CollisionBox.Center.ToVec3(Z), 15, Color.Pink, true); return; } // If walking on an incline apply rotation if (InclineAngle != 0f) { composer.PushModelMatrix( Matrix4x4.CreateRotationZ(InclineAngle, new Vector3(Center, 0)) ); } // Render the sprite composer.RenderSprite( Position, Size, !IsGravityPushActive ? Color.White : Color.Pink, Sprite.Texture, Sprite.CurrentFrame, IsFacingRight, false ); // Remove the rotation matrix if (InclineAngle != 0f) { composer.PopModelMatrix(); } if (IsGravityPushActive) { composer.RenderOutline( new Vector3( CollisionBox.Center.X - GravityPushRange, CollisionBox.Center.Y - GravityPushRange, 15 ), new Vector2(GravityPushRange * 2), Color.Pink, 2 ); } }
private void RenderMouseOverTiles(RenderComposer composer) { var mouseRect = new Rectangle(Engine.Renderer.Camera.ScreenToWorld(Vector2.Zero), new Vector2(1, 1)) { Center = Engine.Renderer.Camera.ScreenToWorld(Engine.InputManager.MousePosition) }; composer.RenderOutline(new Vector3(mouseRect.Position, 10), mouseRect.Size, Color.Magenta, 2); //composer.PushModelMatrix(Matrix4x4.CreateTranslation(new Vector3(-mouseRect.Position, 0))); composer.RenderTo(_frameBuffer); _drawMemory.Clear(); quadTree.GetObjects(mouseRect, ref _drawMemory); for (var i = 0; i < _drawMemory.Count; i++) { var tile = _drawMemory[i]; var a = composer.GetBatch(); var data = a.GetData(null); data[0].Vertex = tile.Vertex0.ToVec3(); data[0].Color = new Color(50 + i, i, 0).ToUint(); data[1].Vertex = tile.Vertex1.ToVec3(); data[1].Color = new Color(i * 20, i, 0).ToUint(); data[2].Vertex = tile.Vertex2.ToVec3(); data[2].Color = new Color(i * 20, i * 20, 0).ToUint(); data[3].Vertex = tile.Vertex3.ToVec3(); data[3].Color = new Color(i, i * 20, 0).ToUint(); } composer.PushCommand(new ExecCodeCommand() { Func = () => { byte[] pixels = _frameBuffer.Sample(new Rectangle(Engine.InputManager.MousePosition, Vector2.One)); _lastMouseX = pixels[3]; _lastMouseY = pixels[2]; } }); //composer.PopModelMatrix(); composer.RenderTo(null); }
/// <summary> /// Render an outline of all leaves in the tree. /// Used for debugging purposes. /// </summary> public void RenderDebug(RenderComposer c, Color color) { var treeTraverse = new Queue <QuadTreeNode <T> >(); treeTraverse.Enqueue(this); while (treeTraverse.TryDequeue(out QuadTreeNode <T> quadTree)) { c.RenderOutline(quadTree.QuadRect, color); if (quadTree.TopLeftChild == null) { continue; } treeTraverse.Enqueue(quadTree.TopLeftChild); treeTraverse.Enqueue(quadTree.TopRightChild); treeTraverse.Enqueue(quadTree.BottomLeftChild); treeTraverse.Enqueue(quadTree.BottomRightChild); } }
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); }
private void RenderMap(RenderComposer composer) { _drawMemory.Clear(); var rect = new Rectangle( Engine.Renderer.Camera.ScreenToWorld(Vector2.Zero), Engine.Configuration.RenderSize * (Engine.Renderer.Scale - (Engine.Renderer.IntScale - 1)) / Engine.Renderer.Camera.Zoom ); quadTree.GetObjects(rect, ref _drawMemory); _rendered = _drawMemory.Count; composer.RenderOutline(new Vector3(rect.Position, 0f), rect.Size, Color.CornflowerBlue, 2); // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _drawMemory.Count; i++) { var tile = _drawMemory[i]; var c = Color.White.ToUint(); var texture = tile.Height == 1 ? _tileMntTexture : i % 27 == 0 ? _tileGrs2Texture : _tileGrs1Texture; var a = composer.GetBatch(); var data = a.GetData(texture.Texture); data[0].Vertex = tile.Vertex0.ToVec3(); data[0].Color = c; data[0].UV = Vector2.Zero; data[1].Vertex = tile.Vertex1.ToVec3(); data[1].Color = c; data[1].UV = new Vector2(1, 0); data[2].Vertex = tile.Vertex2.ToVec3(); data[2].Color = c; data[2].UV = new Vector2(1, 1); data[3].Vertex = tile.Vertex3.ToVec3(); data[3].Color = c; data[3].UV = new Vector2(0, 1); } }
protected override void RenderContent(RenderComposer composer) { Vector2[] anchorArray = _anim.Anchors; if (_parent.AnimController != null) { if (_parent.Mirrored) { _parent.AnimController.MirrorXAnchors ??= new Vector2[_anim.Anchors.Length]; anchorArray = _parent.Mirrored ? _parent.AnimController.MirrorXAnchors : anchorArray; } if (_parent.Mirrored) { if (ImGui.Button("Copy Non-Mirror Anchors")) { for (int i = _anim.StartingFrame; i <= _anim.EndingFrame; i++) { anchorArray[i] = _anim.Anchors[i]; } } ImGui.SameLine(); if (ImGui.Button("Copy Y Axis of Non-Mirror Anchors")) { for (int i = _anim.StartingFrame; i <= _anim.EndingFrame; i++) { anchorArray[i].Y = _anim.Anchors[i].Y; } } } } bool selected = _anchorSettingFrame == -1; if (selected) { ImGui.PushStyleColor(ImGuiCol.Button, new Color(255, 0, 0).ToUint()); } if (ImGui.Button("Interactive Move All")) { _anchorSettingFrame = -1; } if (selected) { ImGui.PopStyleColor(); } int startFrame = _anim.StartingFrame; int endFrame = _anim.EndingFrame; for (int i = startFrame; i <= endFrame; i++) { ImGui.PushID(i); ImGui.InputFloat2($"Frame {i} ({_anim.Frames[i]})", ref anchorArray[i]); ImGui.SameLine(); selected = _anchorSettingFrame == i; if (selected) { ImGui.PushStyleColor(ImGuiCol.Button, new Color(255, 0, 0).ToUint()); } if (ImGui.Button("Interactive Set")) { _anchorSettingFrame = i; } if (selected) { ImGui.PopStyleColor(); } ImGui.PopID(); } Vector2 pos = ImGui.GetWindowPos(); pos.Y += ImGui.GetWindowHeight(); pos = pos.IntCastRound(); float scale = _parent.Scale; var interactiveRect = Rectangle.Empty; if (_anchorSettingFrame != -1) { _anchorSettingFrame = Maths.Clamp(_anchorSettingFrame, startFrame, endFrame); pos.Y += 10 * scale; int prevFrame = Math.Max(_anchorSettingFrame - 1, startFrame); Vector2 size = _anim.Frames[prevFrame].Size * scale; Vector2 prevFramePos = pos + anchorArray[prevFrame] * scale; Rectangle inflatedRect = new Rectangle(prevFramePos, size).Inflate(scale, scale); composer.RenderSprite(inflatedRect.PositionZ(0), inflatedRect.Size, Color.White); composer.RenderSprite(new Vector3(prevFramePos, 0), size, Color.White * 0.5f, _anim.Texture, _anim.Frames[prevFrame], _parent.Mirrored); size = _anim.Frames[_anchorSettingFrame].Size * scale; interactiveRect = new Rectangle(pos + anchorArray[_anchorSettingFrame] * scale, size); composer.RenderSprite(interactiveRect.PositionZ(0), size, Color.White * 0.75f, _anim.Texture, _anim.Frames[_anchorSettingFrame], _parent.Mirrored); composer.RenderOutline(interactiveRect.Inflate(scale, scale), Color.Red); } else { for (int i = startFrame; i <= endFrame; i++) { Vector2 size = _anim.Frames[i].Size * scale; interactiveRect = new Rectangle(pos + anchorArray[i] * scale, size); composer.RenderSprite(interactiveRect.PositionZ(0), size, Color.White * 0.75f, _anim.Texture, _anim.Frames[i], _parent.Mirrored); } composer.RenderOutline(interactiveRect.Inflate(scale, scale), Color.Red); } if (!_mouseDown && interactiveRect.Contains(Engine.Host.MousePosition) && Engine.Host.IsKeyDown(Key.MouseKeyLeft)) { _mouseDown = true; _mouseDownPos = Engine.Host.MousePosition; _interactiveAnchorStart = _anchorSettingFrame == -1 ? Vector2.Zero : anchorArray[_anchorSettingFrame]; } else if (!Engine.Host.IsKeyHeld(Key.MouseKeyLeft)) { _mouseDown = false; } if (_mouseDown) { Vector2 movedAmount = Engine.Host.MousePosition - _mouseDownPos; Vector2 m = (movedAmount / scale).IntCastRound(); if (_anchorSettingFrame == -1) { for (int i = startFrame; i <= endFrame; i++) { anchorArray[i] = anchorArray[i] - _interactiveAnchorStart; anchorArray[i] = anchorArray[i] + m; } _interactiveAnchorStart = m; } else { anchorArray[_anchorSettingFrame] = _interactiveAnchorStart + m; } } }
protected override bool RenderInternal(RenderComposer c) { var open = true; ImGui.SetNextWindowPos(new Vector2(0, 20), ImGuiCond.Always); ImGui.SetNextWindowSize(c.CurrentTarget.Size - new Vector2(0, 20)); ImGui.Begin(Title, ref open, ImGuiWindowFlags.MenuBar | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove); RenderImGui(); ImGui.End(); Position = Vector3.Zero; Size = c.CurrentTarget.Size; if (!open) { Parent?.RemoveChild(this); return(false); } if (_textureFb?.ColorAttachment == null) { return(true); // Disposed or uninitialized fb } if (_currentAssetTexture == null) { return(true); } _textureFb.ColorAttachment.Smooth = false; c.RenderToAndClear(_textureFb); c.RenderSprite(Vector3.Zero, _currentAssetTexture.Size, _currentAssetTexture); // Render meta overlay on the spritesheet texture. if (_currentAsset != null) { AnimatedSprite currentFileContext = _currentAsset.Content !; SpriteAnimationFrameSource frameSource = currentFileContext.FrameSource; if (frameSource != null) { for (var i = 0; i < frameSource.GetFrameCount(); i++) { Rectangle frameUv = frameSource.GetFrameUV(i); c.RenderOutline(frameUv, _selectedFrame == i ? Color.Green : Color.Red); if (_showFrameIdx && frameSource is SpriteArrayFrameSource) { Vector3 stringPos = frameUv.Position.ToVec3(); DrawableFontAtlas atlas = _debugFont.GetAtlas(20); c.RenderString(stringPos + new Vector3(1), Color.Black, i.ToString(), atlas); c.RenderString(stringPos, Color.Red, i.ToString(), atlas); } } } } c.RenderTo(null); RenderAnimationPreview(c); return(true); }
///<summary> /// Render the object's Transform rectangle. /// Emotion specific method. ///</summary> public void RenderObjectRectange(RenderComposer composer) { // Check if Item can be cast to Unit in "unit" variable and if so provides the "unit" variable for further use if (Item is Unit unit) { // Draw texture center composer.RenderCircle(Item.Center.ToVec3(Item.Z), 3, Color.Green, true); if (unit.InclineAngle != 0f) { composer.PushModelMatrix( Matrix4x4.CreateRotationZ(unit.InclineAngle, new Vector3(unit.Center, 0)) ); } // Draw the texture rectangle composer.RenderOutline(Item.Position, Item.Size, Color.Green, 2); if (unit.InclineAngle != 0f) { composer.PopModelMatrix(); } // Draw future position for units Vector3 futurePosition; if (!unit.IsAffectedByGravityPush) { futurePosition = new Vector3( unit.CollisionBox.X + (unit.VelocityX * unit.RunTimer.Progress), unit.CollisionBox.Y - (unit.GravityTimer.Progress * unit.StartingVelocityY), unit.CollisionBox.Z ); } else { if (unit.GravityPushPushDurationTimer != null) { futurePosition = new Vector3( unit.CollisionBox.X + (unit.VelocityX * unit.GravityPushPushDurationTimer.Progress), unit.CollisionBox.Y - unit.StartingVelocityY, unit.CollisionBox.Z ); } else { futurePosition = new Vector3( unit.CollisionBox.X, unit.CollisionBox.Y - unit.StartingVelocityY, unit.CollisionBox.Z ); } } composer.RenderOutline(futurePosition, unit.CollisionBox.Size, Color.Cyan, 1); // Draw last position of the CollisionBox composer.RenderOutline(unit.LastState.CollisionBox.Position, unit.LastState.CollisionBox.Size, Color.Yellow, 2); // Draw CollisionBox for units composer.RenderOutline(unit.CollisionBox.Position, unit.CollisionBox.Size, Color.Red, 2); // Draw CollisionBox center for units composer.RenderCircle(unit.CollisionBox.Center.ToVec3(Item.Z), 3, Color.Red, true); } else if (Item is Decoration dec) { // Draw texture center composer.RenderCircle(Item.Center.ToVec3(Item.Z), 3, Color.Green, true); // Draw texture rectangle (without rotation) composer.RenderOutline(dec.Position, dec.DisplaySize, Color.Blue, 2); if (dec.Rotation != 0f) { // Tiled rotates images around the bottom left corner composer.PushModelMatrix( Matrix4x4.CreateRotationZ(dec.Rotation, new Vector3(dec.X, dec.Y + dec.DisplaySize.Y, 0)) ); } // Draw texture rectangle (with rotation) composer.RenderOutline(dec.Position, dec.DisplaySize, Color.Red, 2); if (dec.Rotation != 0f) { // Tiled rotates images around the bottom left corner composer.PopModelMatrix(); } } }