Fix scaled textures in ModelBlockModel patches
This commit is contained in:
parent
7121233462
commit
ff2e1b3b50
5 changed files with 28 additions and 27 deletions
|
|
@ -1033,6 +1033,7 @@ public class HDBlockModels {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log.severe(String.format("Invalid modellist patch for box %f/%f/%f:%f/%f/%f side %s at line %d", bl.from[0], bl.from[1], bl.from[2], bl.to[0], bl.to[1], bl.to[2], side.side, lineNum));
|
Log.severe(String.format("Invalid modellist patch for box %f/%f/%f:%f/%f/%f side %s at line %d", bl.from[0], bl.from[1], bl.from[2], bl.to[0], bl.to[1], bl.to[2], side.side, lineNum));
|
||||||
|
Log.severe(String.format("line = %s:%s", typeid, line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.dynmap.renderer.RenderPatchFactory.SideVisible;
|
||||||
import org.dynmap.utils.PatchDefinition;
|
import org.dynmap.utils.PatchDefinition;
|
||||||
import org.dynmap.utils.PatchDefinitionFactory;
|
import org.dynmap.utils.PatchDefinitionFactory;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class ModModelDefinitionImpl implements ModModelDefinition {
|
public class ModModelDefinitionImpl implements ModModelDefinition {
|
||||||
private final ModTextureDefinitionImpl txtDef;
|
private final ModTextureDefinitionImpl txtDef;
|
||||||
private boolean published = false;
|
private boolean published = false;
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package org.dynmap.modsupport.impl;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.dynmap.modsupport.BlockSide;
|
import org.dynmap.modsupport.BlockSide;
|
||||||
import org.dynmap.modsupport.ModelBlockModel;
|
import org.dynmap.modsupport.ModelBlockModel;
|
||||||
|
|
@ -60,8 +58,8 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
|
||||||
fromBlockSide.put(BlockSide.BOTTOM, "d");
|
fromBlockSide.put(BlockSide.BOTTOM, "d");
|
||||||
fromBlockSide.put(BlockSide.NORTH, "n");
|
fromBlockSide.put(BlockSide.NORTH, "n");
|
||||||
fromBlockSide.put(BlockSide.SOUTH, "s");
|
fromBlockSide.put(BlockSide.SOUTH, "s");
|
||||||
fromBlockSide.put(BlockSide.WEST, "e");
|
fromBlockSide.put(BlockSide.WEST, "w");
|
||||||
fromBlockSide.put(BlockSide.EAST, "w");
|
fromBlockSide.put(BlockSide.EAST, "e");
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -221,26 +221,26 @@ public class PatchDefinition implements RenderPatch {
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
boolean good = true;
|
boolean good = true;
|
||||||
// Compute visible corners to see if we're inside cube
|
// Compute visible corners to see if we're inside cube
|
||||||
double xx0 = x0 + (xu - x0) * umin;
|
double xx0 = x0 + (xu - x0) * umin + (xv - x0) * vmin;
|
||||||
double xx1 = x0 + (xv - x0) * vmin;
|
double xx1 = x0 + (xu - x0) * vmin + (xv - x0) * vmax;
|
||||||
double xx2 = x0 + (xu - x0) * umax;
|
double xx2 = x0 + (xu - x0) * umax + (xv - x0) * vmin;
|
||||||
double xx3 = x0 + (xv - x0) * vmax;
|
double xx3 = x0 + (xu - x0) * vmax + (xv - x0) * vmax;;
|
||||||
if (outOfRange(xx0) || outOfRange(xx1) || outOfRange(xx2) || outOfRange(xx3)) {
|
if (outOfRange(xx0) || outOfRange(xx1) || outOfRange(xx2) || outOfRange(xx3)) {
|
||||||
Log.severe(String.format("Invalid visible range xu=[%f:%f], xv=[%f:%f]", xx0, xx2, xx1, xx3));
|
Log.severe(String.format("Invalid visible range xu=[%f:%f], xv=[%f:%f]", xx0, xx2, xx1, xx3));
|
||||||
good = false;
|
good = false;
|
||||||
}
|
}
|
||||||
double yy0 = y0 + (yu - y0) * umin;
|
double yy0 = y0 + (yu - y0) * umin + (yv - y0) * vmin;
|
||||||
double yy1 = y0 + (yv - y0) * vmin;
|
double yy1 = y0 + (yu - y0) * vmin + (yv - y0) * vmax;
|
||||||
double yy2 = y0 + (yu - y0) * umax;
|
double yy2 = y0 + (yu - y0) * umax + (yv - y0) * vmin;
|
||||||
double yy3 = y0 + (yv - y0) * vmax;
|
double yy3 = y0 + (yu - y0) * vmax + (yv - y0) * vmax;;
|
||||||
if (outOfRange(yy0) || outOfRange(yy1) || outOfRange(yy2) || outOfRange(yy3)) {
|
if (outOfRange(yy0) || outOfRange(yy1) || outOfRange(yy2) || outOfRange(yy3)) {
|
||||||
Log.severe(String.format("Invalid visible range yu=[%f:%f], yv=[%f:%f]", yy0, yy2, yy1, yy3));
|
Log.severe(String.format("Invalid visible range yu=[%f:%f], yv=[%f:%f]", yy0, yy2, yy1, yy3));
|
||||||
good = false;
|
good = false;
|
||||||
}
|
}
|
||||||
double zz0 = z0 + (zu - z0) * umin;
|
double zz0 = z0 + (zu - z0) * umin + (zv - z0) * vmin;
|
||||||
double zz1 = z0 + (zv - z0) * vmin;
|
double zz1 = z0 + (zu - z0) * vmin + (zv - z0) * vmax;
|
||||||
double zz2 = z0 + (zu - z0) * umax;
|
double zz2 = z0 + (zu - z0) * umax + (zv - z0) * vmin;
|
||||||
double zz3 = z0 + (zv - z0) * vmax;
|
double zz3 = z0 + (zu - z0) * vmax + (zv - z0) * vmax;
|
||||||
if (outOfRange(zz0) || outOfRange(zz1) || outOfRange(zz2) || outOfRange(zz3)) {
|
if (outOfRange(zz0) || outOfRange(zz1) || outOfRange(zz2) || outOfRange(zz3)) {
|
||||||
Log.severe(String.format("Invalid visible range zu=[%f:%f], zv=[%f:%f]", zz0, zz2, zz1, zz3));
|
Log.severe(String.format("Invalid visible range zu=[%f:%f], zv=[%f:%f]", zz0, zz2, zz1, zz3));
|
||||||
good = false;
|
good = false;
|
||||||
|
|
@ -315,6 +315,7 @@ public class PatchDefinition implements RenderPatch {
|
||||||
if (patchuv[0] > patchuv[2]) { flipU = true; double save = patchuv[0]; patchuv[0] = patchuv[2]; patchuv[2] = save; }
|
if (patchuv[0] > patchuv[2]) { flipU = true; double save = patchuv[0]; patchuv[0] = patchuv[2]; patchuv[2] = save; }
|
||||||
if (patchuv[1] > patchuv[3]) { flipV = true; double save = patchuv[1]; patchuv[1] = patchuv[3]; patchuv[3] = save; }
|
if (patchuv[1] > patchuv[3]) { flipV = true; double save = patchuv[1]; patchuv[1] = patchuv[3]; patchuv[3] = save; }
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
case FACE_0:
|
case FACE_0:
|
||||||
|
|
@ -423,7 +424,6 @@ public class PatchDefinition implements RenderPatch {
|
||||||
upleft = upright;
|
upleft = upright;
|
||||||
upright = save;
|
upright = save;
|
||||||
}
|
}
|
||||||
//System.out.println(String.format("ll=%s, lr=%s, ul=%s, ur=%s", lowleft, lowright, upleft, upright));
|
|
||||||
// Compute texture origin, based on corners and patchuv
|
// Compute texture origin, based on corners and patchuv
|
||||||
Vector3D txtorig = new Vector3D();
|
Vector3D txtorig = new Vector3D();
|
||||||
Vector3D txtU = new Vector3D();
|
Vector3D txtU = new Vector3D();
|
||||||
|
|
@ -435,12 +435,12 @@ public class PatchDefinition implements RenderPatch {
|
||||||
double du = patchuv[2] - patchuv[0];
|
double du = patchuv[2] - patchuv[0];
|
||||||
txtU.set(lowright).subtract(lowleft); // vector along U
|
txtU.set(lowright).subtract(lowleft); // vector along U
|
||||||
double uScale = txtU.length() / du;
|
double uScale = txtU.length() / du;
|
||||||
txtU.scale(uScale / du); // Compute full U vect
|
txtU.scale(uScale / txtU.length()); // Compute full U vect
|
||||||
// Compute V axis
|
// Compute V axis
|
||||||
double dv = patchuv[3] - patchuv[1];
|
double dv = patchuv[3] - patchuv[1];
|
||||||
txtV.set(upleft).subtract(lowleft); // vector along V
|
txtV.set(upleft).subtract(lowleft); // vector along V
|
||||||
double vScale = txtV.length() / dv;
|
double vScale = txtV.length() / dv;
|
||||||
txtV.scale(vScale / dv); // Compute full V vect
|
txtV.scale(vScale / txtV.length()); // Compute full V vect
|
||||||
// Compute texture origin
|
// Compute texture origin
|
||||||
txtorig.set(txtU).scale(-patchuv[0]).add(lowleft);
|
txtorig.set(txtU).scale(-patchuv[0]).add(lowleft);
|
||||||
wrk.set(txtV).scale(-patchuv[1]);
|
wrk.set(txtV).scale(-patchuv[1]);
|
||||||
|
|
@ -449,8 +449,6 @@ public class PatchDefinition implements RenderPatch {
|
||||||
txtU.add(txtorig); // And add it for full U
|
txtU.add(txtorig); // And add it for full U
|
||||||
txtV.add(txtorig); // And add it to compute full V
|
txtV.add(txtorig); // And add it to compute full V
|
||||||
}
|
}
|
||||||
// System.out.println(String.format("txtO=%s, txtU=%s, txtV=%s, uv=%f/%f/%f/%f", txtorig, txtU, txtV, patchuv[0], patchuv[1], patchuv[2],
|
|
||||||
// patchuv[3]));
|
|
||||||
update(txtorig.x, txtorig.y, txtorig.z, txtU.x, txtU.y, txtU.z, txtV.x, txtV.y, txtV.z,
|
update(txtorig.x, txtorig.y, txtorig.z, txtU.x, txtU.y, txtU.z, txtV.x, txtV.y, txtV.z,
|
||||||
patchuv[0], patchuv[2], patchuv[1], patchuv[3], flipU ? SideVisible.TOPFLIP : (flipV ? SideVisible.TOPFLIPV : SideVisible.TOP), textureid, patchuv[1], patchuv[3]);
|
patchuv[0], patchuv[2], patchuv[1], patchuv[3], flipU ? SideVisible.TOPFLIP : (flipV ? SideVisible.TOPFLIPV : SideVisible.TOP), textureid, patchuv[1], patchuv[3]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,18 +198,21 @@ public class PatchDefinitionFactory implements RenderPatchFactory {
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
// PatchDefinition pd;
|
// PatchDefinition pd;
|
||||||
// BlockSide[] faces = { BlockSide.NORTH, BlockSide.EAST, BlockSide.SOUTH, BlockSide.WEST, BlockSide.TOP, BlockSide.BOTTOM };
|
//
|
||||||
|
// // box=0.000000/3.000000/9.000000:2.000000/6.000000/13.000000:
|
||||||
|
// // w/0/13.000000/7.000000/15.000000/10.000000:d/0/0.000000/9.000000/2.000000/13.000000:e/0/13.000000/7.000000/15.000000/10.000000:u/0/0.000000/9.000000/2.000000/13.000000:R/0/180/0
|
||||||
|
// BlockSide[] faces = { BlockSide.WEST, BlockSide.BOTTOM, BlockSide.EAST, BlockSide.TOP };
|
||||||
// // campfire log:box=1/0/0:5/4/16:n/0/0/4/4/8:e/0/0/1/16/5:s/0/0/4/4/8:w/0/16/0/0/4:u90/0/0/0/16/4:d90/0/0/0/16/4
|
// // campfire log:box=1/0/0:5/4/16:n/0/0/4/4/8:e/0/0/1/16/5:s/0/0/4/4/8:w/0/16/0/0/4:u90/0/0/0/16/4:d90/0/0/0/16/4
|
||||||
// double[][] uvs = { { 0, 4, 4, 8 }, { 0, 1, 16, 5 }, { 0, 4, 4, 8 }, { 16, 0, 0, 4 }, { 0, 0, 16, 4 }, { 0, 0, 16, 4 } };
|
// double[][] uvs = { { 13, 7, 15, 10 }, { 0, 9, 2, 13 }, { 13, 7, 15, 10 }, { 0, 9, 2, 13 } };
|
||||||
// ModelBlockModel.SideRotation[] rots = { ModelBlockModel.SideRotation.DEG0, ModelBlockModel.SideRotation.DEG0, ModelBlockModel.SideRotation.DEG0,
|
// ModelBlockModel.SideRotation[] rots = { ModelBlockModel.SideRotation.DEG0, ModelBlockModel.SideRotation.DEG0, ModelBlockModel.SideRotation.DEG0,
|
||||||
// ModelBlockModel.SideRotation.DEG0, ModelBlockModel.SideRotation.DEG90, ModelBlockModel.SideRotation.DEG90 };
|
// ModelBlockModel.SideRotation.DEG0 };
|
||||||
// double[] from = { 1, 0, 0 };
|
// double[] from = { 0, 3, 9 };
|
||||||
// double[] to = { 5, 4, 16 };
|
// double[] to = { 2, 6, 13 };
|
||||||
//
|
//
|
||||||
// // Do normal faces, default limits
|
// // Do normal faces, default limits
|
||||||
// pd = new PatchDefinition();
|
// pd = new PatchDefinition();
|
||||||
// for (int i = 0; i < faces.length; i++) {
|
// for (int i = 0; i < faces.length; i++) {
|
||||||
// pd.updateModelFace(from, to, faces[i], uvs[i], rots[i], 0);
|
// pd.updateModelFace(from, to, faces[i], uvs[i], rots[i], true, 0);
|
||||||
// System.out.println("Log " + faces[i] + ": " + pd);
|
// System.out.println("Log " + faces[i] + ": " + pd);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue