Search in sources :

Example 1 with AxisAngle4d

use of javax.vecmath.AxisAngle4d in project EnderIO by SleepyTrousers.

the class RotatingSmartItemModel method handlePerspective.

@Override
@Nonnull
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
    Pair<? extends IBakedModel, Matrix4f> perspective = parent.handlePerspective(cameraTransformType);
    double r = (EnderIO.proxy.getTickCount() % 360) + Minecraft.getMinecraft().getRenderPartialTicks();
    TRSRTransformation transformOrig = new TRSRTransformation(perspective.getRight());
    Quat4f leftRot = transformOrig.getLeftRot();
    Quat4f yRotation = new Quat4f();
    yRotation.set(new AxisAngle4d(0, 1, 0, Math.toRadians(r * speed)));
    leftRot.mul(yRotation);
    TRSRTransformation transformNew = new TRSRTransformation(transformOrig.getTranslation(), leftRot, transformOrig.getScale(), transformOrig.getRightRot());
    return Pair.of(perspective.getLeft(), transformNew.getMatrix());
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) Matrix4f(javax.vecmath.Matrix4f) AxisAngle4d(javax.vecmath.AxisAngle4d) Quat4f(javax.vecmath.Quat4f) Nonnull(javax.annotation.Nonnull) ItemOverride(net.minecraft.client.renderer.block.model.ItemOverride)

Aggregations

Nonnull (javax.annotation.Nonnull)1 AxisAngle4d (javax.vecmath.AxisAngle4d)1 Matrix4f (javax.vecmath.Matrix4f)1 Quat4f (javax.vecmath.Quat4f)1 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)1 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)1