aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PaintingRenderer.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.Client/PaintingRenderer.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.Client/PaintingRenderer.cpp')
-rw-r--r--Minecraft.Client/PaintingRenderer.cpp164
1 files changed, 87 insertions, 77 deletions
diff --git a/Minecraft.Client/PaintingRenderer.cpp b/Minecraft.Client/PaintingRenderer.cpp
index 4238f759..f5e09dbd 100644
--- a/Minecraft.Client/PaintingRenderer.cpp
+++ b/Minecraft.Client/PaintingRenderer.cpp
@@ -6,6 +6,8 @@
#include "..\Minecraft.World\Random.h"
#include "..\Minecraft.World\Mth.h"
+ResourceLocation PaintingRenderer::PAINTING_LOCATION(TN_ART_KZ);
+
PaintingRenderer::PaintingRenderer()
{
random = new Random();
@@ -22,7 +24,7 @@ void PaintingRenderer::render(shared_ptr<Entity> _painting, double x, double y,
glTranslatef((float)x, (float)y, (float)z);
glRotatef(rot, 0, 1, 0);
glEnable(GL_RESCALE_NORMAL);
- bindTexture(TN_ART_KZ); // 4J was L"/art/kz.png"
+ bindTexture(painting); // 4J was L"/art/kz.png"
Painting::Motive *motive = painting->motive;
@@ -35,82 +37,85 @@ void PaintingRenderer::render(shared_ptr<Entity> _painting, double x, double y,
void PaintingRenderer::renderPainting(shared_ptr<Painting> painting, int w, int h, int uo, int vo)
{
- float xx0 = -w / 2.0f;
- float yy0 = -h / 2.0f;
-
- float z0 = -0.5f;
- float z1 = +0.5f;
-
- for (int xs = 0; xs < w / 16; xs++)
- for (int ys = 0; ys < h / 16; ys++)
- {
- float x0 = xx0 + (xs + 1) * 16;
- float x1 = xx0 + (xs) * 16;
- float y0 = yy0 + (ys + 1) * 16;
- float y1 = yy0 + (ys) * 16;
-
- setBrightness(painting, (x0 + x1) / 2, (y0 + y1) / 2);
-
- float fu0 = (uo + w - (xs) * 16) / 256.0f;
- float fu1 = (uo + w - (xs + 1) * 16) / 256.0f;
- float fv0 = (vo + h - (ys) * 16) / 256.0f;
- float fv1 = (vo + h - (ys + 1) * 16) / 256.0f;
-
- float bu0 = (12 * 16) / 256.0f;
- float bu1 = (12 * 16 + 16) / 256.0f;
- float bv0 = (0) / 256.0f;
- float bv1 = (0 + 16) / 256.0f;
-
- float uu0 = (12 * 16) / 256.0f;
- float uu1 = (12 * 16 + 16) / 256.0f;
- float uv0 = (0.5f) / 256.0f;
- float uv1 = (0.5f) / 256.0f;
-
- float su0 = (12 * 16 + 0.5f) / 256.0f;
- float su1 = (12 * 16 + 0.5f) / 256.0f;
- float sv0 = (0) / 256.0f;
- float sv1 = (0 + 16) / 256.0f;
-
- Tesselator *t = Tesselator::getInstance();
- t->begin();
- t->normal(0, 0, -1);
- t->vertexUV((float)(x0), (float)( y1), (float)( z0), (float)( fu1), (float)( fv0));
- t->vertexUV((float)(x1), (float)( y1), (float)( z0), (float)( fu0), (float)( fv0));
- t->vertexUV((float)(x1), (float)( y0), (float)( z0), (float)( fu0), (float)( fv1));
- t->vertexUV((float)(x0), (float)( y0), (float)( z0), (float)( fu1), (float)( fv1));
-
- t->normal(0, 0, 1);
- t->vertexUV((float)(x0), (float)( y0), (float)( z1), (float)( bu0), (float)( bv0));
- t->vertexUV((float)(x1), (float)( y0), (float)( z1), (float)( bu1), (float)( bv0));
- t->vertexUV((float)(x1), (float)( y1), (float)( z1), (float)( bu1), (float)( bv1));
- t->vertexUV((float)(x0), (float)( y1), (float)( z1), (float)( bu0), (float)( bv1));
-
- t->normal(0, 1, 0);
- t->vertexUV((float)(x0), (float)( y0), (float)( z0), (float)( uu0), (float)( uv0));
- t->vertexUV((float)(x1), (float)( y0), (float)( z0), (float)( uu1), (float)( uv0));
- t->vertexUV((float)(x1), (float)( y0), (float)( z1), (float)( uu1), (float)( uv1));
- t->vertexUV((float)(x0), (float)( y0), (float)( z1), (float)( uu0), (float)( uv1));
-
- t->normal(0, -1, 0);
- t->vertexUV((float)(x0), (float)( y1), (float)( z1), (float)( uu0), (float)( uv0));
- t->vertexUV((float)(x1), (float)( y1), (float)( z1), (float)( uu1), (float)( uv0));
- t->vertexUV((float)(x1), (float)( y1), (float)( z0), (float)( uu1), (float)( uv1));
- t->vertexUV((float)(x0), (float)( y1), (float)( z0), (float)( uu0), (float)( uv1));
-
- t->normal(-1, 0, 0);
- t->vertexUV((float)(x0), (float)( y0), (float)( z1), (float)( su1), (float)( sv0));
- t->vertexUV((float)(x0), (float)( y1), (float)( z1), (float)( su1), (float)( sv1));
- t->vertexUV((float)(x0), (float)( y1), (float)( z0), (float)( su0), (float)( sv1));
- t->vertexUV((float)(x0), (float)( y0), (float)( z0), (float)( su0), (float)( sv0));
-
- t->normal(1, 0, 0);
- t->vertexUV((float)(x1), (float)( y0), (float)( z0), (float)( su1), (float)( sv0));
- t->vertexUV((float)(x1), (float)( y1), (float)( z0), (float)( su1), (float)( sv1));
- t->vertexUV((float)(x1), (float)( y1), (float)( z1), (float)( su0), (float)( sv1));
- t->vertexUV((float)(x1), (float)( y0), (float)( z1), (float)( su0), (float)( sv0));
- t->end();
- }
-
+ float xx0 = -w / 2.0f;
+ float yy0 = -h / 2.0f;
+
+ float edgeWidth = 0.5f;
+
+ // Back
+ float bu0 = (12 * 16) / 256.0f;
+ float bu1 = (12 * 16 + 16) / 256.0f;
+ float bv0 = (0) / 256.0f;
+ float bv1 = (0 + 16) / 256.0f;
+
+ // Border
+ float uu0 = (12 * 16) / 256.0f;
+ float uu1 = (12 * 16 + 16) / 256.0f;
+ float uv0 = (0.5f) / 256.0f;
+ float uv1 = (0.5f) / 256.0f;
+
+ // Border
+ float su0 = (12 * 16 + 0.5f) / 256.0f;
+ float su1 = (12 * 16 + 0.5f) / 256.0f;
+ float sv0 = (0) / 256.0f;
+ float sv1 = (0 + 16) / 256.0f;
+
+ for (int xs = 0; xs < w / 16; xs++)
+ {
+ for (int ys = 0; ys < h / 16; ys++) {
+ float x0 = xx0 + (xs + 1) * 16;
+ float x1 = xx0 + (xs) * 16;
+ float y0 = yy0 + (ys + 1) * 16;
+ float y1 = yy0 + (ys) * 16;
+
+ setBrightness(painting, (x0 + x1) / 2, (y0 + y1) / 2);
+
+ // Painting
+ float fu0 = (uo + w - (xs) * 16) / 256.0f;
+ float fu1 = (uo + w - (xs + 1) * 16) / 256.0f;
+ float fv0 = (vo + h - (ys) * 16) / 256.0f;
+ float fv1 = (vo + h - (ys + 1) * 16) / 256.0f;
+
+ Tesselator *t = Tesselator::getInstance();
+ t->begin();
+ t->normal(0, 0, -1);
+ t->vertexUV(x0, y1, -edgeWidth, fu1, fv0);
+ t->vertexUV(x1, y1, -edgeWidth, fu0, fv0);
+ t->vertexUV(x1, y0, -edgeWidth, fu0, fv1);
+ t->vertexUV(x0, y0, -edgeWidth, fu1, fv1);
+
+ t->normal(0, 0, 1);
+ t->vertexUV(x0, y0, edgeWidth, bu0, bv0);
+ t->vertexUV(x1, y0, edgeWidth, bu1, bv0);
+ t->vertexUV(x1, y1, edgeWidth, bu1, bv1);
+ t->vertexUV(x0, y1, edgeWidth, bu0, bv1);
+
+ t->normal(0, 1, 0);
+ t->vertexUV(x0, y0, -edgeWidth, uu0, uv0);
+ t->vertexUV(x1, y0, -edgeWidth, uu1, uv0);
+ t->vertexUV(x1, y0, edgeWidth, uu1, uv1);
+ t->vertexUV(x0, y0, edgeWidth, uu0, uv1);
+
+ t->normal(0, -1, 0);
+ t->vertexUV(x0, y1, edgeWidth, uu0, uv0);
+ t->vertexUV(x1, y1, edgeWidth, uu1, uv0);
+ t->vertexUV(x1, y1, -edgeWidth, uu1, uv1);
+ t->vertexUV(x0, y1, -edgeWidth, uu0, uv1);
+
+ t->normal(-1, 0, 0);
+ t->vertexUV(x0, y0, edgeWidth, su1, sv0);
+ t->vertexUV(x0, y1, edgeWidth, su1, sv1);
+ t->vertexUV(x0, y1, -edgeWidth, su0, sv1);
+ t->vertexUV(x0, y0, -edgeWidth, su0, sv0);
+
+ t->normal(1, 0, 0);
+ t->vertexUV(x1, y0, -edgeWidth, su1, sv0);
+ t->vertexUV(x1, y1, -edgeWidth, su1, sv1);
+ t->vertexUV(x1, y1, edgeWidth, su0, sv1);
+ t->vertexUV(x1, y0, edgeWidth, su0, sv0);
+ t->end();
+ }
+ }
}
void PaintingRenderer::setBrightness(shared_ptr<Painting> painting, float ss, float ya)
@@ -128,4 +133,9 @@ void PaintingRenderer::setBrightness(shared_ptr<Painting> painting, float ss, fl
int v = col / 65536;
glMultiTexCoord2f(0, u, v);
glColor3f(1, 1, 1);
+}
+
+ResourceLocation *PaintingRenderer::getTextureLocation(shared_ptr<Entity> mob)
+{
+ return &PAINTING_LOCATION;
} \ No newline at end of file