Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.