diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj
index 87b8a761..9ef9405a 100644
--- a/PCK-Studio/PckStudio.csproj
+++ b/PCK-Studio/PckStudio.csproj
@@ -651,11 +651,11 @@
-
+
-
+
@@ -712,7 +712,7 @@
-
+
diff --git a/PCK-Studio/Properties/Resources.Designer.cs b/PCK-Studio/Properties/Resources.Designer.cs
index cefd3304..7f174008 100644
--- a/PCK-Studio/Properties/Resources.Designer.cs
+++ b/PCK-Studio/Properties/Resources.Designer.cs
@@ -815,16 +815,26 @@ namespace PckStudio.Properties {
}
///
- /// Looks up a localized string similar to // TODO: Add parent detection
- ///
- ///{
+ /// Looks up a localized string similar to {
/// "bat": {
/// "textureLocations": [
/// "res/mob/bat"
/// ],
- /// "parents": {
- /// "rightEar": "head",
- /// "leftEar": "head"
+ /// "root": {
+ /// "head": [
+ /// "rightEar",
+ /// "leftEar"
+ /// ],
+ /// "body": [
+ /// {
+ /// "rightWing": [
+ /// "rightWingTip"
+ /// ],
+ /// "leftWing": [
+ /// "leftWingTip"
+ /// ]
+ /// }
+ /// ]
/// }
/// },
/// "bed": {
@@ -836,14 +846,9 @@ namespace PckStudio.Properties {
/// "textureLocations": [
/// "res/mob/fire"
/// ]
- ///
/// },
/// "boat": {
- /// "textureLocations": [
- /// "res/item/boat/boat_acacia",
- /// "res/item/boat/boat_birch",
- /// "res/item/boat/boat_darkoak",
- /// "res/item/boat/boat [rest of string was truncated]";.
+ /// [rest of string was truncated]";.
///
public static string modelMetaData {
get {
@@ -1161,61 +1166,6 @@ namespace PckStudio.Properties {
}
}
- ///
- /// Looks up a localized string similar to #version 330 core
- ///
- ///layout(location = 0) out vec4 color;
- ///
- ///uniform sampler2D u_Texture;
- ///
- ///in vec2 o_TillingFactor;
- ///in vec2 o_TexCoord;
- ///
- ///void main()
- ///{
- /// color = texture(u_Texture, o_TexCoord * o_TillingFactor);
- ///};.
- ///
- public static string skinFragmentShader {
- get {
- return ResourceManager.GetString("skinFragmentShader", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to #version 330 core
- ///
- ///layout (triangles) in;
- ///layout (triangle_strip, max_vertices=3) out;
- ///
- ///uniform vec2 u_TexSize;
- ///
- ///out vec2 o_TexCoord;
- ///out vec2 o_TillingFactor;
- ///
- ///in geometryData
- ///{
- /// vec2 TexCoord;
- ///} dataIn[];
- ///
- ///void FixUV()
- ///{
- /// bool isXBad =
- /// dataIn[0].TexCoord.x >= u_TexSize.x &&
- /// dataIn[1].TexCoord.x >= u_TexSize.x &&
- /// dataIn[2].TexCoord.x >= u_TexSize.x;
- ///
- /// gl_Position = gl_in[0].gl_Position;
- /// o_TexCoord = dataIn[0].TexCoord;
- /// if (isXBad)
- /// o_TexCoord.x = mod(o_TexCoord.x, u_TexSiz [rest of string was truncated]";.
- ///
- public static string skinGeometryShader {
- get {
- return ResourceManager.GetString("skinGeometryShader", resourceCulture);
- }
- }
-
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -1226,32 +1176,6 @@ namespace PckStudio.Properties {
}
}
- ///
- /// Looks up a localized string similar to #version 330 core
- ///
- ///layout(location = 0) in vec3 vertexPosition;
- ///layout(location = 1) in vec2 texCoord;
- ///
- ///uniform mat4 u_ViewProjection;
- ///uniform mat4 u_Transform;
- ///
- ///out geometryData
- ///{
- /// vec2 TexCoord;
- ///} dataOut;
- ///
- ///void main()
- ///{
- /// dataOut.TexCoord = texCoord;
- /// gl_Position = u_ViewProjection * u_Transform * vec4(vertexPosition, 1.0);
- ///};.
- ///
- public static string skinVertexShader {
- get {
- return ResourceManager.GetString("skinVertexShader", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to #version 330 core
///
@@ -1325,6 +1249,87 @@ namespace PckStudio.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to #version 330 core
+ ///
+ ///layout(location = 0) out vec4 color;
+ ///
+ ///uniform sampler2D u_Texture;
+ ///
+ ///in vec2 o_TillingFactor;
+ ///in vec2 o_TexCoord;
+ ///
+ ///void main()
+ ///{
+ /// color = texture(u_Texture, o_TexCoord * o_TillingFactor);
+ ///};.
+ ///
+ public static string texturedCubeFragmentShader {
+ get {
+ return ResourceManager.GetString("texturedCubeFragmentShader", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to #version 330 core
+ ///
+ ///layout (triangles) in;
+ ///layout (triangle_strip, max_vertices=3) out;
+ ///
+ ///uniform vec2 u_TexSize;
+ ///
+ ///out vec2 o_TexCoord;
+ ///out vec2 o_TillingFactor;
+ ///
+ ///in geometryData
+ ///{
+ /// vec2 TexCoord;
+ ///} dataIn[];
+ ///
+ ///void FixUV()
+ ///{
+ /// bool isXBad =
+ /// dataIn[0].TexCoord.x >= u_TexSize.x &&
+ /// dataIn[1].TexCoord.x >= u_TexSize.x &&
+ /// dataIn[2].TexCoord.x >= u_TexSize.x;
+ ///
+ /// gl_Position = gl_in[0].gl_Position;
+ /// o_TexCoord = dataIn[0].TexCoord;
+ /// if (isXBad)
+ /// o_TexCoord.x = mod(o_TexCoord.x, u_TexSiz [rest of string was truncated]";.
+ ///
+ public static string texturedCubeGeometryShader {
+ get {
+ return ResourceManager.GetString("texturedCubeGeometryShader", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to #version 330 core
+ ///
+ ///layout(location = 0) in vec3 vertexPosition;
+ ///layout(location = 1) in vec2 texCoord;
+ ///
+ ///uniform mat4 u_ViewProjection;
+ ///uniform mat4 u_Transform;
+ ///
+ ///out geometryData
+ ///{
+ /// vec2 TexCoord;
+ ///} dataOut;
+ ///
+ ///void main()
+ ///{
+ /// dataOut.TexCoord = texCoord;
+ /// gl_Position = u_ViewProjection * u_Transform * vec4(vertexPosition, 1.0);
+ ///};.
+ ///
+ public static string texturedCubeVertexShader {
+ get {
+ return ResourceManager.GetString("texturedCubeVertexShader", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/PCK-Studio/Properties/Resources.resx b/PCK-Studio/Properties/Resources.resx
index 524e4da9..93b5dcad 100644
--- a/PCK-Studio/Properties/Resources.resx
+++ b/PCK-Studio/Properties/Resources.resx
@@ -379,11 +379,11 @@
..\Resources\icons\Replace.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\Resources\shader\skinVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ ..\Resources\shader\texturedCubeVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
- ..\Resources\shader\skinFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ ..\Resources\shader\texturedCubeFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
..\Resources\skybox_texture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -394,8 +394,8 @@
..\Resources\shader\skyboxVertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
- ..\Resources\shader\skinGeometryShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ ..\Resources\shader\texturedCubeGeometryShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
..\Resources\shader\framebufferFragmentShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
diff --git a/PCK-Studio/Rendering/SceneViewport.cs b/PCK-Studio/Rendering/SceneViewport.cs
index 8136de6e..d855c86f 100644
--- a/PCK-Studio/Rendering/SceneViewport.cs
+++ b/PCK-Studio/Rendering/SceneViewport.cs
@@ -96,7 +96,6 @@ namespace PckStudio.Rendering
public SceneViewport() : base()
{
VSync = true;
- RefreshRate = _refreshRate;
_stopwatch = new Stopwatch();
_timer = new Timer();
_timer.Tick += TimerTick;
@@ -106,6 +105,7 @@ namespace PckStudio.Rendering
_stopwatch.Start();
}
+ RefreshRate = _refreshRate;
Camera = new PerspectiveCamera(60f, new Vector3(0f, 0f, 0f));
_shaderLibrary = new ShaderLibrary();
_initialized = false;
diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs
index 50a9c5d5..8e82b938 100644
--- a/PCK-Studio/Rendering/SkinRenderer.cs
+++ b/PCK-Studio/Rendering/SkinRenderer.cs
@@ -309,11 +309,16 @@ namespace PckStudio.Rendering
private void InitializeSkinData()
{
- head ??= new CubeMeshCollection("Head") { FlipZMapping = true };
+ ModelPartSpecifics.PositioningInfo headInfo = ModelPartSpecifics.GetPositioningInfo("HEAD");
+ head ??= new CubeMeshCollection("Head", headInfo.Translation.ToOpenTKVector(), headInfo.Pivot.ToOpenTKVector())
+ {
+ FlipZMapping = true
+ };
head.AddNamed("DefaultHead", new(-4, -8, -4), new(8, 8, 8), new(0, 0));
head.AddNamed("DefaultHeadOverlay", new(-4, -8, -4), new(8, 8, 8), new(32, 0), OverlayScale * 2);
- body ??= new CubeMeshCollection("Body");
+ ModelPartSpecifics.PositioningInfo bodyInfo = ModelPartSpecifics.GetPositioningInfo("BODY");
+ body ??= new CubeMeshCollection("Body", bodyInfo.Translation.ToOpenTKVector(), bodyInfo.Pivot.ToOpenTKVector());
body.AddNamed("DefaultBody",new(-4, 0, -2), new(8, 12, 4), new(16, 16));
body.AddNamed("DefaultBodyOverlay", new(-4, 0, -2), new(8, 12, 4), new(16, 32), OverlayScale);
@@ -405,15 +410,15 @@ namespace PckStudio.Rendering
// Skin shader
{
- var skinShader = ShaderProgram.Create(
- new ShaderSource(ShaderType.VertexShader, Resources.skinVertexShader),
- new ShaderSource(ShaderType.FragmentShader, Resources.skinFragmentShader),
- new ShaderSource(ShaderType.GeometryShader, Resources.skinGeometryShader)
+ var cubeShader = ShaderProgram.Create(
+ new ShaderSource(ShaderType.VertexShader, Resources.texturedCubeVertexShader),
+ new ShaderSource(ShaderType.FragmentShader, Resources.texturedCubeFragmentShader),
+ new ShaderSource(ShaderType.GeometryShader, Resources.texturedCubeGeometryShader)
);
- skinShader.Bind();
- skinShader.SetUniform1("u_Texture", 0);
- skinShader.Validate();
- AddShader("SkinShader", skinShader);
+ cubeShader.Bind();
+ cubeShader.SetUniform1("u_Texture", 0);
+ cubeShader.Validate();
+ AddShader("CubeShader", cubeShader);
GLErrorCheck();
armorTexture = new Texture2D(0);
@@ -865,10 +870,10 @@ namespace PckStudio.Rendering
Matrix4 transform = Matrix4.Identity;
- ShaderProgram skinShader = GetShader("SkinShader");
- skinShader.Bind();
- skinShader.SetUniformMat4("u_ViewProjection", ref viewProjection);
- skinShader.SetUniform2("u_TexSize", new Vector2(TextureSize.Width, TextureSize.Height));
+ ShaderProgram cubeShader = GetShader("CubeShader");
+ cubeShader.Bind();
+ cubeShader.SetUniformMat4("u_ViewProjection", ref viewProjection);
+ cubeShader.SetUniform2("u_TexSize", new Vector2(TextureSize.Width, TextureSize.Height));
skinTexture.Bind();
@@ -910,16 +915,16 @@ namespace PckStudio.Rendering
armLeftMatrix = LeftArmMatrix * armLeftMatrix;
}
- RenderBodyPart(skinShader, Matrix4.Identity, transform, "HEAD", "HEADWEAR");
- RenderBodyPart(skinShader, Matrix4.Identity, transform, "BODY", "JACKET");
- RenderBodyPart(skinShader, armRightMatrix, transform, "ARM0", "SLEEVE0");
- RenderBodyPart(skinShader, armLeftMatrix, transform, "ARM1", "SLEEVE1");
- RenderBodyPart(skinShader, legRightMatrix, transform, "LEG0", "PANTS0");
- RenderBodyPart(skinShader, legLeftMatrix, transform, "LEG1", "PANTS1");
+ RenderBodyPart(cubeShader, Matrix4.Identity, transform, "HEAD", "HEADWEAR");
+ RenderBodyPart(cubeShader, Matrix4.Identity, transform, "BODY", "JACKET");
+ RenderBodyPart(cubeShader, armRightMatrix, transform, "ARM0", "SLEEVE0");
+ RenderBodyPart(cubeShader, armLeftMatrix, transform, "ARM1", "SLEEVE1");
+ RenderBodyPart(cubeShader, legRightMatrix, transform, "LEG0", "PANTS0");
+ RenderBodyPart(cubeShader, legLeftMatrix, transform, "LEG1", "PANTS1");
if (_capeImage is not null)
{
- skinShader.SetUniform2("u_TexSize", new Vector2(64, 32));
+ cubeShader.SetUniform2("u_TexSize", new Vector2(64, 32));
capeTexture.Bind();
// Defines minimum Angle(in Degrees) of the cape
float capeMinimumRotationAngle = 7.5f;
@@ -931,43 +936,42 @@ namespace PckStudio.Rendering
Matrix4 partMatrix =
Matrix4.CreateRotationY(MathHelper.DegreesToRadians(180f)) *
Matrix4.CreateRotationX(MathHelper.DegreesToRadians(capeRotation));
- RenderPart(skinShader, cape, partMatrix, transform);
+ RenderPart(cubeShader, cape, partMatrix, transform);
}
// Armor rendering
if (ShowArmor && !ANIM.GetFlag(SkinAnimFlag.ALL_ARMOR_DISABLED))
{
armorTexture.Bind();
- //skinShader.SetUniform4("u_Color", Color.FromArgb(0xff << 24 | Color.White.ToArgb() - _outlineColor.ToArgb()));
- skinShader.SetUniform2("u_TexSize", new Vector2(64, 64));
+ cubeShader.SetUniform2("u_TexSize", new Vector2(64, 64));
if (!ANIM.GetFlag(SkinAnimFlag.HEAD_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_HEAD_ARMOR))
- RenderPart(skinShader, offsetSpecificMeshStorage["HELMET"], Matrix4.Identity, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["HELMET"], Matrix4.Identity, transform);
if (!ANIM.GetFlag(SkinAnimFlag.BODY_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_BODY_ARMOR))
- RenderPart(skinShader, offsetSpecificMeshStorage["CHEST"], Matrix4.Identity, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["CHEST"], Matrix4.Identity, transform);
if (!ANIM.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_RIGHT_ARM_ARMOR))
- RenderPart(skinShader, offsetSpecificMeshStorage["SHOULDER0"], RightArmMatrix * armRightMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["SHOULDER0"], RightArmMatrix * armRightMatrix, transform);
if (!ANIM.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_LEFT_ARM_ARMOR))
- RenderPart(skinShader, offsetSpecificMeshStorage["SHOULDER1"], LeftArmMatrix * armLeftMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["SHOULDER1"], LeftArmMatrix * armLeftMatrix, transform);
bool showRightLegArmor = !ANIM.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_RIGHT_LEG_ARMOR);
if (showRightLegArmor)
{
- RenderPart(skinShader, offsetSpecificMeshStorage["PANTS0"], legRightMatrix, transform);
- RenderPart(skinShader, offsetSpecificMeshStorage["BOOT0"], legRightMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["PANTS0"], legRightMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["BOOT0"], legRightMatrix, transform);
}
bool showLeftLegArmor = !ANIM.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED) || ANIM.GetFlag(SkinAnimFlag.FORCE_LEFT_LEG_ARMOR);
if (showLeftLegArmor)
{
- RenderPart(skinShader, offsetSpecificMeshStorage["PANTS1"], legLeftMatrix, transform);
- RenderPart(skinShader, offsetSpecificMeshStorage["BOOT1"], legLeftMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["PANTS1"], legLeftMatrix, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["BOOT1"], legLeftMatrix, transform);
}
if (showRightLegArmor && showLeftLegArmor)
- RenderPart(skinShader, offsetSpecificMeshStorage["WAIST"], Matrix4.Identity, transform);
+ RenderPart(cubeShader, offsetSpecificMeshStorage["WAIST"], Matrix4.Identity, transform);
}
if (showWireFrame)
diff --git a/PCK-Studio/Resources/shader/skinFragmentShader.glsl b/PCK-Studio/Resources/shader/texturedCubeFragmentShader.glsl
similarity index 100%
rename from PCK-Studio/Resources/shader/skinFragmentShader.glsl
rename to PCK-Studio/Resources/shader/texturedCubeFragmentShader.glsl
diff --git a/PCK-Studio/Resources/shader/skinGeometryShader.glsl b/PCK-Studio/Resources/shader/texturedCubeGeometryShader.glsl
similarity index 100%
rename from PCK-Studio/Resources/shader/skinGeometryShader.glsl
rename to PCK-Studio/Resources/shader/texturedCubeGeometryShader.glsl
diff --git a/PCK-Studio/Resources/shader/skinVertexShader.glsl b/PCK-Studio/Resources/shader/texturedCubeVertexShader.glsl
similarity index 100%
rename from PCK-Studio/Resources/shader/skinVertexShader.glsl
rename to PCK-Studio/Resources/shader/texturedCubeVertexShader.glsl