use of net.minecraft.client.renderer.block.model.BlockFaceUV in project MinecraftForge by MinecraftForge.
the class ForgeHooksClient method applyUVLock.
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, EnumFacing originalSide, ITransformation rotation) {
TRSRTransformation global = new TRSRTransformation(rotation.getMatrix());
Matrix4f uv = global.getUVLockTransform(originalSide).getMatrix();
Vector4f vec = new Vector4f(0, 0, 0, 1);
vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0)) / 16;
vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0)) / 16;
uv.transform(vec);
// / vec.w;
float uMin = 16 * vec.x;
// / vec.w;
float vMin = 16 * vec.y;
vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2)) / 16;
vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2)) / 16;
vec.z = 0;
vec.w = 1;
uv.transform(vec);
// / vec.w;
float uMax = 16 * vec.x;
// / vec.w;
float vMax = 16 * vec.y;
if (uMin > uMax) {
float t = uMin;
uMin = uMax;
uMax = t;
}
if (vMin > vMax) {
float t = vMin;
vMin = vMax;
vMax = t;
}
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);
return new BlockFaceUV(new float[] { uMin, vMin, uMax, vMax }, angle);
}
use of net.minecraft.client.renderer.block.model.BlockFaceUV in project Binnie by ForestryMC.
the class AABBModelBaker method bakeModel.
@Override
public IModelBakerModel bakeModel(boolean flip) {
ModelRotation mr = ModelRotation.X0_Y0;
if (flip) {
mr = ModelRotation.X0_Y180;
}
// Add baked models to the current model.
for (Pair<IBlockState, IBakedModel> bakedModel : bakedModels) {
currentModel.addModelQuads(bakedModel);
}
for (Pair<IBlockState, IBakedModel> bakedModel : bakedModelsPost) {
currentModel.addModelQuadsPost(bakedModel);
}
for (BoundModelBakerFace face : faces) {
final AxisAlignedBB modelBounds = face.modelBounds;
final Vector3f from = new Vector3f((float) modelBounds.minX * 16.0f, (float) modelBounds.minY * 16.0f, (float) modelBounds.minZ * 16.0f);
final Vector3f to = new Vector3f((float) modelBounds.maxX * 16.0f, (float) modelBounds.maxY * 16.0f, (float) modelBounds.maxZ * 16.0f);
final EnumFacing myFace = face.face;
final float[] uvs = getFaceUvs(myFace, to, from);
final BlockFaceUV uv = new BlockFaceUV(uvs, 0);
final BlockPartFace bpf = new BlockPartFace(myFace, face.colorIndex, "", uv);
BakedQuad bf = faceBakery.makeBakedQuad(from, to, bpf, face.spite, myFace, mr, null, true, true);
currentModel.addQuad(myFace, bf);
}
return currentModel;
}
use of net.minecraft.client.renderer.block.model.BlockFaceUV in project Charset by CharsetMC.
the class FaceBakeryWire method makeBakedQuad.
public BakedQuad makeBakedQuad(Vector3f min, Vector3f max, int tintIndex, float[] uvOrig, TextureAtlasSprite icon, EnumFacing facing, ModelRotation rot, boolean uvLocked) {
float[] uv = uvOrig;
if (!uvLocked && uvScale > 1) {
float ox = (uvOffset % uvScale) * (16.0f / uvScale);
float oy = (uvOffset / uvScale) * (16.0f / uvScale);
uv = new float[] { uv[0] / (float) uvScale + ox, uv[1] / (float) uvScale + oy, uv[2] / (float) uvScale + ox, uv[3] / (float) uvScale + oy };
}
BakedQuad quad = makeBakedQuad(min, max, new BlockPartFace(null, tintIndex, "", new BlockFaceUV(uv, 0)), icon, facing, rot, null, uvLocked, true);
if (tintIndex == -1) {
return quad;
} else {
int[] data = quad.getVertexData();
data[3] = data[10] = data[17] = data[24] = getFaceShadeColor(tintIndex, rot.rotate(facing));
return new IColoredBakedQuad.ColoredBakedQuad(data, tintIndex, quad.getFace());
}
}
use of net.minecraft.client.renderer.block.model.BlockFaceUV in project ForestryMC by ForestryMC.
the class ModelBaker method bakeModel.
@Override
public IModelBakerModel bakeModel(boolean flip) {
ModelRotation modelRotation = ModelRotation.X0_Y0;
if (flip) {
modelRotation = ModelRotation.X0_Y180;
}
// Add baked models to the current model.
for (Pair<IBlockState, IBakedModel> bakedModel : bakedModels) {
currentModel.addModelQuads(bakedModel);
}
for (Pair<IBlockState, IBakedModel> bakedModel : bakedModelsPost) {
currentModel.addModelQuadsPost(bakedModel);
}
for (ModelBakerFace face : faces) {
EnumFacing facing = face.face;
BlockFaceUV uvFace = new BlockFaceUV(UVS, 0);
BlockPartFace partFace = new BlockPartFace(facing, face.colorIndex, "", uvFace);
BakedQuad quad = FACE_BAKERY.makeBakedQuad(POS_FROM, POS_TO, partFace, face.spite, facing, modelRotation, null, true, true);
currentModel.addQuad(facing, quad);
}
return currentModel;
}
Aggregations