Finish converting the code from javax.vecmath to the vanilla vector classes. Forge is now vecmath-free!
This commit is contained in:
parent
1558362583
commit
738abbb360
28 changed files with 307 additions and 494 deletions
|
@ -417,7 +417,6 @@ project(':forge') {
|
|||
installer 'org.jline:jline:3.12.+'
|
||||
installer 'org.apache.maven:maven-artifact:3.6.0'
|
||||
installer 'net.jodah:typetools:0.6.1'
|
||||
installer 'java3d:vecmath:1.5.2'
|
||||
installer 'org.apache.logging.log4j:log4j-api:2.11.2'
|
||||
installer 'org.apache.logging.log4j:log4j-core:2.11.2'
|
||||
installer 'net.minecrell:terminalconsoleappender:1.2.+'
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
--- a/net/minecraft/client/renderer/Matrix3f.java
|
||||
+++ b/net/minecraft/client/renderer/Matrix3f.java
|
||||
@@ -406,4 +406,10 @@
|
||||
@@ -406,4 +406,11 @@
|
||||
public Matrix3f func_226121_d_() {
|
||||
return new Matrix3f(this);
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ public void multiplyBackward(Matrix3f other) {
|
||||
+ Matrix3f copy = other.func_226121_d_();
|
||||
+ copy.func_226118_b_(this);
|
||||
|
|
|
@ -1,12 +1,30 @@
|
|||
--- a/net/minecraft/client/renderer/Matrix4f.java
|
||||
+++ b/net/minecraft/client/renderer/Matrix4f.java
|
||||
@@ -373,4 +373,88 @@
|
||||
@@ -373,4 +373,78 @@
|
||||
matrix4f.field_226586_l_ = p_226599_2_;
|
||||
return matrix4f;
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ public Matrix4f(float[] values) { set(values); }
|
||||
+ public Matrix4f(float[] values) {
|
||||
+ field_226575_a_ = values[0];
|
||||
+ field_226576_b_ = values[1];
|
||||
+ field_226577_c_ = values[2];
|
||||
+ field_226578_d_ = values[3];
|
||||
+ field_226579_e_ = values[4];
|
||||
+ field_226580_f_ = values[5];
|
||||
+ field_226581_g_ = values[6];
|
||||
+ field_226582_h_ = values[7];
|
||||
+ field_226583_i_ = values[8];
|
||||
+ field_226584_j_ = values[9];
|
||||
+ field_226585_k_ = values[10];
|
||||
+ field_226586_l_ = values[11];
|
||||
+ field_226587_m_ = values[12];
|
||||
+ field_226588_n_ = values[13];
|
||||
+ field_226589_o_ = values[14];
|
||||
+ field_226590_p_ = values[15];
|
||||
+ }
|
||||
+
|
||||
+ public void set(Matrix4f mat) {
|
||||
+ this.field_226575_a_ = mat.field_226575_a_;
|
||||
+ this.field_226576_b_ = mat.field_226576_b_;
|
||||
|
@ -45,47 +63,19 @@
|
|||
+ field_226590_p_ += other.field_226590_p_;
|
||||
+ }
|
||||
+
|
||||
+ public void set(float[] others) {
|
||||
+ field_226575_a_ = others[0];
|
||||
+ field_226576_b_ = others[1];
|
||||
+ field_226577_c_ = others[2];
|
||||
+ field_226578_d_ = others[3];
|
||||
+ field_226579_e_ = others[4];
|
||||
+ field_226580_f_ = others[5];
|
||||
+ field_226581_g_ = others[6];
|
||||
+ field_226582_h_ = others[7];
|
||||
+ field_226583_i_ = others[8];
|
||||
+ field_226584_j_ = others[9];
|
||||
+ field_226585_k_ = others[10];
|
||||
+ field_226586_l_ = others[11];
|
||||
+ field_226587_m_ = others[12];
|
||||
+ field_226588_n_ = others[13];
|
||||
+ field_226589_o_ = others[14];
|
||||
+ field_226590_p_ = others[15];
|
||||
+ }
|
||||
+
|
||||
+ public void write(float[] dest) {
|
||||
+ dest[0] = field_226575_a_;
|
||||
+ dest[1] = field_226576_b_;
|
||||
+ dest[2] = field_226577_c_;
|
||||
+ dest[3] = field_226578_d_;
|
||||
+ dest[4] = field_226579_e_;
|
||||
+ dest[5] = field_226580_f_;
|
||||
+ dest[6] = field_226581_g_;
|
||||
+ dest[7] = field_226582_h_;
|
||||
+ dest[8] = field_226583_i_;
|
||||
+ dest[9] = field_226584_j_;
|
||||
+ dest[10] = field_226585_k_;
|
||||
+ dest[11] = field_226586_l_;
|
||||
+ dest[12] = field_226587_m_;
|
||||
+ dest[13] = field_226588_n_;
|
||||
+ dest[14] = field_226589_o_;
|
||||
+ dest[15] = field_226590_p_;
|
||||
+ }
|
||||
+
|
||||
+ public void multiplyBackward(Matrix4f other) {
|
||||
+ Matrix4f copy = other.func_226601_d_();
|
||||
+ copy.func_226595_a_(this);
|
||||
+ this.set(copy);
|
||||
+ }
|
||||
+
|
||||
+ public void setTranslation(float x, float y, float z) {
|
||||
+ this.field_226575_a_ = 1.0F;
|
||||
+ this.field_226580_f_ = 1.0F;
|
||||
+ this.field_226585_k_ = 1.0F;
|
||||
+ this.field_226590_p_ = 1.0F;
|
||||
+ this.field_226578_d_ = x;
|
||||
+ this.field_226582_h_ = y;
|
||||
+ this.field_226586_l_ = z;
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
--- a/net/minecraft/client/renderer/Quaternion.java
|
||||
+++ b/net/minecraft/client/renderer/Quaternion.java
|
||||
@@ -176,4 +176,12 @@
|
||||
public Quaternion func_227068_g_() {
|
||||
return new Quaternion(this);
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ public Quaternion(float[] values) {
|
||||
+ this.field_227061_b_ = values[0];
|
||||
+ this.field_227062_c_ = values[1];
|
||||
+ this.field_227063_d_ = values[2];
|
||||
+ this.field_227064_e_ = values[3];
|
||||
+ }
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
private final Matrix4f field_227976_a_;
|
||||
private boolean field_227977_b_;
|
||||
@Nullable
|
||||
@@ -133,4 +133,33 @@
|
||||
@@ -133,4 +133,32 @@
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.field_227976_a_);
|
||||
}
|
||||
|
@ -29,17 +29,16 @@
|
|||
+ return field_227981_f_.func_227068_g_();
|
||||
+ }
|
||||
+
|
||||
+ private javax.vecmath.Matrix3f normalTransform = null;
|
||||
+ public javax.vecmath.Matrix3f getNormalMatrix() {
|
||||
+ private Matrix3f normalTransform = null;
|
||||
+ public Matrix3f getNormalMatrix() {
|
||||
+ checkNormalTransform();
|
||||
+ return normalTransform;
|
||||
+ }
|
||||
+ private void checkNormalTransform() {
|
||||
+ if (normalTransform == null) {
|
||||
+ normalTransform = new javax.vecmath.Matrix3f();
|
||||
+ net.minecraftforge.common.model.TransformationHelper.toVecmath(field_227976_a_).getRotationScale(normalTransform);
|
||||
+ normalTransform.invert();
|
||||
+ normalTransform.transpose();
|
||||
+ normalTransform = new Matrix3f(field_227976_a_);
|
||||
+ normalTransform.func_226123_f_();
|
||||
+ normalTransform.func_226110_a_();
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
--- a/net/minecraft/client/renderer/Vector3f.java
|
||||
+++ b/net/minecraft/client/renderer/Vector3f.java
|
||||
@@ -198,4 +198,14 @@
|
||||
@@ -198,4 +198,17 @@
|
||||
public String toString() {
|
||||
return "[" + this.field_229184_g_ + ", " + this.field_229185_h_ + ", " + this.field_229186_i_ + "]";
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ public Vector3f(float[] values) {
|
||||
+ set(values);
|
||||
+ }
|
||||
+ public void set(float[] values) {
|
||||
+ this.field_229184_g_ = values[0];
|
||||
+ this.field_229185_h_ = values[1];
|
||||
+ this.field_229186_i_ = values[2];
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
--- a/net/minecraft/client/renderer/Vector4f.java
|
||||
+++ b/net/minecraft/client/renderer/Vector4f.java
|
||||
@@ -129,4 +129,21 @@
|
||||
@@ -129,4 +129,16 @@
|
||||
public String toString() {
|
||||
return "[" + this.field_229368_a_ + ", " + this.field_229369_b_ + ", " + this.field_229370_c_ + ", " + this.field_229371_d_ + "]";
|
||||
}
|
||||
+
|
||||
+ // Forge start
|
||||
+ public Vector4f(float[] values) {
|
||||
+ set(values);
|
||||
+ }
|
||||
+ public void set(float[] values) {
|
||||
+ this.field_229368_a_ = values[0];
|
||||
+ this.field_229369_b_ = values[1];
|
||||
+ this.field_229370_c_ = values[2];
|
||||
+ this.field_229371_d_ = values[3];
|
||||
+ }
|
||||
+ public void write(float[] values) {
|
||||
+ values[0] = this.field_229368_a_;
|
||||
+ values[1] = this.field_229369_b_;
|
||||
+ values[2] = this.field_229370_c_;
|
||||
+ values[3] = this.field_229371_d_;
|
||||
+ }
|
||||
+ public void setX(float x) { this.field_229368_a_ = x; }
|
||||
+ public void setY(float y) { this.field_229369_b_ = y; }
|
||||
+ public void setZ(float z) { this.field_229370_c_ = z; }
|
||||
+ public void setW(float z) { this.field_229371_d_ = z; }
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
|||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -50,17 +49,13 @@ import java.util.Set;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.vecmath.Matrix3f;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.core.async.ThreadNameCachingStrategy;
|
||||
import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -79,14 +74,7 @@ import net.minecraft.client.gui.ClientBossInfo;
|
|||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogType;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.model.BipedModel;
|
||||
|
@ -97,7 +85,6 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|||
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelRotation;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
|
@ -403,39 +390,10 @@ public class ForgeHooksClient
|
|||
modelLoader.onPostBakeEvent(modelRegistry);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Matrix4f getMatrix(ItemTransformVec3f transform)
|
||||
{
|
||||
Matrix4f m = new Matrix4f(), t = new Matrix4f();
|
||||
m.setIdentity();
|
||||
m.setTranslation(TransformationHelper.toVecmath(transform.translation));
|
||||
t.setIdentity();
|
||||
t.rotY(transform.rotation.getY());
|
||||
m.mul(t);
|
||||
t.setIdentity();
|
||||
t.rotX(transform.rotation.getX());
|
||||
m.mul(t);
|
||||
t.setIdentity();
|
||||
t.rotZ(transform.rotation.getZ());
|
||||
m.mul(t);
|
||||
t.setIdentity();
|
||||
t.m00 = transform.scale.getX();
|
||||
t.m11 = transform.scale.getY();
|
||||
t.m22 = transform.scale.getZ();
|
||||
m.mul(t);
|
||||
return m;
|
||||
}
|
||||
|
||||
private static final net.minecraft.client.renderer.Matrix4f flipX;
|
||||
private static final net.minecraft.client.renderer.Matrix3f flipXNormal;
|
||||
static {
|
||||
|
||||
flipX = new net.minecraft.client.renderer.Matrix4f(new float[]{
|
||||
-1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
});
|
||||
flipX = Matrix4f.func_226593_a_(-1,1,1);
|
||||
flipXNormal = new net.minecraft.client.renderer.Matrix3f(flipX);
|
||||
}
|
||||
|
||||
|
@ -535,26 +493,6 @@ public class ForgeHooksClient
|
|||
}
|
||||
}
|
||||
|
||||
public static void transform(net.minecraft.client.renderer.Vector3f vec, Matrix4f m)
|
||||
{
|
||||
Vector4f tmp = new Vector4f(vec.getX(), vec.getY(), vec.getZ(), 1f);
|
||||
m.transform(tmp);
|
||||
if(Math.abs(tmp.w - 1f) > 1e-5) tmp.scale(1f / tmp.w);
|
||||
vec.set(tmp.x, tmp.y, tmp.z);
|
||||
}
|
||||
|
||||
public static Matrix4f getMatrix(ModelRotation modelRotation)
|
||||
{
|
||||
Matrix4f ret = TransformationHelper.toVecmath(modelRotation.func_225615_b_().func_227988_c_()), tmp = new Matrix4f();
|
||||
tmp.setIdentity();
|
||||
tmp.m03 = tmp.m13 = tmp.m23 = .5f;
|
||||
ret.mul(tmp, ret);
|
||||
tmp.invert();
|
||||
//tmp.m03 = tmp.m13 = tmp.m23 = -.5f;
|
||||
ret.mul(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int getColorIndex(VertexFormat fmt)
|
||||
{
|
||||
ImmutableList<VertexFormatElement> elements = fmt.func_227894_c_();
|
||||
|
@ -787,17 +725,17 @@ public class ForgeHooksClient
|
|||
public static void fillNormal(int[] faceData, Direction facing)
|
||||
{
|
||||
Vector3f v1 = getVertexPos(faceData, 3);
|
||||
Vector3f t = getVertexPos(faceData, 1);
|
||||
Vector3f t1 = getVertexPos(faceData, 1);
|
||||
Vector3f v2 = getVertexPos(faceData, 2);
|
||||
v1.sub(t);
|
||||
t.set(getVertexPos(faceData, 0));
|
||||
v2.sub(t);
|
||||
v1.cross(v2, v1);
|
||||
v1.normalize();
|
||||
Vector3f t2 = getVertexPos(faceData, 0);
|
||||
v1.sub(t1);
|
||||
v2.sub(t2);
|
||||
v2.cross(v1);
|
||||
v2.func_229194_d_();
|
||||
|
||||
int x = ((byte) Math.round(v1.x * 127)) & 0xFF;
|
||||
int y = ((byte) Math.round(v1.y * 127)) & 0xFF;
|
||||
int z = ((byte) Math.round(v1.z * 127)) & 0xFF;
|
||||
int x = ((byte) Math.round(v2.getX() * 127)) & 0xFF;
|
||||
int y = ((byte) Math.round(v2.getY() * 127)) & 0xFF;
|
||||
int z = ((byte) Math.round(v2.getZ() * 127)) & 0xFF;
|
||||
|
||||
int normal = x | (y << 0x08) | (z << 0x10);
|
||||
|
||||
|
@ -852,24 +790,19 @@ public class ForgeHooksClient
|
|||
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, Direction originalSide, TransformationMatrix rotation, ResourceLocation p_228824_9_)
|
||||
{
|
||||
TransformationMatrix global = new TransformationMatrix(rotation.func_227988_c_());
|
||||
Matrix4f uv = TransformationHelper.toVecmath(TransformationHelper.getUVLockTransform(global, originalSide).func_227988_c_());
|
||||
Vector4f vec = new Vector4f(0, 0, 0, 1);
|
||||
Matrix4f uv = TransformationHelper.getUVLockTransform(global, originalSide).func_227988_c_();
|
||||
float u0 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0));
|
||||
float v0 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0));
|
||||
vec.x = u0 / 16;
|
||||
vec.y = v0 / 16;
|
||||
uv.transform(vec);
|
||||
float uMin = 16 * vec.x; // / vec.w;
|
||||
float vMin = 16 * vec.y; // / vec.w;
|
||||
Vector4f vec = new Vector4f(u0 / 16, v0 / 16, 0, 1);
|
||||
vec.func_229372_a_(uv);
|
||||
float uMin = 16 * vec.getX(); // / vec.w;
|
||||
float vMin = 16 * vec.getY(); // / vec.w;
|
||||
float u1 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2));
|
||||
float v1 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2));
|
||||
vec.x = u1 / 16;
|
||||
vec.y = v1 / 16;
|
||||
vec.z = 0;
|
||||
vec.w = 1;
|
||||
uv.transform(vec);
|
||||
float uMax = 16 * vec.x; // / vec.w;
|
||||
float vMax = 16 * vec.y; // / vec.w;
|
||||
vec.set(u1 / 16,v1 / 16,0,1);
|
||||
vec.func_229372_a_(uv);
|
||||
float uMax = 16 * vec.getX(); // / vec.w;
|
||||
float vMax = 16 * vec.getY(); // / vec.w;
|
||||
if (uMin > uMax && u0 < u1 || uMin < uMax && u0 > u1)
|
||||
{
|
||||
float t = uMin;
|
||||
|
@ -884,10 +817,9 @@ public class ForgeHooksClient
|
|||
}
|
||||
float a = (float)Math.toRadians(blockFaceUV.rotation);
|
||||
Vector3f rv = new Vector3f(MathHelper.cos(a), MathHelper.sin(a), 0);
|
||||
Matrix3f rot = new Matrix3f();
|
||||
uv.getRotationScale(rot);
|
||||
rot.transform(rv);
|
||||
int angle = MathHelper.normalizeAngle(-(int)Math.round(Math.toDegrees(Math.atan2(rv.y, rv.x)) / 90) * 90, 360);
|
||||
Matrix3f rot = new Matrix3f(uv);
|
||||
rv.func_229188_a_(rot);
|
||||
int angle = MathHelper.normalizeAngle(-(int)Math.round(Math.toDegrees(Math.atan2(rv.getY(), rv.getX())) / 90) * 90, 360);
|
||||
return new BlockFaceUV(new float[]{ uMin, vMin, uMax, vMax }, angle);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Random;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
|
@ -37,7 +36,6 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public interface IForgeBakedModel
|
||||
{
|
||||
|
|
|
@ -20,12 +20,8 @@
|
|||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
|
||||
/*
|
||||
* Replacement interface for ModelRotation to allow custom transformations of vanilla models.
|
||||
|
@ -66,27 +62,20 @@ public interface IForgeTransformationMatrix
|
|||
default TransformationMatrix inverse()
|
||||
{
|
||||
if (isIdentity()) return getTransformaion();
|
||||
javax.vecmath.Matrix4f m = TransformationHelper.toVecmath(getTransformaion().func_227988_c_());
|
||||
m.invert();
|
||||
return new TransformationMatrix(TransformationHelper.toMojang(m));
|
||||
Matrix4f m = getTransformaion().func_227988_c_().func_226601_d_();
|
||||
m.func_226600_c_();
|
||||
return new TransformationMatrix(m);
|
||||
}
|
||||
|
||||
default void transformPosition(Vector4f position)
|
||||
{
|
||||
TransformationHelper.transform(getTransformaion().func_227988_c_(), position);
|
||||
position.func_229372_a_(getTransformaion().func_227988_c_());
|
||||
}
|
||||
|
||||
default void transformNormal(Vector3f normal)
|
||||
{
|
||||
javax.vecmath.Vector3f copy = TransformationHelper.toVecmath(normal);
|
||||
transformNormal(copy);
|
||||
normal.set(copy.x, copy.y, copy.z);
|
||||
}
|
||||
|
||||
default void transformNormal(javax.vecmath.Vector3f normal)
|
||||
{
|
||||
getTransformaion().getNormalMatrix().transform(normal);
|
||||
normal.normalize();
|
||||
normal.func_229188_a_(getTransformaion().getNormalMatrix());
|
||||
normal.func_229194_d_();
|
||||
}
|
||||
|
||||
default Direction rotateTransform(Direction facing)
|
||||
|
@ -94,4 +83,38 @@ public interface IForgeTransformationMatrix
|
|||
return Direction.func_229385_a_(getTransformaion().func_227988_c_(), facing);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert transformation from assuming center-block system to corner-block system
|
||||
*/
|
||||
default TransformationMatrix blockCenterToCorner()
|
||||
{
|
||||
TransformationMatrix transform = getTransformaion();
|
||||
if (transform.isIdentity()) return TransformationMatrix.func_227983_a_();
|
||||
|
||||
Matrix4f ret = transform.func_227988_c_();
|
||||
Matrix4f tmp = Matrix4f.func_226599_b_(.5f, .5f, .5f);
|
||||
ret.multiplyBackward(tmp);
|
||||
tmp.func_226591_a_();
|
||||
tmp.setTranslation(-.5f, -.5f, -.5f);
|
||||
ret.func_226595_a_(tmp);
|
||||
return new TransformationMatrix(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert transformation from assuming corner-block system to center-block system
|
||||
*/
|
||||
default TransformationMatrix blockCornerToCenter()
|
||||
{
|
||||
TransformationMatrix transform = getTransformaion();
|
||||
if (transform.isIdentity()) return TransformationMatrix.func_227983_a_();
|
||||
|
||||
Matrix4f ret = transform.func_227988_c_();
|
||||
Matrix4f tmp = Matrix4f.func_226599_b_(-.5f, -.5f, -.5f);
|
||||
ret.multiplyBackward(tmp);
|
||||
tmp.func_226591_a_();
|
||||
tmp.setTranslation(.5f, .5f, .5f);
|
||||
ret.func_226595_a_(tmp);
|
||||
return new TransformationMatrix(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package net.minecraftforge.client.model;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
@ -36,7 +35,6 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
|||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class BakedItemModel implements IBakedModel
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -35,9 +34,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public abstract class BakedModelWrapper<T extends IBakedModel> implements IBakedModel
|
||||
{
|
||||
|
|
|
@ -54,7 +54,8 @@ final class FancyMissingModel implements IUnbakedModel
|
|||
{
|
||||
private static final ResourceLocation font = new ResourceLocation("minecraft", "textures/font/ascii.png");
|
||||
private static final Material font2 = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation("minecraft", "font/ascii"));
|
||||
private static final TransformationMatrix smallTransformation = TransformationHelper.blockCenterToCorner(new TransformationMatrix(null, null, new Vector3f(.25f, .25f, .25f), null));
|
||||
private static final TransformationMatrix smallTransformation = new TransformationMatrix(null, null, new Vector3f(.25f, .25f, .25f), null)
|
||||
.blockCenterToCorner();
|
||||
private static final LoadingCache<VertexFormat, SimpleModelFontRenderer> fontCache = CacheBuilder.newBuilder().maximumSize(3).build(new CacheLoader<VertexFormat, SimpleModelFontRenderer>()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -159,10 +159,10 @@ public final class ModelDynBucket implements IModelGeometry<ModelDynBucket>
|
|||
|
||||
TextureAtlasSprite particleSprite = particleLocation != null ? spriteGetter.apply(particleLocation) : null;
|
||||
|
||||
// if the fluid is lighter than air, will manipulate the initial state to be rotated 180° to turn it upside down
|
||||
// if the fluid is lighter than air, will manipulate the initial state to be rotated 180deg to turn it upside down
|
||||
if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
|
||||
{
|
||||
sprite = new ModelTransformComposition(state, new SimpleModelTransform(TransformationHelper.blockCenterToCorner(new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null))));
|
||||
sprite = new ModelTransformComposition(state, new SimpleModelTransform(new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null).blockCenterToCorner()));
|
||||
state = sprite;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ public class ModelLoaderRegistry
|
|||
try
|
||||
{
|
||||
TransformationMatrix base = context.deserialize(transformData, TransformationMatrix.class);
|
||||
return Optional.of(new SimpleModelTransform(ImmutableMap.of(), TransformationHelper.blockCenterToCorner(base)));
|
||||
return Optional.of(new SimpleModelTransform(ImmutableMap.of(), base.blockCenterToCorner()));
|
||||
}
|
||||
catch (JsonParseException e)
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ public class ModelLoaderRegistry
|
|||
if(!transform.entrySet().isEmpty())
|
||||
{
|
||||
base = context.deserialize(transform, TransformationMatrix.class);
|
||||
base = TransformationHelper.blockCenterToCorner(base);
|
||||
base = base.blockCenterToCorner();
|
||||
}
|
||||
IModelTransform state = new SimpleModelTransform(Maps.immutableEnumMap(transforms), base);
|
||||
return Optional.of(state);
|
||||
|
@ -208,7 +208,7 @@ public class ModelLoaderRegistry
|
|||
if(transform.has(name))
|
||||
{
|
||||
TransformationMatrix t = context.deserialize(transform.remove(name), TransformationMatrix.class);
|
||||
transforms.put(itemCameraTransform, TransformationHelper.blockCenterToCorner(t));
|
||||
transforms.put(itemCameraTransform, t.blockCenterToCorner());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
|
@ -35,7 +34,6 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
{
|
||||
if (transforms.hasCustomTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.blockCenterToCorner(TransformationHelper.toTransformation(transforms.getTransform(type))));
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)).blockCenterToCorner());
|
||||
}
|
||||
}
|
||||
return ImmutableMap.copyOf(map);
|
||||
|
@ -96,7 +96,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
}
|
||||
else if (transforms.hasCustomTransform(type))
|
||||
{
|
||||
map.put(type, TransformationHelper.blockCenterToCorner(TransformationHelper.toTransformation(transforms.getTransform(type))));
|
||||
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)).blockCenterToCorner());
|
||||
}
|
||||
}
|
||||
return ImmutableMap.copyOf(map);
|
||||
|
@ -109,7 +109,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
{
|
||||
// Push to the matrix to make it not empty and indicate that we want to transform things
|
||||
mat.func_227860_a_();
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(TransformationHelper.blockCornerToCenter(tr).func_227988_c_());
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(tr.blockCornerToCenter().func_227988_c_());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class PerspectiveMapWrapper implements IBakedModel
|
|||
{
|
||||
// Push to the matrix to make it not empty and indicate that we want to transform things
|
||||
mat.func_227860_a_();
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(TransformationHelper.blockCornerToCenter(tr).func_227988_c_());
|
||||
mat.func_227866_c_().func_227870_a_().func_226595_a_(tr.blockCornerToCenter().func_227988_c_());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ package net.minecraftforge.client.model;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
|
@ -32,12 +32,8 @@ import java.util.Optional;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.AxisAngle4f;
|
||||
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Quaternion;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -334,7 +330,8 @@ public class ModelBlockAnimation
|
|||
Vector3f translation = new Vector3f(0, 0, 0);
|
||||
Vector3f scale = new Vector3f(1, 1, 1);
|
||||
Vector3f origin = new Vector3f(0, 0, 0);
|
||||
AxisAngle4f rotation = new AxisAngle4f(0, 0, 0, 0);
|
||||
Vector3f rotation_axis = new Vector3f(0, 0, 0);
|
||||
float rotation_angle = 0;
|
||||
for(MBVariableClip var : variables)
|
||||
{
|
||||
int length = loop ? var.samples.length : (var.samples.length - 1);
|
||||
|
@ -375,16 +372,16 @@ public class ModelBlockAnimation
|
|||
translation.setZ(value);
|
||||
break;
|
||||
case XROT:
|
||||
rotation.x = value;
|
||||
rotation_axis.setX(value);
|
||||
break;
|
||||
case YROT:
|
||||
rotation.y = value;
|
||||
rotation_axis.setY(value);
|
||||
break;
|
||||
case ZROT:
|
||||
rotation.z = value;
|
||||
rotation_axis.setZ(value);
|
||||
break;
|
||||
case ANGLE:
|
||||
rotation.angle = (float)Math.toRadians(value);
|
||||
rotation_angle = (float)Math.toRadians(value);
|
||||
break;
|
||||
case SCALE:
|
||||
scale.set(value, value, value);
|
||||
|
@ -409,12 +406,12 @@ public class ModelBlockAnimation
|
|||
break;
|
||||
}
|
||||
}
|
||||
Quaternion rot = new Quaternion(new Vector3f(rotation.x, rotation.y, rotation.z), rotation.angle, false);
|
||||
Quaternion rot = new Quaternion(rotation_axis, rotation_angle, false);
|
||||
TransformationMatrix base = new TransformationMatrix(translation, rot, scale, null);
|
||||
Vector3f negOrigin = origin.func_229195_e_();
|
||||
negOrigin.func_229192_b_(-1,-1,-1);
|
||||
base = new TransformationMatrix(origin, null, null, null).compose(base).compose(new TransformationMatrix(negOrigin, null, null, null));
|
||||
return TransformationHelper.blockCenterToCorner(base);
|
||||
return base.blockCenterToCorner();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,20 +68,20 @@ public enum B3DClip implements IClip
|
|||
TransformationMatrix ret = TransformationMatrix.func_227983_a_();
|
||||
if(node.getAnimation() == null)
|
||||
{
|
||||
return ret.compose(B3DLoader.fromVecmath(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
return ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
}
|
||||
int start = Math.max(1, (int)Math.round(Math.floor(time)));
|
||||
int end = Math.min(start + 1, (int)Math.round(Math.ceil(time)));
|
||||
float progress = time - (float)Math.floor(time);
|
||||
Key keyStart = node.getAnimation().getKeys().get(start, node);
|
||||
Key keyEnd = node.getAnimation().getKeys().get(end, node);
|
||||
TransformationMatrix startTr = keyStart == null ? null : B3DLoader.fromVecmath(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null);
|
||||
TransformationMatrix endTr = keyEnd == null ? null : B3DLoader.fromVecmath(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null);
|
||||
TransformationMatrix startTr = keyStart == null ? null : new TransformationMatrix(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null);
|
||||
TransformationMatrix endTr = keyEnd == null ? null : new TransformationMatrix(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null);
|
||||
if(keyStart == null)
|
||||
{
|
||||
if(keyEnd == null)
|
||||
{
|
||||
ret = ret.compose(B3DLoader.fromVecmath(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
}
|
||||
// TODO animated TRSRTransformation for speed?
|
||||
else
|
||||
|
|
|
@ -36,11 +36,11 @@ import java.util.function.Predicate;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
|
@ -156,12 +156,6 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
return new ModelWrapper(modelLocation, model, ImmutableSet.of(model.getRoot().getName()), true, true, 1);
|
||||
}
|
||||
|
||||
@Deprecated // TODO: Does a lot of unnecessary work converting things, should use the TransformationMatrix constructor directly with mojang vector classes instead.
|
||||
public static TransformationMatrix fromVecmath(javax.vecmath.Vector3f pos, javax.vecmath.Quat4f rot, javax.vecmath.Vector3f scale, javax.vecmath.Quat4f rot2)
|
||||
{
|
||||
return new TransformationMatrix(TransformationHelper.toMojang(pos), TransformationHelper.toMojang(rot), TransformationHelper.toMojang(scale), TransformationHelper.toMojang(rot2));
|
||||
}
|
||||
|
||||
public static final class B3DState implements IModelTransform
|
||||
{
|
||||
@Nullable
|
||||
|
@ -310,10 +304,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
ret = ret.compose(pm);
|
||||
// joint offset in the parent coords
|
||||
ret = ret.compose(fromVecmath(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
}
|
||||
// current node local pose
|
||||
ret = ret.compose(fromVecmath(key.getPos(), key.getRot(), key.getScale(), null));
|
||||
ret = ret.compose(new TransformationMatrix(key.getPos(), key.getRot(), key.getScale(), null));
|
||||
// this part moved inside the model
|
||||
// inverse bind of the current node
|
||||
/*Matrix4f rm = new TRSRTransformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix();
|
||||
|
@ -339,9 +333,9 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
TransformationMatrix pm = cache.getUnchecked(Triple.of(animation, node.getParent(), frame));
|
||||
ret = ret.compose(pm);
|
||||
// joint offset in the parent coords
|
||||
ret = ret.compose(fromVecmath(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
ret = ret.compose(new TransformationMatrix(parent.getPos(), parent.getRot(), parent.getScale(), null));
|
||||
}
|
||||
ret = ret.compose(fromVecmath(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
ret = ret.compose(new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null));
|
||||
// TODO cache
|
||||
TransformationMatrix invBind = new NodeJoint(node).getInvBindPose();
|
||||
ret = ret.compose(invBind);
|
||||
|
@ -362,9 +356,9 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
@Override
|
||||
public TransformationMatrix getInvBindPose()
|
||||
{
|
||||
Matrix4f m = TransformationHelper.toVecmath(fromVecmath(node.getPos(), node.getRot(), node.getScale(), null).func_227988_c_());
|
||||
m.invert();
|
||||
TransformationMatrix pose = new TransformationMatrix(TransformationHelper.toMojang(m));
|
||||
Matrix4f m = new TransformationMatrix(node.getPos(), node.getRot(), node.getScale(), null).func_227988_c_();
|
||||
m.func_226600_c_();
|
||||
TransformationMatrix pose = new TransformationMatrix(m);
|
||||
|
||||
if(node.getParent() != null)
|
||||
{
|
||||
|
@ -714,14 +708,14 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
@Override
|
||||
public Matrix4f apply(Node<?> node)
|
||||
{
|
||||
return TransformationHelper.toVecmath(global.compose(localCache.getUnchecked(node)).func_227988_c_());
|
||||
return global.compose(localCache.getUnchecked(node)).func_227988_c_();
|
||||
}
|
||||
});
|
||||
for(Face f : faces)
|
||||
{
|
||||
UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format);
|
||||
quadBuilder.setContractUVs(true);
|
||||
quadBuilder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z));
|
||||
quadBuilder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().getX(), f.getNormal().getY(), f.getNormal().getZ()));
|
||||
List<Texture> textures = null;
|
||||
if(f.getBrush() != null) textures = f.getBrush().getTextures();
|
||||
TextureAtlasSprite sprite;
|
||||
|
@ -747,12 +741,12 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
switch(vertexFormatElements.get(e).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, 1);
|
||||
builder.put(e, v.getPos().getX(), v.getPos().getY(), v.getPos().getZ(), 1);
|
||||
break;
|
||||
case COLOR:
|
||||
if(v.getColor() != null)
|
||||
{
|
||||
builder.put(e, v.getColor().x, v.getColor().y, v.getColor().z, v.getColor().w);
|
||||
builder.put(e, v.getColor().getX(), v.getColor().getY(), v.getColor().getZ(), v.getColor().getW());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -764,8 +758,8 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
if(vertexFormatElements.get(e).getIndex() < v.getTexCoords().length)
|
||||
{
|
||||
builder.put(e,
|
||||
sprite.getInterpolatedU(v.getTexCoords()[0].x * 16),
|
||||
sprite.getInterpolatedV(v.getTexCoords()[0].y * 16),
|
||||
sprite.getInterpolatedU(v.getTexCoords()[0].getX() * 16),
|
||||
sprite.getInterpolatedV(v.getTexCoords()[0].getY() * 16),
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
@ -778,11 +772,11 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
|
|||
case NORMAL:
|
||||
if(v.getNormal() != null)
|
||||
{
|
||||
builder.put(e, v.getNormal().x, v.getNormal().y, v.getNormal().z, 0);
|
||||
builder.put(e, v.getNormal().getX(), v.getNormal().getY(), v.getNormal().getZ(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(e, faceNormal.x, faceNormal.y, faceNormal.z, 0);
|
||||
builder.put(e, faceNormal.getX(), faceNormal.getY(), faceNormal.getZ(), 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -37,13 +37,9 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
import javax.vecmath.Quat4f;
|
||||
import javax.vecmath.Vector2f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -253,8 +249,8 @@ public class B3DModel
|
|||
String path = readString();
|
||||
int flags = buf.getInt();
|
||||
int blend = buf.getInt();
|
||||
Vector2f pos = new Vector2f(buf.getFloat(), buf.getFloat());
|
||||
Vector2f scale = new Vector2f(buf.getFloat(), buf.getFloat());
|
||||
Vec2f pos = new Vec2f(buf.getFloat(), buf.getFloat());
|
||||
Vec2f scale = new Vec2f(buf.getFloat(), buf.getFloat());
|
||||
float rot = buf.getFloat();
|
||||
ret.add(new Texture(path, flags, blend, pos, scale, rot));
|
||||
}
|
||||
|
@ -389,7 +385,7 @@ public class B3DModel
|
|||
Map<Integer, Key> ret = new HashMap<>();
|
||||
int flags = buf.getInt();
|
||||
Vector3f pos = null, scale = null;
|
||||
Quat4f rot = null;
|
||||
Quaternion rot = null;
|
||||
while(buf.hasRemaining())
|
||||
{
|
||||
int frame = buf.getInt();
|
||||
|
@ -456,7 +452,7 @@ public class B3DModel
|
|||
String name = readString();
|
||||
Vector3f pos = new Vector3f(buf.getFloat(), buf.getFloat(), buf.getFloat());
|
||||
Vector3f scale = new Vector3f(buf.getFloat(), buf.getFloat(), buf.getFloat());
|
||||
Quat4f rot = readQuat();
|
||||
Quaternion rot = readQuat();
|
||||
dump("NODE(" + name + ", " + pos + ", " + scale + ", " + rot + ") {");
|
||||
while(buf.hasRemaining())
|
||||
{
|
||||
|
@ -494,13 +490,13 @@ public class B3DModel
|
|||
return node;
|
||||
}
|
||||
|
||||
private Quat4f readQuat()
|
||||
private Quaternion readQuat()
|
||||
{
|
||||
float w = buf.getFloat();
|
||||
float x = buf.getFloat();
|
||||
float y = buf.getFloat();
|
||||
float z = buf.getFloat();
|
||||
return new Quat4f(x, y, z, w);
|
||||
return new Quaternion(x, y, z, w);
|
||||
}
|
||||
|
||||
private void skip()
|
||||
|
@ -533,15 +529,15 @@ public class B3DModel
|
|||
|
||||
public static class Texture
|
||||
{
|
||||
public static final Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0);
|
||||
public static final Texture White = new Texture("builtin/white", 0, 0, new Vec2f(0, 0), new Vec2f(1, 1), 0);
|
||||
private final String path;
|
||||
private final int flags;
|
||||
private final int blend;
|
||||
private final Vector2f pos;
|
||||
private final Vector2f scale;
|
||||
private final Vec2f pos;
|
||||
private final Vec2f scale;
|
||||
private final float rot;
|
||||
|
||||
public Texture(String path, int flags, int blend, Vector2f pos, Vector2f scale, float rot)
|
||||
public Texture(String path, int flags, int blend, Vec2f pos, Vec2f scale, float rot)
|
||||
{
|
||||
this.path = path;
|
||||
this.flags = flags;
|
||||
|
@ -566,12 +562,12 @@ public class B3DModel
|
|||
return blend;
|
||||
}
|
||||
|
||||
public Vector2f getPos()
|
||||
public Vec2f getPos()
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
public Vector2f getScale()
|
||||
public Vec2f getScale()
|
||||
{
|
||||
return scale;
|
||||
}
|
||||
|
@ -667,7 +663,7 @@ public class B3DModel
|
|||
Matrix4f t = new Matrix4f();
|
||||
if(mesh.getWeightMap().get(this).isEmpty())
|
||||
{
|
||||
t.setIdentity();
|
||||
t.func_226591_a_();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -675,27 +671,28 @@ public class B3DModel
|
|||
{
|
||||
totalWeight += bone.getLeft();
|
||||
Matrix4f bm = animator.apply(bone.getRight());
|
||||
bm.mul(bone.getLeft());
|
||||
bm.func_226592_a_(bone.getLeft());
|
||||
t.add(bm);
|
||||
}
|
||||
if(Math.abs(totalWeight) > 1e-4) t.mul(1f / totalWeight);
|
||||
else t.setIdentity();
|
||||
if(Math.abs(totalWeight) > 1e-4) t.func_226592_a_(1f / totalWeight);
|
||||
else t.func_226591_a_();
|
||||
}
|
||||
|
||||
TransformationMatrix trsr = new TransformationMatrix(TransformationHelper.toMojang(t));
|
||||
TransformationMatrix trsr = new TransformationMatrix(t);
|
||||
|
||||
// pos
|
||||
Vector4f pos = new Vector4f(this.pos);
|
||||
pos.w = 1;
|
||||
trsr.transformPosition(TransformationHelper.toMojang(pos));
|
||||
Vector3f rPos = new Vector3f(pos.x / pos.w, pos.y / pos.w, pos.z / pos.w);
|
||||
pos.setW(1);
|
||||
trsr.transformPosition(pos);
|
||||
pos.func_229374_e_();
|
||||
Vector3f rPos = new Vector3f(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
// normal
|
||||
Vector3f rNormal = null;
|
||||
|
||||
if(this.normal != null)
|
||||
{
|
||||
rNormal = new Vector3f(this.normal);
|
||||
rNormal = this.normal.func_229195_e_();
|
||||
trsr.transformNormal(rNormal);
|
||||
}
|
||||
|
||||
|
@ -787,13 +784,13 @@ public class B3DModel
|
|||
|
||||
public static Vector3f getNormal(Vertex v1, Vertex v2, Vertex v3)
|
||||
{
|
||||
Vector3f a = new Vector3f(v2.getPos());
|
||||
Vector3f a = v2.getPos().func_229195_e_();
|
||||
a.sub(v1.getPos());
|
||||
Vector3f b = new Vector3f(v3.getPos());
|
||||
Vector3f b = v3.getPos().func_229195_e_();
|
||||
b.sub(v1.getPos());
|
||||
Vector3f c = new Vector3f();
|
||||
c.cross(a, b);
|
||||
c.normalize();
|
||||
Vector3f c = a.func_229195_e_();
|
||||
c.cross(b);
|
||||
c.func_229194_d_();
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -805,9 +802,9 @@ public class B3DModel
|
|||
@Nullable
|
||||
private final Vector3f scale;
|
||||
@Nullable
|
||||
private final Quat4f rot;
|
||||
private final Quaternion rot;
|
||||
|
||||
public Key(@Nullable Vector3f pos, @Nullable Vector3f scale, @Nullable Quat4f rot)
|
||||
public Key(@Nullable Vector3f pos, @Nullable Vector3f scale, @Nullable Quaternion rot)
|
||||
{
|
||||
this.pos = pos;
|
||||
this.scale = scale;
|
||||
|
@ -827,7 +824,7 @@ public class B3DModel
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public Quat4f getRot()
|
||||
public Quaternion getRot()
|
||||
{
|
||||
return rot;
|
||||
}
|
||||
|
@ -892,7 +889,7 @@ public class B3DModel
|
|||
private final String name;
|
||||
private final Vector3f pos;
|
||||
private final Vector3f scale;
|
||||
private final Quat4f rot;
|
||||
private final Quaternion rot;
|
||||
private final ImmutableMap<String, Node<?>> nodes;
|
||||
@Nullable
|
||||
private Animation animation;
|
||||
|
@ -900,12 +897,12 @@ public class B3DModel
|
|||
@Nullable
|
||||
private Node<? extends IKind<?>> parent;
|
||||
|
||||
public static <K extends IKind<K>> Node<K> create(String name, Vector3f pos, Vector3f scale, Quat4f rot, List<Node<?>> nodes, K kind)
|
||||
public static <K extends IKind<K>> Node<K> create(String name, Vector3f pos, Vector3f scale, Quaternion rot, List<Node<?>> nodes, K kind)
|
||||
{
|
||||
return new Node<>(name, pos, scale, rot, nodes, kind);
|
||||
}
|
||||
|
||||
public Node(String name, Vector3f pos, Vector3f scale, Quat4f rot, List<Node<?>> nodes, K kind)
|
||||
public Node(String name, Vector3f pos, Vector3f scale, Quaternion rot, List<Node<?>> nodes, K kind)
|
||||
{
|
||||
this.name = name;
|
||||
this.pos = pos;
|
||||
|