Componentified Camera

This commit is contained in:
Simon Lübeß
2021-05-17 20:07:58 +02:00
parent 3e0c4b2eb7
commit 7fb1f30303
6 changed files with 234 additions and 34 deletions
+56 -5
View File
@@ -4,16 +4,67 @@ namespace GlitchyEngine.World
{
public struct TransformComponent
{
static int _id;
Vector3 _position = .Zero;
Vector3 _rotation = .Zero;
Vector3 _scale = .One;
public static int ID {get => _id; set => _id = value; }
internal Matrix _transform;
Matrix _transform;
bool _dirty;
public Matrix Transform
{
get => _transform;
get mut
{
return _transform;
}
set mut => _transform = value;
}
public Vector3 Position
{
get => _position;
set mut
{
if(_position == value)
return;
_position = value;
_dirty = true;
}
}
public Vector3 Rotation
{
get => _rotation;
set mut
{
if(_rotation == value)
return;
_rotation = value;
_dirty = true;
}
}
public Vector3 Scale
{
get => _scale;
set mut
{
if(_scale == value)
return;
_scale = value;
_dirty = true;
}
}
public void Update() mut
{
if(!_dirty)
return;
_transform = .Translation(_position) * .RotationX(_rotation.X) *
.RotationY(_rotation.Y) * .RotationZ(_rotation.Z) * .Scaling(_scale);
_dirty = false;
}
}
}