Wrote a very basic camera and unit tests.
This commit is contained in:
48
RecrownedGTK/Graphics/Camera.cs
Normal file
48
RecrownedGTK/Graphics/Camera.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using OpenTK;
|
||||
|
||||
namespace RecrownedGTK.Graphics {
|
||||
public class Camera {
|
||||
private Vector3 scale = new Vector3(1f), translate, rotation;
|
||||
public Vector3 Scale {
|
||||
get {
|
||||
return scale;
|
||||
}
|
||||
set {
|
||||
updated = true;
|
||||
scale = value;
|
||||
}
|
||||
}
|
||||
public Vector3 Translate {
|
||||
set {
|
||||
updated = true;
|
||||
translate = value;
|
||||
}
|
||||
}
|
||||
public Vector3 Rotation {
|
||||
set {
|
||||
updated = true;
|
||||
rotation = value;
|
||||
}
|
||||
get {
|
||||
return rotation;
|
||||
}
|
||||
}
|
||||
private Matrix4 transform;
|
||||
|
||||
public Matrix4 Transform {
|
||||
get {
|
||||
if (!updated) return transform;
|
||||
updated = true;
|
||||
transform =
|
||||
Matrix4.CreateScale(scale) *
|
||||
Matrix4.CreateRotationX(rotation.X) *
|
||||
Matrix4.CreateRotationY(rotation.Y) *
|
||||
Matrix4.CreateRotationZ(rotation.Z) *
|
||||
Matrix4.CreateTranslation(translate);
|
||||
transform = Matrix4.Transpose(transform);
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
private bool updated;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user