.
This commit is contained in:
19
Engine/Scene/Component/Transform.cs
Normal file
19
Engine/Scene/Component/Transform.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using OpenTK.Mathematics;
|
||||
|
||||
namespace Engine.Scene.Component;
|
||||
|
||||
public class Transform(GameObject gameObject) : Component(gameObject)
|
||||
{
|
||||
public Vector3 Position { get; set; } = Vector3.Zero;
|
||||
public Quaternion Rotation { get; set; } = Quaternion.Identity;
|
||||
public Vector3 Scale { get; set; } = Vector3.One;
|
||||
public Vector3 LocalScale { get; set; } = Vector3.One;
|
||||
|
||||
public Matrix4 LocalTransformMatrix => Matrix4.CreateScale(Scale) *
|
||||
Matrix4.CreateFromQuaternion(Rotation) *
|
||||
Matrix4.CreateTranslation(Position);
|
||||
|
||||
public Matrix4 TransformMatrix => LocalTransformMatrix * ParentTransformMatrix;
|
||||
|
||||
private Matrix4 ParentTransformMatrix => Matrix4.Identity;
|
||||
}
|
||||
Reference in New Issue
Block a user