mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Finish converting the code from javax.vecmath to the vanilla vector classes. Forge is now vecmath-free!
This commit is contained in:
1 parent
1558362583
commit
738abbb360
28 files changed
+307
-494
No files matched your search
@@ -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;
|
||||
@@ -974,7 +971,7 @@ public class B3DModel
|
||||
return scale;
|
||||
}
|
||||
|
||||
public Quat4f getRot()
|
||||
public Quaternion getRot()
|
||||
{
|
||||
return rot;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ package net.minecraftforge.client.model.obj;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import joptsimple.internal.Strings;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
|
||||
import javax.vecmath.Vector4f;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import joptsimple.internal.Strings;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
@@ -33,6 +35,7 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraftforge.client.model.*;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometryPart;
|
||||
import net.minecraftforge.client.model.geometry.IMultipartModelGeometry;
|
||||
@@ -42,9 +45,6 @@ import net.minecraftforge.common.model.TransformationHelper;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Vector2f;
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -52,17 +52,17 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
{
|
||||
private static Vector2f[] DEFAULT_COORDS = {
|
||||
new Vector2f(0, 0),
|
||||
new Vector2f(0, 1),
|
||||
new Vector2f(1, 1),
|
||||
new Vector2f(1, 0),
|
||||
private static Vec2f[] DEFAULT_COORDS = {
|
||||
new Vec2f(0, 0),
|
||||
new Vec2f(0, 1),
|
||||
new Vec2f(1, 1),
|
||||
new Vec2f(1, 0),
|
||||
};
|
||||
|
||||
private final Map<String, ModelGroup> parts = Maps.newHashMap();
|
||||
|
||||
private final List<Vector3f> positions = Lists.newArrayList();
|
||||
private final List<Vector2f> texCoords = Lists.newArrayList();
|
||||
private final List<Vec2f> texCoords = Lists.newArrayList();
|
||||
private final List<Vector3f> normals = Lists.newArrayList();
|
||||
private final List<Vector4f> colors = Lists.newArrayList();
|
||||
|
||||
@@ -307,12 +307,12 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2f parseVector2(String[] line)
|
||||
public static Vec2f parseVector2(String[] line)
|
||||
{
|
||||
switch (line.length) {
|
||||
case 1: return new Vector2f(0,0);
|
||||
case 2: return new Vector2f(Float.parseFloat(line[1]), 0);
|
||||
default: return new Vector2f(Float.parseFloat(line[1]), Float.parseFloat(line[2]));
|
||||
case 1: return new Vec2f(0,0);
|
||||
case 2: return new Vec2f(Float.parseFloat(line[1]), 0);
|
||||
default: return new Vec2f(Float.parseFloat(line[1]), Float.parseFloat(line[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,12 +401,12 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
Vector3f a = positions.get(indices[0][0]);
|
||||
Vector3f ab = positions.get(indices[1][0]);
|
||||
Vector3f ac = positions.get(indices[2][0]);
|
||||
Vector3f abs = new Vector3f(ab);
|
||||
Vector3f abs = ab.func_229195_e_();
|
||||
abs.sub(a);
|
||||
Vector3f acs = new Vector3f(ac);
|
||||
Vector3f acs = ac.func_229195_e_();
|
||||
acs.sub(a);
|
||||
abs.cross(abs,acs);
|
||||
abs.normalize();
|
||||
abs.cross(acs);
|
||||
abs.func_229194_d_();
|
||||
faceNormal = abs;
|
||||
}
|
||||
|
||||
@@ -419,8 +419,8 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
builder.setTexture(texture);
|
||||
builder.setApplyDiffuseLighting(!isFullbright);
|
||||
|
||||
int fakeLight = (int)((ambientColor.x + ambientColor.y + ambientColor.z) * 15 / 3.0f);
|
||||
Vector2f uv2 = new Vector2f(((float) fakeLight * 0x20) / 0xFFFF, ((float) fakeLight * 0x20) / 0xFFFF);
|
||||
int fakeLight = (int)((ambientColor.getX() + ambientColor.getY() + ambientColor.getZ()) * 15 / 3.0f);
|
||||
Vec2f uv2 = new Vec2f(((float) fakeLight * 0x20) / 0xFFFF, ((float) fakeLight * 0x20) / 0xFFFF);
|
||||
|
||||
boolean hasTransform = !transform.isIdentity();
|
||||
TransformationMatrix transformation = hasTransform ? transform : null;
|
||||
@@ -429,15 +429,15 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
{
|
||||
int[] index = indices[Math.min(i,indices.length-1)];
|
||||
Vector3f pos0 = positions.get(index[0]);
|
||||
Vector4f position = new Vector4f(pos0.x, pos0.y, pos0.z, 1);
|
||||
Vector2f texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i];
|
||||
Vector4f position = new Vector4f(pos0.getX(), pos0.getY(), pos0.getZ(), 1);
|
||||
Vec2f texCoord = index.length >= 2 && texCoords.size() > 0 ? texCoords.get(index[1]) : DEFAULT_COORDS[i];
|
||||
Vector3f norm0 = !needsNormalRecalculation && index.length >= 3 && normals.size() > 0 ? normals.get(index[2]) : faceNormal;
|
||||
Vector3f normal = norm0;
|
||||
Vector4f color = index.length >= 4 && colors.size() > 0 ? colors.get(index[3]) : new Vector4f(1, 1, 1, 1);
|
||||
if (hasTransform)
|
||||
{
|
||||
normal = new Vector3f(norm0);
|
||||
transformation.transformPosition(TransformationHelper.toMojang(position));
|
||||
normal = norm0.func_229195_e_();
|
||||
transformation.transformPosition(position);
|
||||
transformation.transformNormal(normal);
|
||||
};
|
||||
Vector4f tintedColor = new Vector4f(
|
||||
@@ -450,7 +450,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
norm[i] = normal;
|
||||
}
|
||||
|
||||
builder.setQuadOrientation(Direction.getFacingFromVector(norm[0].x, norm[0].y,norm[0].z));
|
||||
builder.setQuadOrientation(Direction.getFacingFromVector(norm[0].getX(), norm[0].getY(),norm[0].getZ()));
|
||||
|
||||
Direction cull = null;
|
||||
if (detectCullableFaces)
|
||||
@@ -508,7 +508,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
return Pair.of(builder.build(), cull);
|
||||
}
|
||||
|
||||
private void putVertexData(IVertexConsumer consumer, VertexFormat format, Vector4f position0, Vector2f texCoord0, Vector3f normal0, Vector4f color0, Vector2f uv2, TextureAtlasSprite texture)
|
||||
private void putVertexData(IVertexConsumer consumer, VertexFormat format, Vector4f position0, Vec2f texCoord0, Vector3f normal0, Vector4f color0, Vec2f uv2, TextureAtlasSprite texture)
|
||||
{
|
||||
ImmutableList<VertexFormatElement> elements = format.func_227894_c_();
|
||||
for(int j=0;j<elements.size();j++)
|
||||
@@ -527,8 +527,8 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
{
|
||||
case 0:
|
||||
consumer.put(j,
|
||||
texture.getInterpolatedU(texCoord0.getX() * 16),
|
||||
texture.getInterpolatedV((flipV ? (1 - texCoord0.getY()) : texCoord0.getY()) * 16)
|
||||
texture.getInterpolatedU(texCoord0.x * 16),
|
||||
texture.getInterpolatedV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
@@ -675,7 +675,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
|
||||
|
||||
public boolean isFullbright()
|
||||
{
|
||||
return mat != null && mat.ambientColor.epsilonEquals(new Vector4f(1,1,1,1), 1/256f);
|
||||
return mat != null && TransformationHelper.epsilonEquals(mat.ambientColor, new Vector4f(1,1,1,1), 1/256f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
public class TRSRTransformer extends VertexTransformer
|
||||
{
|
||||
private final TransformationMatrix transform;
|
||||
@@ -40,14 +39,19 @@ public class TRSRTransformer extends VertexTransformer
|
||||
switch (getVertexFormat().func_227894_c_().get(element).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
Vector4f pos = new Vector4f(data);
|
||||
Vector4f pos = new Vector4f(data[0], data[1], data[2], data[3]);
|
||||
transform.transformPosition(pos);
|
||||
pos.write(data);
|
||||
data[0] = pos.getX();
|
||||
data[1] = pos.getY();
|
||||
data[2] = pos.getZ();
|
||||
data[3] = pos.getW();
|
||||
break;
|
||||
case NORMAL:
|
||||
Vector3f normal = new Vector3f(data);
|
||||
transform.transformNormal(normal);
|
||||
normal.get(data);
|
||||
data[0] = normal.getX();
|
||||
data[1] = normal.getY();
|
||||
data[2] = normal.getZ();
|
||||
break;
|
||||
}
|
||||
super.put(element, data);
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.model.pipeline;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.color.BlockColors;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
@@ -153,13 +152,13 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
||||
v1.sub(t);
|
||||
t.set(position[0]);
|
||||
v2.sub(t);
|
||||
v1.cross(v2, v1);
|
||||
v1.normalize();
|
||||
v2.cross(v1);
|
||||
v2.func_229194_d_();
|
||||
for(int v = 0; v < 4; v++)
|
||||
{
|
||||
normal[v][0] = v1.x;
|
||||
normal[v][1] = v1.y;
|
||||
normal[v][2] = v1.z;
|
||||
normal[v][0] = v2.getX();
|
||||
normal[v][1] = v2.getY();
|
||||
normal[v][2] = v2.getZ();
|
||||
normal[v][3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user