Jump to content

[SOLVED][1.12.2] TESR Animation


Terrails

Recommended Posts

I'm trying to animate an TESR. Well I already did it but I did it wrong (by increasing the counter in the rendering itself instead of update() in the tile class), I'm trying to move it to update() but the problem starts here... the rendering isn't smooth. I read to I need to use partialTicks for this kind of stuff but I don't understand how? I'm translating, scaling and rotating in my TESR. Any help would be greatly appreciated. 

Edited by Terrails
Link to comment
Share on other sites

partialTicks is used to smooth animation by interpolating between ticks.  For example (code from PneumaticCraft: Repressurized to smoothly animate rotations of the Assembly Drill - see https://github.com/TeamPneumatic/pnc-repressurized/blob/master/src/main/java/me/desht/pneumaticcraft/client/render/tileentity/RenderAssemblyDrill.java):

    void renderModel(TileEntityAssemblyDrill te, float partialTicks) {
        if (te != null) {
            float[] renderAngles = new float[5];
            for (int i = 0; i < 4; i++) {
                renderAngles[i] = te.oldAngles[i] + (te.angles[i] - te.oldAngles[i]) * partialTicks;
            }
            renderAngles[4] = te.oldDrillRotation + (te.drillRotation - te.oldDrillRotation) * partialTicks;
            model.renderModel(0.0625f, renderAngles);
        } else {
            model.renderModel(0.0625f, new float[]{0, 0, 35, 55, 0});
        }
    }

The rotation angles and previous rotation angles are stored in the TE - every tick, the angles are updated as appropriate and the previous angles are copied into te.oldAngles[] (multiple angles in this case, since it's a robot arm which has several points of rotation).

 

The actual render angles are calculated as an interpolation of the current and previous angles, based on partialTicks: renderAngle = oldAngle + (newAngle - oldAngle) * partialTicks.

 

Of course, this can also apply to any other rendering: translations, scaling etc.  But that's the principle.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.