Jump to content

[1.14.4] Lighting problem when rotating OBJ model


Yanny7

Recommended Posts

I have problem with lighting when I rotate model in TER. When it is rendered without rotation, lighting for up/down is correct, but all sides are bright. When I rotate it a bit, dark side (from bottom) is rendered on top. See picture where model is rotated ~90°

904420478_Snmkaobrazovkyz2019-10-2410-19-20.png.65fef5b0773f4154bdabf370a178e281.png

 

TES:

    public void render(WaterWheelTile tile, double x, double y, double z, float partialTicks, int destroyStage) {
        if (model == null) {
            model = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation("toomanyores:waterwheel"));
        }

        Direction direction = tile.getBlockState().get(WaterWheelBlock.HORIZONTAL_FACING);

        GlStateManager.pushMatrix();

        GlStateManager.enableLighting();
        GlStateManager.translated(x, y, z);
        GlStateManager.scaled(1/16.0, 1/16.0, 1/16.0);
        GlStateManager.translated(8, 16, 8);

        switch (direction) {
            case NORTH:
                GlStateManager.rotated(90, 0, 1, 0);
                break;
            case SOUTH:
                GlStateManager.rotated(270, 0, 1, 0);
                break;
            case EAST:
                GlStateManager.rotated(180, 0, 1, 0);
                break;
            case WEST:
                GlStateManager.rotated(0, 0, 1, 0);
                break;
        }

        GlStateManager.translated(0, -8, 0);
        GlStateManager.rotated(90, 1, 0, 0);
        GlStateManager.translated(0, 8, 0);

        if (Minecraft.isAmbientOcclusionEnabled()) {
            GlStateManager.shadeModel(GL11.GL_SMOOTH);
        } else {
            GlStateManager.shadeModel(GL11.GL_FLAT);
        }

        int i = tile.getWorld().getCombinedLight(tile.getPos(), 0);
        int j = i % 65536;
        int k = i / 65536;
        float brightness = Math.max(j / 255f, k / 255f);

        bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
        Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightness(model, tile.getBlockState(), brightness, true);

        GlStateManager.disableLighting();
        GlStateManager.popMatrix();
    }

 

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.