use of net.minecraftforge.common.model.TRSRTransformation in project ImmersiveEngineering by BluSunrize.
the class TileEntityFloodlight method applyTransformations.
@SideOnly(Side.CLIENT)
@Override
public Optional<TRSRTransformation> applyTransformations(IBlockState object, String group, Optional<TRSRTransformation> transform) {
if (!transform.isPresent())
transform = Optional.of(new TRSRTransformation((Matrix4f) null));
Matrix4f mat = transform.get().getMatrix();
Vector3f transl = new Vector3f(.5f, .5f, .5f);
double yaw = 0;
double pitch = 0;
double roll = 0;
// pitch, yaw, roll
if (side.getAxis() == Axis.Y) {
yaw = facing == EnumFacing.SOUTH ? 180 : facing == EnumFacing.WEST ? 90 : facing == EnumFacing.EAST ? -90 : 0;
if (side == EnumFacing.DOWN)
roll = 180;
} else //It's a mess, but it works!
{
if (side == EnumFacing.NORTH) {
pitch = 90;
yaw = 180;
}
if (side == EnumFacing.SOUTH)
pitch = 90;
if (side == EnumFacing.WEST) {
pitch = 90;
yaw = -90;
}
if (side == EnumFacing.EAST) {
pitch = 90;
yaw = 90;
}
if (facing == EnumFacing.DOWN)
roll += 180;
else if (side.getAxis() == Axis.X && facing.getAxis() == Axis.Z)
roll += 90 * facing.getAxisDirection().getOffset() * side.getAxisDirection().getOffset();
else if (side.getAxis() == Axis.Z && facing.getAxis() == Axis.X)
roll += -90 * facing.getAxisDirection().getOffset() * side.getAxisDirection().getOffset();
}
transl.add(new Vector3f(side.getFrontOffsetX() * .125f, side.getFrontOffsetY() * .125f, side.getFrontOffsetZ() * .125f));
if ("axis".equals(group) || "light".equals(group) || "off".equals(group) || "glass".equals(group)) {
if (side.getAxis() == Axis.Y)
yaw += rotY;
else
roll += rotY;
if ("light".equals(group) || "off".equals(group) || "glass".equals(group))
pitch += rotX;
}
mat.setRotation(ClientUtils.degreeToQuaterion(pitch, yaw, roll));
mat.setTranslation(transl);
return Optional.of(new TRSRTransformation(mat));
}
use of net.minecraftforge.common.model.TRSRTransformation in project Railcraft by Railcraft.
the class Transforms method getItem.
public static IModelState getItem() {
TRSRTransformation thirdPerson = get(0, 3, 1, 0, 0, 0, 0.55f);
TRSRTransformation firstPerson = get(1.13f, 3.2f, 1.13f, 0, -90, 25, 0.68f);
ImmutableMap.Builder<ItemCameraTransforms.TransformType, TRSRTransformation> builder = ImmutableMap.builder();
builder.put(ItemCameraTransforms.TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.5f));
builder.put(ItemCameraTransforms.TransformType.HEAD, get(0, 13, 7, 0, 180, 0, 1));
builder.put(ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, thirdPerson);
builder.put(ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, leftify(thirdPerson));
builder.put(ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND, firstPerson);
builder.put(ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, leftify(firstPerson));
return new SimpleModelState(builder.build());
}
Aggregations