mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-12 10:48:09 +00:00
SceneViewport - Change 'Transform' to 'GetTransform'
This commit is contained in:
@@ -51,8 +51,6 @@ namespace PckStudio.Rendering
|
||||
22, 23, 20
|
||||
];
|
||||
|
||||
public override Matrix4 Transform => Matrix4.Identity;
|
||||
|
||||
internal static VertexBufferLayout VertexBufferLayout { get; } = new VertexBufferLayout().Add(ShaderDataType.Float3).Add(ShaderDataType.Float2);
|
||||
|
||||
public CubeMesh(Cube cube) : this(nameof(CubeMesh), cube)
|
||||
@@ -79,9 +77,14 @@ namespace PckStudio.Rendering
|
||||
|
||||
public Cube GetCube() => _cube;
|
||||
|
||||
public override Matrix4 GetTransform()
|
||||
{
|
||||
return Matrix4.Identity;
|
||||
}
|
||||
|
||||
public override BoundingBox GetBounds(Matrix4 transform)
|
||||
{
|
||||
return _cube.GetBoundingBox(Transform * transform);
|
||||
return _cube.GetBoundingBox(GetTransform() * transform);
|
||||
}
|
||||
|
||||
internal override IEnumerable<TextureVertex> GetVertices()
|
||||
@@ -90,7 +93,7 @@ namespace PckStudio.Rendering
|
||||
|
||||
Vector2 uv = _cube.Uv;
|
||||
|
||||
BoundingBox boundingBox = GetBounds(Transform);
|
||||
BoundingBox boundingBox = GetBounds(GetTransform());
|
||||
Vector3 from = boundingBox.Start;
|
||||
Vector3 to = boundingBox.End;
|
||||
|
||||
|
||||
@@ -58,7 +58,16 @@ namespace PckStudio.Rendering
|
||||
set => _offset = value;
|
||||
}
|
||||
|
||||
public override Matrix4 Transform => (Matrix4.CreateRotationX(MathHelper.DegreesToRadians(Rotation.X)) * Matrix4.CreateRotationY(MathHelper.DegreesToRadians(Rotation.Y)) * Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Rotation.Z))).Pivoted(Translation + _offset, Pivot);
|
||||
public override Matrix4 GetTransform()
|
||||
{
|
||||
Matrix4 rotations = (
|
||||
Matrix4.CreateRotationX(MathHelper.DegreesToRadians(Rotation.X)) *
|
||||
Matrix4.CreateRotationY(MathHelper.DegreesToRadians(Rotation.Y)) *
|
||||
Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Rotation.Z))
|
||||
);
|
||||
Matrix4 translation = Matrix4.CreateTranslation(Translation + Offset);
|
||||
return translation * (rotations).Pivoted(Pivot - Offset);
|
||||
}
|
||||
|
||||
public int Count => cubes.Count;
|
||||
|
||||
@@ -92,7 +101,7 @@ namespace PckStudio.Rendering
|
||||
|
||||
internal override IEnumerable<TextureVertex> GetVertices()
|
||||
=> cubes.Where(c => c.Visible).SelectMany(c =>
|
||||
c.GetVertices().Select(vertex => new TextureVertex(Vector3.TransformPosition(vertex.Position, c.Transform), vertex.TexPosition))
|
||||
c.GetVertices().Select(vertex => new TextureVertex(Vector3.TransformPosition(vertex.Position, c.GetTransform()), vertex.TexPosition))
|
||||
);
|
||||
|
||||
internal override IEnumerable<int> GetIndices()
|
||||
@@ -156,7 +165,7 @@ namespace PckStudio.Rendering
|
||||
if (!cubes.IndexInRange(index))
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
return cubes[index].GetBounds(Transform).Center;
|
||||
return cubes[index].GetBounds(GetTransform()).Center;
|
||||
}
|
||||
|
||||
internal BoundingBox GetCubeBoundingBox(int index)
|
||||
@@ -164,14 +173,14 @@ namespace PckStudio.Rendering
|
||||
if (!cubes.IndexInRange(index))
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
return cubes[index].GetBounds(Transform);
|
||||
return cubes[index].GetBounds(GetTransform());
|
||||
}
|
||||
|
||||
public override BoundingBox GetBounds(Matrix4 transform)
|
||||
{
|
||||
IEnumerable<BoundingBox> boundingBoxes = cubes
|
||||
.Where(c => c.Visible)
|
||||
.Select(c => c.GetBounds(Transform * transform));
|
||||
.Select(c => c.GetBounds(GetTransform() * transform))
|
||||
return BoundingBox.GetEnclosingBoundingBox(boundingBoxes);
|
||||
}
|
||||
|
||||
@@ -181,7 +190,7 @@ namespace PckStudio.Rendering
|
||||
throw new IndexOutOfRangeException();
|
||||
|
||||
Vector3 faceCenter = cubes[index] is CubeMesh c ? c.GetCube().GetFaceCenter(face) : Vector3.Zero;
|
||||
return Vector3.TransformPosition(faceCenter, Transform);
|
||||
return Vector3.TransformPosition(faceCenter, GetTransform());
|
||||
}
|
||||
|
||||
internal void SetVisible(int index, bool visible)
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace PckStudio.Rendering
|
||||
internal VertexBufferLayout VertexLayout { get; }
|
||||
internal bool Visible { get; }
|
||||
|
||||
public abstract Matrix4 Transform { get; }
|
||||
|
||||
protected GenericMesh(string name, bool visible, PrimitiveType type, VertexBufferLayout vertexLayout)
|
||||
{
|
||||
@@ -41,6 +40,7 @@ namespace PckStudio.Rendering
|
||||
|
||||
public abstract GenericMesh<T> SetVisible(bool visible);
|
||||
public abstract BoundingBox GetBounds(Matrix4 transform);
|
||||
public abstract Matrix4 GetTransform();
|
||||
|
||||
internal abstract IEnumerable<T> GetVertices();
|
||||
internal abstract IEnumerable<int> GetIndices();
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace PckStudio.Rendering
|
||||
|
||||
foreach (CubeMeshCollection item in _rootCollection)
|
||||
{
|
||||
DrawMesh(item, shader, item.Transform * Matrix4.CreateScale(1f, -1f, -1f));
|
||||
DrawMesh(item, shader, item.GetTransform() * Matrix4.CreateScale(1f, -1f, -1f));
|
||||
}
|
||||
_modelRenderTexture.Unbind();
|
||||
}
|
||||
|
||||
@@ -1055,7 +1055,7 @@ namespace PckStudio.Rendering
|
||||
float inflate = autoInflateOverlayParts && box.IsOverlayPart() ? box.Type == "HEADWEAR" ? OverlayScale * 2 : OverlayScale : 0f;
|
||||
Cube cube = box.ToCube(inflate);
|
||||
CubeMeshCollection cubeMesh = meshStorage[box.Type];
|
||||
yield return cube.GetBoundingBox(cubeMesh.Transform);
|
||||
yield return cube.GetBoundingBox(cubeMesh.GetTransform());
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
@@ -1072,7 +1072,7 @@ namespace PckStudio.Rendering
|
||||
|
||||
private void RenderPart<T>(ShaderProgram shader, GenericMesh<T> mesh, Matrix4 partMatrix, Matrix4 globalMatrix) where T : struct
|
||||
{
|
||||
Matrix4 transform = partMatrix * mesh.Transform * globalMatrix;
|
||||
Matrix4 transform = partMatrix * mesh.GetTransform() * globalMatrix;
|
||||
DrawMesh(mesh, shader, transform);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user