keep working on matrix. key is to remove old matrix types
Signed-off-by: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Graphics.ShaderEdit;
|
||||
using StgSharp.HighPerformance;
|
||||
using StgSharp.Mathematics;
|
||||
|
||||
using System;
|
||||
@@ -46,11 +47,11 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
private bool _isLookAtAvailable;
|
||||
internal Matrix44 _lookAt;
|
||||
internal Matrix44 _projection;
|
||||
internal Matrix44 cameraAtt;
|
||||
internal Matrix44 rotation;
|
||||
internal Matrix44 rotationAtt;
|
||||
internal MatrixKernel _lookAt;
|
||||
internal MatrixKernel _projection;
|
||||
internal MatrixKernel cameraAtt;
|
||||
internal MatrixKernel rotation;
|
||||
internal MatrixKernel rotationAtt;
|
||||
internal Radius _pitch;
|
||||
internal Radius _row;
|
||||
internal Radius _yaw;
|
||||
@@ -59,20 +60,20 @@ namespace StgSharp.Graphics
|
||||
|
||||
public Camera()
|
||||
{
|
||||
cameraAtt = Matrix44.Unit;
|
||||
cameraAtt = MatrixKernel.Fp32Unit;
|
||||
_target = Vec3.Zero;
|
||||
up = Vec3.Zero;
|
||||
_isLookAtAvailable = false;
|
||||
_lookAt = Matrix44.Unit;
|
||||
rotationAtt = Matrix44.Unit;
|
||||
_projection = new Matrix44();
|
||||
_lookAt = MatrixKernel.Fp32Unit;
|
||||
rotationAtt = MatrixKernel.Fp32Unit;
|
||||
_projection = new MatrixKernel(true);
|
||||
}
|
||||
|
||||
public Camera(Vec3 position, Vec3 target, Vec3 up)
|
||||
: this()
|
||||
{
|
||||
rotationAtt = Matrix44.Unit;
|
||||
cameraAtt = new Matrix44();
|
||||
rotationAtt = MatrixKernel.Fp32Unit;
|
||||
cameraAtt = new MatrixKernel(true);
|
||||
SetViewDirection(position, target, up);
|
||||
_pitch = Radius.Zero;
|
||||
_row = Radius.Zero;
|
||||
@@ -88,8 +89,8 @@ namespace StgSharp.Graphics
|
||||
if (_isLookAtAvailable) {
|
||||
return _lookAt;
|
||||
}
|
||||
Matrix44 move = Matrix44.Unit;
|
||||
move.colum3.vec -= cameraAtt.colum3.vec;
|
||||
Matrix44 move = MatrixKernel.Fp32Unit;
|
||||
move.colum3.vec -= cameraAtt.colum3;
|
||||
_lookAt = rotationAtt.Transpose * move;
|
||||
_isLookAtAvailable = true;
|
||||
return _lookAt;
|
||||
@@ -155,9 +156,7 @@ namespace StgSharp.Graphics
|
||||
public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up)
|
||||
{
|
||||
Vec3 direction = position - target;
|
||||
if ((position.reg == cameraAtt.colum3.reg) &&
|
||||
(this.up == up) &&
|
||||
(cameraAtt.colum2.reg == direction.reg)) {
|
||||
if ((position.reg == cameraAtt.colum3.reg) && (this.up == up) && (cameraAtt.colum2.reg == direction.reg)) {
|
||||
return;
|
||||
}
|
||||
if (direction.GetLength() == 0)
|
||||
@@ -187,11 +186,7 @@ namespace StgSharp.Graphics
|
||||
InternalYaw();
|
||||
}
|
||||
|
||||
public void SetViewRange(
|
||||
Radius fovRadius,
|
||||
Vec2 size,
|
||||
Vec2 offset,
|
||||
(float front, float back) dephRange)
|
||||
public void SetViewRange(Radius fovRadius, Vec2 size, Vec2 offset, (float front, float back) dephRange)
|
||||
{
|
||||
float
|
||||
distance = _target.GetLength(),
|
||||
|
||||
Reference in New Issue
Block a user