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

So, I have some GL code in a custom RenderType, which I'm using as a wrapper for an actual RenderType. My overall goal is to apply clipping to a rendered entity.

 

                rendertype1 = new ClipWrappedRenderLayer(yaw, pitch, x,y,z,progress, rendertype1);
                IVertexBuilder ivertexbuilder = bufferIn.getBuffer(rendertype1);
                renderModel(modelIn, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder);

 

    public ClipWrappedRenderLayer(double pitch, double yaw, double x,double y,double z, double p, RenderType delegate) {
        super(MahouTsukaiMod.modId + delegate.toString() + "_with_clip", delegate.getVertexFormat(), delegate.getDrawMode(), delegate.getBufferSize(), true, delegate.func_230041_s_(),
                () -> {

                    DoubleBuffer eqn1 = BufferUtils.createDoubleBuffer(8).put(new double[]{0,1,1,p});
                    eqn1.flip();
                    GL11.glClipPlane(GL11.GL_CLIP_PLANE0, eqn1);
                    GL11.glEnable(GL11.GL_CLIP_PLANE0);

                    delegate.setupRenderState();


                },
                () -> {
                    delegate.clearRenderState();

                    GL11.glDisable(GL11.GL_CLIP_PLANE0);

                });
        this.delegate = delegate;
    }

 

While the clipping does happen currently, it slides with the camera as opposed to being a static clip on the entity. Is there a way I can translate/rotate this clip to where the entity will be? Nothing I've tried in the way of translation seems to do anything except clip at a slightly different angle while still following the camera.

 

I'm assuming this setup code is called on the outside of the translation, so alternatively if there were a way to call this code on the inside of the translation, that would be good also, as that is how I did it in 1.12.2.

Hi

 

I always find the order of translation-scaling-rotation-etc operations to be confusing so this might be off base, but I've usually found the trick to be either

1) put the operation in a different order (eg rotate then translate instead of translate then rotate); or

2) undo the transformation from model space to world space, perform the operation, then reapply the original transformation

Not sure if that's possible (or desirable) inside your new rendertype, but it might be worth a try.

-TGG

 

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.