public override unsafe void RenderGui(ImGuiWrapper gui) { base.RenderGui(gui); if (gui is SceneEditorGui sceneGui) { var color = Color; if (gui.InputFloat3("Color", &color)) { Color = RyneMath.Max(color, new Float3(0.01f)); Changed = true; } var intensity = Intensity; if (gui.InputFloat("Intensity", ref intensity)) { Intensity = System.Math.Max(intensity, 0.01f); Changed = true; } } if (Changed) { Global.StateManager.GetCurrentState().SceneRenderData.UpdateLight(ToRenderLight(), RenderId); Changed = false; } }
public MaterialGui(ImGuiWrapper gui, Material material, WindowDelegate onMaterialChanged) : base(gui, "Edit " + material.Name) { Material = material; OnMaterialChanged = onMaterialChanged; ItemWidth = 100.0f; AddProperties(); }
/// <summary> /// Opens a menu to select a file /// </summary> /// <param name="directory">Specific folder inside the Global.Config.WorkingDirectory</param> public FileExplorerGui(ImGuiWrapper gui, string directory, string fileExtensions, string windowTitle = "FileExplorer") : base(gui, windowTitle, false) { SearchDirectory = directory; FileExtensions = fileExtensions; OpenFolders = new List <string>(); }
public unsafe void RenderGui(ImGuiWrapper gui, Entity owner) { bool changed = false; if (gui.CollapsingHeader("Transform component", true)) { var position = new Float3(Position); if (gui.InputFloat3("Position", &position)) { if ((new Float3(Position) - position).Length() > Constants.Epsilon) { Position = new Float4(position); changed = true; } } var pivot = new Float3(Pivot); if (gui.InputFloat3("Pivot", &pivot)) { if ((new Float3(Pivot) - pivot).Length() > Constants.Epsilon) { Pivot = new Float4(pivot); changed = true; } } var scale = new Float3(Scale); if (gui.InputFloat3("Scale", &scale)) { if ((new Float3(Scale) - scale).Length() > Constants.Epsilon) { Scale = new Float4(scale); changed = true; } } var rotation = Rotation.ToRotator().ToFloat3(); if (gui.InputFloat3("Rotation", &rotation)) { var oldRotation = Rotation.ToRotator().ToFloat3(); var newRotation = new Rotator(rotation).ToQuaternion().ToRotator().ToFloat3(); if ((oldRotation - newRotation).Length() > Constants.Epsilon) { Rotation = new Rotator(rotation).ToQuaternion(); changed = true; } } } if (changed && gui is SceneEditorGui sceneGui) { if (owner.RenderId > -1) { sceneGui.SceneData.UpdateTransform(owner.RenderId, ToRenderComponent()); } } }
public void RenderGui(ImGuiWrapper gui, Entity owner) { if (gui.CollapsingHeader("Collision component", true)) { if (gui is SceneEditorGui sceneGui) { if (gui.InputCheckBox("Render debug visualization", ref DebugVisualization)) { sceneGui.RenderDebugVisualization = true; //DebugVisualization = !DebugVisualization; } if (sceneGui.RenderDebugVisualization && DebugVisualization) { Global.EntityManager.UpdateCollisionBvh(); switch (Shape) { case RyneCollisionShape.CollisionShapeAABB: var aabb = ExtractAABB(owner.Transform); aabb.DebugVisualization(gui, new Float3(1, 0, 0)); break; case RyneCollisionShape.CollisionShapeCube: var cube = ExtractCube(owner.Transform); cube.DebugVisualization(gui, new Float3(1, 0, 0)); break; } foreach (var id in Global.EntityManager.CollisionBvh.Query(owner.Transform, this)) { if (id == owner.EntityId) { continue; } var collisionData = CollisionSystem.CheckIntersection(owner, Global.EntityManager.Entities[id]); if (collisionData.Intersecting) { var start = new Float3(owner.Transform.GetLocation()); var end = start + collisionData.Normal * collisionData.Depth; gui.DebugAddLine(start, end, new Float3(0, 1, 0)); } } } } } }
public unsafe void RenderGui(ImGuiWrapper gui, Entity owner) { if (gui.CollapsingHeader("Physics component", true)) { var velocity = new Float3(Velocity); if (gui.InputFloat3("Velocity", &velocity)) { } var acceleration = new Float3(Acceleration); if (gui.InputFloat3("Acceleration", &acceleration)) { } gui.InputCheckBox("OnSurface", ref OnSurface); } }
public WindowGui(ImGuiWrapper gui, string windowTitle) { Gui = gui; GuiElements = new List <IGuiElement>(); WindowTitle = windowTitle; Active = true; ExecuteCallback = false; MaxWidth = Global.Config.Width - 100; MaxHeight = Global.Config.Height - 100; MinWidth = 100.0f; MinHeight = 50.0f; ItemWidth = 0.0f; FirstRender = true; SetSizeConstraints = true; }
// TODO: Code generation? public virtual void RenderGui(ImGuiWrapper gui) { // Components if (HasComponent <TransformComponent>()) { Transform.RenderGui(gui, this); } if (HasComponent <PhysicsComponent>()) { Physics.RenderGui(gui, this); } if (HasComponent <CollisionComponent>()) { Collision.RenderGui(gui, this); } if (HasComponent <MeshComponent>()) { Mesh.RenderGui(gui, this); } }
public bool RenderEntity(ImGuiWrapper gui, string label) { return(false); }
public void RenderGui(ImGuiWrapper gui, Entity owner) { if (!(gui is SceneEditorGui sceneGui)) { return; } if (gui.CollapsingHeader("Mesh component", true)) { if (ObjectType == RyneObjectType.ObjectTypeNone) { if (sceneGui.MenuItem("Load voxel mesh")) { var extensions = Global.ResourceManager.GetSupportedExtensions(RyneResourceType.ResourceTypeBsvDag); var window = new FileExplorerGui(sceneGui, "VoxelModels", extensions, "Select model"); window.Callback += result => { var fileExplorer = (FileExplorerGui)result; var type = RyneObjectType.ObjectTypeBsvDag; owner.Mesh.SetMeshData(fileExplorer.SelectedFile, type); owner.Mesh.LoadMesh(); owner.SetChangedInEditor(true); }; sceneGui.AddPopup(window); } } else { if (!Loaded || owner.RenderId == -1) { gui.Text("Mesh loaded: " + Loaded); return; } if (CustomMaterials.Count == 0) { if (gui.MenuItem("Create unique materials")) { SetCustomMaterials(owner); } } else { for (int i = 0; i < CustomMaterials.Count; i++) { var localIndex = i; var material = CustomMaterials[i]; var name = string.IsNullOrEmpty(material.Name) ? localIndex.ToString() : material.Name; if (gui.MenuItem("Edit Material " + name)) { var window = new MaterialGui(sceneGui, material, result => { owner.Mesh.UpdateMaterial(owner, sceneGui.SceneData, (Material)result.GetWindowObject, localIndex); }); sceneGui.AddWindow(window); } } } } } }