From 996a6032bb7a66abe0c17ee6ae408672cbab3e83 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:39:40 +0100 Subject: [PATCH] ModelRenderer - Add offset to render transform & camera --- PCK-Studio/Rendering/ModelRenderer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PCK-Studio/Rendering/ModelRenderer.cs b/PCK-Studio/Rendering/ModelRenderer.cs index e01e7355..fe0ac7ed 100644 --- a/PCK-Studio/Rendering/ModelRenderer.cs +++ b/PCK-Studio/Rendering/ModelRenderer.cs @@ -153,7 +153,7 @@ namespace PckStudio.Rendering public override void ResetCamera(Vector3 offset) { Vector3 center = (_maxBounds.Start + _maxBounds.End) / 2f; - Camera.FocalPoint = Vector3.TransformPosition(center + offset, Matrix4.CreateScale(-1f, 1f, 1f)); + Camera.FocalPoint = Vector3.TransformPosition(center - Vector3.UnitY * 24f + offset, Matrix4.CreateScale(-1f, 1f, 1f)); Camera.Distance = _maxBounds.Volume.Length; Camera.Yaw = 45f; Camera.Pitch = 25f; @@ -220,7 +220,7 @@ namespace PckStudio.Rendering _modelRenderTexture.Bind(slot: 0); Vector3 scaleVector = new Vector3(1f, -1f, -1f); - Matrix4 renderTransform = Matrix4.CreateScale(scaleVector); + Matrix4 renderTransform = Matrix4.CreateScale(scaleVector) * Matrix4.CreateTranslation(Vector3.UnitY * 24f); foreach (GenericMesh item in _rootCollection) { @@ -234,7 +234,9 @@ namespace PckStudio.Rendering highlightMatrix *= Matrix4.CreateRotationX(MathHelper.DegreesToRadians(_highlightingInfo.Rotation.X)); highlightMatrix *= Matrix4.CreateRotationY(MathHelper.DegreesToRadians(_highlightingInfo.Rotation.Y)); highlightMatrix *= Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(_highlightingInfo.Rotation.Z)); - highlightMatrix = Matrix4.CreateTranslation(_highlightingInfo.Pivot) * highlightMatrix.Pivoted(_highlightingInfo.Pivot * -1) * renderTransform; + highlightMatrix = Matrix4.CreateTranslation(_highlightingInfo.Pivot) * highlightMatrix.Pivoted(_highlightingInfo.Pivot * -1); + + highlightMatrix *= renderTransform; DrawBoundingBox(highlightMatrix, _highlightingInfo.BoundingBox, Color.HotPink); }