mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Componentified Camera
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user