unascribed / BlockRenderer

A mod to render blocks and items. Useful for wikis.
https://www.curseforge.com/minecraft/mc-mods/blockrenderer
MIT License
23 stars 17 forks source link

Ability to render mobs. #12

Open mikuhl-dev opened 7 years ago

mikuhl-dev commented 7 years ago

This is the feature that will complete the mod. We have these nice block renders for wikis but mob pages are lacking nice renders. This will even help the vanilla wiki because the new 1.11 mobs are lacking good renders as the people who made the good ones in blender have dropped off the face of the earth.

xbony2 commented 7 years ago

Just to add on to this, this would be awesome for us at the FTB Gamepedia who don't have time to create advanced renderings :O

mikuhl-dev commented 6 years ago

Would like an update on this!

unascribed commented 6 years ago

I've been busy with work and haven't really had time to work on any of my mods.

mikuhl-dev commented 6 years ago

Since mobs can come with different NBT and such, I would say pressing the render key while looking at the mob should render that specific one.

mikuhl-dev commented 6 years ago

@unascribed I figured out how to render entities like this:

            GlStateManager.enableColorMaterial();
            GlStateManager.pushMatrix();
            Float scale = height / (1 + entity.height); // Scale needs to be adjusted to always get a 512 sized image, not sure how to do that.
            GlStateManager.translate(width / 2, height / 2 + entity.height * scale / 2, 50.0F);
            GlStateManager.scale(scale, scale, scale);
            GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); // For some reason mobs are rendered upside down.
            GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F); // Ortho angle on y axis.
            GlStateManager.rotate(30.0F, 1.0F, 0.0F, 1.0F); // Ortho angle on x and z axis.
            entity.setRotationYawHead(0); // Minecraft gives mobs a slightly random head facing. Reset it.
            RenderHelper.enableStandardItemLighting();
            RenderManager rendermanager = mc.getRenderManager();
            rendermanager.setPlayerViewY(180.0F);
            rendermanager.setRenderShadow(false);
            rendermanager.renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false);
            rendermanager.setRenderShadow(true);
            GlStateManager.popMatrix();
            RenderHelper.disableStandardItemLighting();
            GlStateManager.disableRescaleNormal();
            GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
            GlStateManager.disableTexture2D();
            GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);

Need a whole GUI with options and stuff like to flip axis' because some mobs like Ender Dragon are backwards.

image

mikuhl-dev commented 6 years ago

It seems that the renders will have to be manually sized, because the bounding boxes are not accurate on lots of mobs.

mikuhl-dev commented 5 years ago

Cant you just increase the scale by 1 until it exceeds 512 pixels?

unascribed commented 5 years ago

You can't just ask the GPU how big something is. That isn't how it works.

mikuhl-dev commented 5 years ago

I did it myself. I just start from scale 0 and add 1 to the scale until the longest part of the read image reads more than 512 pixels, and then scale it down by one and that is the final image.

unascribed commented 5 years ago

readPixels is an extremely slow operation and this would make bulk renders unacceptably slow.

-------- Original Message -------- On Jul 18, 2019, 06:32, Michael wrote:

I did it myself. I just start from scale 0 and add 1 to the scale until the longest part of the read image reads more than 512 pixels, and then scale it down by one and that is the final image.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mikuhl-dev commented 5 years ago

Yes the game lags for a second, but usually you want to do renders for mobs on-demand, because there are many variables you might want to render, like dye, armor, etc.

unascribed commented 5 years ago

Due to the usage of the DataManager for entities, all permutations of entity properties can be iterated automatically. The game lagging for "a second" is extremely expensive when you start thinking about hundreds or thousands of renders.

If you were to PR this I'd probably merge it, I've stopped caring about Minecraft. Trying to present my concerns and explain why I think this is a bad approach.

tomodachi94 commented 11 months ago

@herbix's renderTo for Minecraft 1.8 implements this quite nicely.