forked from Misaki/GhostEngine
Changed Vector3Field.cs to derive from ValueControl<Vector3> and use NumberBox controls for better UI handling. Changed EditorControls.xaml to update resource paths for new controls. Changed InternalControls.xaml to simplify the resource dictionary by removing unnecessary references. Changed IComponentEditor.cs to reflect updates in the component editor's lifecycle methods. Changed project files for Ghost.Editor and Ghost.Core to include new dependencies and project references. Changed FileExtensions.cs and IInspectorService.cs to align with the new namespace structure. Changed Result.cs to enhance error handling and success checking methods. Changed TypeHandle.cs to improve type handling compatibility. Changed AssemblyInfo.cs files to include new assembly visibility attributes for better encapsulation. Added new graphics-related classes and interfaces in the Ghost.Engine project, including IGraphicsDevice and DX12GraphicsDevice. Added a new Mesh class to handle 3D mesh data and provide methods for creating geometric shapes. Added GraphicsPipeline.cs to manage the graphics rendering loop and device initialization. Added ScenePage.xaml and ScenePage.xaml.cs to create a new page for rendering scenes. Updated HierarchyPage.xaml.cs and InspectorPage.xaml.cs to use the new service locator pattern for service retrieval. Updated LandingWindow.xaml.cs and EngineEditorWindow.xaml.cs to utilize the new service locator pattern for better service access. Updated Logger.cs to enhance logging capabilities with optional stack traces and assertion logging. Updated QueryFilter.cs and QueryEnumerable.cs to use the new TypeHandle structure for improved efficiency. Updated WorldNode.cs and WorldNodeSerializer.cs to enhance serialization and management of world nodes. Updated AssetDatabase and related classes to improve asset management and metadata generation. Updated Ghost.UnitTest.csproj to include new project references and package dependencies for unit tests.
61 lines
2.3 KiB
C#
61 lines
2.3 KiB
C#
using Ghost.Editor.Controls;
|
|
using Ghost.Editor.Core.Inspector;
|
|
using Ghost.Engine.Components;
|
|
using Ghost.Engine.Utilities;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
namespace Ghost.Editor.Components;
|
|
|
|
[CustomEditor(typeof(LocalToWorld))]
|
|
internal class LocalToWorldEditor : ComponentEditor
|
|
{
|
|
private Vector3Field _translationField = null!;
|
|
private Vector3Field _rotationField = null!;
|
|
private Vector3Field _scaleField = null!;
|
|
|
|
public override void Create(StackPanel container)
|
|
{
|
|
_translationField = new Vector3Field();
|
|
_rotationField = new Vector3Field();
|
|
_scaleField = new Vector3Field();
|
|
|
|
_translationField.OnValueChanged += (s, e) =>
|
|
{
|
|
var data = ComponentObject.GetData<LocalToWorld>();
|
|
MatrixUtility.GetTRS(data.ValueRO.matrix, out var _, out var oldRotation, out var oldScale);
|
|
data.ValueRW.matrix = MatrixUtility.CreateTRS(e.NewValue, oldRotation, oldScale);
|
|
};
|
|
|
|
_rotationField.OnValueChanged += (s, e) =>
|
|
{
|
|
var data = ComponentObject.GetData<LocalToWorld>();
|
|
MatrixUtility.GetTRS(data.ValueRO.matrix, out var oldTranslation, out var _, out var oldScale);
|
|
data.ValueRW.matrix = MatrixUtility.CreateTRS(oldTranslation, e.NewValue.ToQuaternion(), oldScale);
|
|
};
|
|
|
|
_scaleField.OnValueChanged += (s, e) =>
|
|
{
|
|
var data = ComponentObject.GetData<LocalToWorld>();
|
|
MatrixUtility.GetTRS(data.ValueRO.matrix, out var oldTranslation, out var oldRotation, out var _);
|
|
data.ValueRW.matrix = MatrixUtility.CreateTRS(oldTranslation, oldRotation, e.NewValue);
|
|
};
|
|
|
|
container.Children.Add(new PropertyField() { Label = "Position", Content = _translationField });
|
|
container.Children.Add(new PropertyField() { Label = "Rotation", Content = _rotationField });
|
|
container.Children.Add(new PropertyField() { Label = "Scale", Content = _scaleField });
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
var data = ComponentObject.GetData<LocalToWorld>();
|
|
MatrixUtility.GetTRS(data.ValueRO.matrix, out var translation, out var rotation, out var scale);
|
|
|
|
_translationField.Value = translation;
|
|
_rotationField.Value = VectorUtility.CreateFromQuaternion(rotation);
|
|
_scaleField.Value = scale;
|
|
}
|
|
|
|
public override void Destroy()
|
|
{
|
|
}
|
|
} |