Class PlayerModel
java.lang.Object
lol.trq.helios.model.PlayerModel
The transforms Minecraft 1.8.9 renders a player with, as plain matrix math: the same chain as
RenderPlayer, RendererLivingEntity, ModelPlayer and ModelBiped, so something drawn
at an Attachment follows the model exactly.
The chain from model pixels to camera-relative world blocks is T(position) · R_y(180 - bodyYaw) ·
S(-1, -1, 1) · S(0.9375) · T(0, -1.5078125, 0) · S(1/16), then the part's pivot and rotations. Sneaking adds
T(0, 0.2, 0) before the pixel scale, moves the head pivot down one pixel, tilts the body forward 0.5 radians
and, for players other than the client's own, lowers the position by 0.125. Riding a living entity limits how far
the body turns from the mount, as vanilla does. Sleeping, dying and the elytra are not modelled.
Every method writes into arrays the caller owns and allocates nothing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatHow far armour sits out from the skin, in pixels.static final floatDistance from the body pivot to the back surface, in pixels.static final floatHeight of the head, in pixels.static final floatThe living renderer's vertical model offset, in model units.static final floatThe furthest the body turns from a ridden mount, in degrees.static final floatModel units per pixel.static final floatThe player renderer's scale.static final floatForward tilt of the body when sneaking, in radians.static final floatHow far vanilla lowers other sneaking players, in blocks.static final floatHead pivot height when sneaking, in pixels.static final floatHow far a sneaking model shifts down, in model units, before scaling. -
Method Summary
Modifier and TypeMethodDescriptionstatic float[]anchor(PlayerPose pose, Attachment attachment, float[] out) Writes an attachment's transform: model pixels relative to the anchor, to camera-relative world blocks.static floatbodyYaw(PlayerPose pose) Returns the yaw the body is drawn at, after the riding limit.static floatinterpolateAngle(float previous, float current, float partialTicks) Interpolates between two angles the short way round, asRendererLivingEntity.interpolateRotation.static floatnetHeadYaw(PlayerPose pose) Returns the head yaw relative to the body, as the model receives it.static float[]root(PlayerPose pose, float[] out) Writes the model root: model pixels, before any part's pivot, to camera-relative world blocks.static floatwrap(float degrees) Wraps an angle to[-180, 180), asMathHelper.wrapAngleTo180_float.
-
Field Details
-
PIXEL
public static final float PIXELModel units per pixel.- See Also:
-
SCALE
public static final float SCALEThe player renderer's scale.- See Also:
-
MODEL_OFFSET
public static final float MODEL_OFFSETThe living renderer's vertical model offset, in model units.- See Also:
-
SNEAK_SHIFT
public static final float SNEAK_SHIFTHow far a sneaking model shifts down, in model units, before scaling.- See Also:
-
SNEAK_DROP
public static final float SNEAK_DROPHow far vanilla lowers other sneaking players, in blocks.- See Also:
-
SNEAK_BODY_PITCH
public static final float SNEAK_BODY_PITCHForward tilt of the body when sneaking, in radians.- See Also:
-
SNEAK_HEAD_PIVOT
public static final float SNEAK_HEAD_PIVOTHead pivot height when sneaking, in pixels.- See Also:
-
HEAD_HEIGHT
public static final float HEAD_HEIGHTHeight of the head, in pixels.- See Also:
-
BACK_DEPTH
public static final float BACK_DEPTHDistance from the body pivot to the back surface, in pixels.- See Also:
-
ARMOUR_OUTSET
public static final float ARMOUR_OUTSETHow far armour sits out from the skin, in pixels.- See Also:
-
MOUNT_LIMIT
public static final float MOUNT_LIMITThe furthest the body turns from a ridden mount, in degrees.- See Also:
-
-
Method Details
-
bodyYaw
Returns the yaw the body is drawn at, after the riding limit.- Parameters:
pose- the pose- Returns:
- the body yaw in degrees
-
netHeadYaw
Returns the head yaw relative to the body, as the model receives it. When riding, vanilla measures it from the mount rather than from the drawn body.- Parameters:
pose- the pose- Returns:
- the relative head yaw in degrees
-
root
Writes the model root: model pixels, before any part's pivot, to camera-relative world blocks.- Parameters:
pose- the poseout- receives the matrix- Returns:
out
-
anchor
Writes an attachment's transform: model pixels relative to the anchor, to camera-relative world blocks. Draw an attachment in pixels around the origin, with x toward the player's left, y down and z toward the back.- Parameters:
pose- the poseattachment- the anchorout- receives the matrix- Returns:
out
-
wrap
public static float wrap(float degrees) Wraps an angle to[-180, 180), asMathHelper.wrapAngleTo180_float.- Parameters:
degrees- the angle- Returns:
- the wrapped angle
-
interpolateAngle
public static float interpolateAngle(float previous, float current, float partialTicks) Interpolates between two angles the short way round, asRendererLivingEntity.interpolateRotation.- Parameters:
previous- the angle last tickcurrent- the angle this tickpartialTicks- the frame's partial tick- Returns:
- the interpolated angle
-