Added a new static class `AssetsPath` for asset management. Added a new icon file (`icon-256.ico`) for UI representation. Added new package references to enhance functionality. Added internals visibility attributes for better testing. Added a new `EngineEditorViewModel` class for MVVM support. Added a new `GameObject` class for component management. Added a new `BitSet` class for efficient bit manipulation. Added various utility classes to support the new entity system. Changed the `ID` property in `ProjectInfo` to internal. Changed the `AddProjectAsync` method to return the created `ProjectInfo`. Changed the connection string retrieval method to use the new `Command` constant. Changed the `DataPath` class to use `readonly` fields for folder paths. Changed the `ActivationHandler` class to use new `DataPath` constants. Changed the `OpenProjectPage` layout and interaction for better UI. Updated the target framework to a newer version for compatibility. Updated the `ProjectService` to use new constants from `DataPath`. Updated the `World` class to improve entity management. Refactored the `ProjectRepository` class to encapsulate SQL commands. Refactored the `Transform` class to use properties for better encapsulation.
62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
using Ghost.Engine.Helpers;
|
|
using System.Numerics;
|
|
|
|
namespace Ghost.Engine.Components;
|
|
|
|
public class Transform : Component
|
|
{
|
|
private Vector3 _position = Vector3.Zero;
|
|
public Vector3 position
|
|
{
|
|
get => _position;
|
|
set
|
|
{
|
|
_position = value;
|
|
hasChanged = true;
|
|
UpdateMatrices();
|
|
}
|
|
}
|
|
|
|
private Quaternion _rotation = Quaternion.Identity;
|
|
public Quaternion Rotation
|
|
{
|
|
get => _rotation;
|
|
set
|
|
{
|
|
_rotation = value;
|
|
hasChanged = true;
|
|
UpdateMatrices();
|
|
}
|
|
}
|
|
|
|
private Vector3 _scale = Vector3.One;
|
|
public Vector3 Scale
|
|
{
|
|
get => _scale;
|
|
set
|
|
{
|
|
_scale = value;
|
|
hasChanged = true;
|
|
UpdateMatrices();
|
|
}
|
|
}
|
|
|
|
public bool hasChanged = true;
|
|
|
|
private Matrix4x4 _localToWorldMatrix = Matrix4x4.Identity;
|
|
private Matrix4x4 _worldToLocalMatrix = Matrix4x4.Identity;
|
|
|
|
public Matrix4x4 LocalToWorldMatrix => _localToWorldMatrix;
|
|
public Matrix4x4 WorldToLocalMatrix => _worldToLocalMatrix;
|
|
|
|
private void UpdateMatrices()
|
|
{
|
|
_localToWorldMatrix = MatrixHelpers.CreateTRS(_position, _rotation, _scale);
|
|
Matrix4x4.Invert(_localToWorldMatrix, out _worldToLocalMatrix);
|
|
}
|
|
|
|
public override void Start()
|
|
{
|
|
UpdateMatrices();
|
|
}
|
|
} |