Skip to content

Commit

Permalink
SkinRenderer - Rename parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Jan 31, 2024
1 parent a242c7f commit f9c14ae
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions PCK-Studio/Rendering/SkinRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,15 @@ protected override void OnLoad(EventArgs e)

// Initialize skin shader
{
_skinShader = Shader.Create(Resources.skinVertexShader, Resources.skinFragmentShader);
_skinShader = Shader.Create(Resources.skinVertexShader, Resources.skinFragmentShader);
_skinShader.Validate();
_skinShader.Bind();

Texture ??= Resources.classic_template;
RenderTexture = Texture;
_skinShader.Bind();
Texture ??= Resources.classic_template;
RenderTexture = Texture;

GLErrorCheck();
}
GLErrorCheck();
}
}

public void UpdateModelData()
Expand Down Expand Up @@ -624,31 +624,37 @@ protected override void OnPaint(PaintEventArgs e)
SwapBuffers();
}

private void RenderBodyPart(Vector3 pivot, Vector3 translation, Matrix4 rotation, Matrix4 globalMatrix, params string[] additionalData)
private void RenderBodyPart(Vector3 pivot, Vector3 translation, Matrix4 partMatrix, Matrix4 globalMatrix, params string[] additionalData)
{
foreach (var data in additionalData)
{
RenderPart(data, pivot, translation, rotation, globalMatrix);
RenderPart(data, pivot, translation, partMatrix, globalMatrix);
}
}

private void RenderPart(string name, Vector3 pivot, Vector3 translation, Matrix4 rotation, Matrix4 globalMatrix)
private void RenderPart(string name, Vector3 pivot, Vector3 translation, Matrix4 partMatrix, Matrix4 globalMatrix)
{
CubeRenderGroup renderGroup = additionalModelRenderGroups[name];
float yOffset = GetOffset(name);
translation.Y -= yOffset;
pivot.Y += yOffset;
renderGroup.Submit();
RenderBuffer buffer = renderGroup.GetRenderBuffer();
var model = Matrix4.CreateTranslation(translation);
model *= Matrix4.CreateTranslation(pivot);
model *= rotation;
model *= Matrix4.CreateTranslation(pivot).Inverted();
Matrix4 model = Pivot(translation, pivot, partMatrix);
model *= globalMatrix;
_skinShader.SetUniformMat4("u_Model", ref model);
Renderer.Draw(_skinShader, buffer);
}

private static Matrix4 Pivot(Vector3 translation, Vector3 pivot, Matrix4 target)
{
var model = Matrix4.CreateTranslation(translation);
model *= Matrix4.CreateTranslation(pivot);
model *= target;
model *= Matrix4.CreateTranslation(pivot).Inverted();
return model;
}

protected override void OnMouseWheel(MouseEventArgs e)
{
camera.Distance -= e.Delta / System.Windows.Input.Mouse.MouseWheelDeltaForOneLine;
Expand Down

0 comments on commit f9c14ae

Please sign in to comment.