mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added guizmo
Translation is broken for some reason
This commit is contained in:
@@ -3,11 +3,16 @@ using ImGui;
|
||||
using GlitchyEngine.Renderer;
|
||||
using GlitchyEngine.Math;
|
||||
using GlitchyEngine;
|
||||
using GlitchyEngine.World;
|
||||
using ImGuizmo;
|
||||
|
||||
namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
class SceneViewportWindow
|
||||
{
|
||||
private Editor _editor;
|
||||
public Camera _camera;
|
||||
|
||||
public const String s_WindowTitle = "Scene";
|
||||
|
||||
private bool _open = true;
|
||||
@@ -41,8 +46,9 @@ namespace GlitchyEditor.EditWindows
|
||||
}
|
||||
}
|
||||
|
||||
public this()
|
||||
public this(Editor editor)
|
||||
{
|
||||
_editor = editor;
|
||||
}
|
||||
|
||||
private ImGui.Vec2 oldViewportSize;
|
||||
@@ -76,6 +82,40 @@ namespace GlitchyEditor.EditWindows
|
||||
{
|
||||
ImGui.Image(_renderTarget, viewportSize);
|
||||
}
|
||||
|
||||
if(_editor.SelectedEntities.Count > 0)
|
||||
{
|
||||
ImGuizmo.SetDrawlist();
|
||||
|
||||
var entity = _editor.SelectedEntities.Back;
|
||||
|
||||
var transformCmp = _editor.World.GetComponent<TransformComponent>(entity);
|
||||
|
||||
var transform = transformCmp.LocalTransform;
|
||||
|
||||
var view = _camera.View;
|
||||
var projection = _camera.Projection;
|
||||
|
||||
var v = ImGui.GetWindowPos();
|
||||
var cntMin = ImGui.GetWindowContentRegionMin();
|
||||
|
||||
v.x += cntMin.x;
|
||||
v.y += cntMin.y;
|
||||
|
||||
ImGuizmo.SetRect(v.x, v.y, viewportSize.x, viewportSize.y);
|
||||
|
||||
Color c = .(0,0,0,255);
|
||||
|
||||
//ImGuizmo.DrawCubes((.)&view, (.)&projection, (.)&transform, 1);
|
||||
ImGuizmo.Manipulate((.)&view, (.)&projection, .TRANSLATE, .LOCAL, (.)&transform);
|
||||
|
||||
Matrix mat = .Identity;
|
||||
|
||||
ImGuizmo.DrawGrid((.)&view, (.)&projection, (.)&mat, 10);
|
||||
|
||||
transformCmp.LocalTransform = transform;
|
||||
//ImGuizmo.ViewManipulate((.)&view, , .TRANSLATE, .LOCAL, (.)&transform);
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace GlitchyEditor
|
||||
|
||||
private EntityHierarchyWindow _entityHierarchyWindow = new .(this) ~ delete _;
|
||||
private ComponentEditWindow _componentEditWindow = new .(this) ~ delete _;
|
||||
private SceneViewportWindow _sceneViewportWindow = new .() ~ delete _;
|
||||
private SceneViewportWindow _sceneViewportWindow = new .(this) ~ delete _;
|
||||
|
||||
private List<Entity> _selectedEntities = new .() ~ delete _;
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using GlitchyEditor.EditWindows;
|
||||
using System;
|
||||
using ImGui;
|
||||
using GlitchyEngine;
|
||||
using GlitchyEditor.EditWindows;
|
||||
using GlitchyEngine.Events;
|
||||
using GlitchyEngine.ImGui;
|
||||
using GlitchyEngine.Math;
|
||||
using GlitchyEngine.Renderer;
|
||||
using GlitchyEngine.World;
|
||||
using ImGui;
|
||||
using System;
|
||||
using GlitchyEngine.Renderer.Text;
|
||||
|
||||
namespace GlitchyEditor
|
||||
{
|
||||
@@ -88,9 +87,10 @@ namespace GlitchyEditor
|
||||
Application.Get().Window.Context.SwapChain.BackbufferViewport.Height);
|
||||
_cameraController.CameraPosition = .(0, 0, -5);
|
||||
_cameraController.TranslationSpeed = 10;
|
||||
|
||||
|
||||
_editor.[Friend]CreateEntityWithTransform();
|
||||
|
||||
_editor.SceneViewportWindow._camera = _cameraController.Camera;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
|
||||
Reference in New Issue
Block a user