Posted September 6, 201411 yr I am making a jar, and I have a good 3d model for it, but some of the faces aren't rendering throuch other faces. Srceenshots: http://downloads.mc42.net/ForgeImages/2014-09-06_08.18.12.png[/img]http://downloads.mc42.net/ForgeImages/2014-09-06_08.18.20.png[/img]http://downloads.mc42.net/ForgeImages/2014-09-06_08.18.24.png[/img]http://downloads.mc42.net/ForgeImages/2014-09-06_08.18.30.png[/img]http://downloads.mc42.net/ForgeImages/2014-09-06_08.18.40.png[/img] Code: Renderer: package net.mc42.mods.eclipses.tileentities; import org.lwjgl.opengl.GL11; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class TileEntityJarRenderer extends TileEntitySpecialRenderer { //The model of your block private final TileEntityJarCapModel modelCap; private final TileEntityJarBodyModel modelBody; private final TileEntityJarContentsModel modelContent; public TileEntityJarRenderer() { this.modelCap = new TileEntityJarCapModel(); this.modelBody = new TileEntityJarBodyModel(); this.modelContent = new TileEntityJarContentsModel(); } private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); GL11.glPushMatrix(); GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); GL11.glPopMatrix(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); //Use in 1.6.2 this ResourceLocation textures = (new ResourceLocation("modeclipses:textures/blocks/TileEntityCapJar.png")); //the ':' is very important //binding the textures Minecraft.getMinecraft().renderEngine.bindTexture(textures); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //this.modelBody.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //Tell it to stop rendering for both the PushMatrix's GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); //Use in 1.6.2 this ResourceLocation textures2 = (new ResourceLocation("modeclipses:textures/blocks/solar_essence_still.png")); //the ':' is very important //binding the textures Minecraft.getMinecraft().renderEngine.bindTexture(textures2); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); //GL11.glEnable(GL11.GL_BLEND); //GL11.glDisable(GL11.GL_CULL_FACE); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); this.modelContent.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //Tell it to stop rendering for both the PushMatrix's //GL11.glEnable(GL11.GL_CULL_FACE); //GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); GL11.glPopMatrix(); //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); //Use in 1.6.2 this ResourceLocation textures1 = (new ResourceLocation("modeclipses:textures/blocks/TileEntityBodyJar.png")); //the ':' is very important //binding the textures Minecraft.getMinecraft().renderEngine.bindTexture(textures1); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); this.modelBody.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //Tell it to stop rendering for both the PushMatrix's GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); GL11.glPopMatrix(); } //Set the lighting stuff, so it changes it's brightness properly. private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; //float brightness = block.getBlockBrightness(world, i, j, k); //As of MC 1.7+ block.getBlockBrightness() has become block.getLightValue(): float brightness = block.getLightValue(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } } Model Cap: // Date: 9/5/2014 8:20:37 PM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package net.mc42.mods.eclipses.tileentities; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class TileEntityJarCapModel extends ModelBase { //fields ModelRenderer Shape1; ModelRenderer Shape2; public TileEntityJarCapModel() { textureWidth = 64; textureHeight = 32; /*Shape1 = new ModelRenderer(this, 0, 0); Shape1.addBox(0F, 0F, 0F, 12, 14, 12); Shape1.setRotationPoint(-6F, 10F, -6F); Shape1.setTextureSize(64, 32); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F);*/ Shape2 = new ModelRenderer(this, 0, 0); Shape2.addBox(0F, 0F, 0F, 10, 2, 10); Shape2.setRotationPoint(-5F, 8F, -5F); Shape2.setTextureSize(64, 32); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); //Shape1.render(f5); Shape2.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } Model Body: // Date: 9/5/2014 8:20:37 PM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package net.mc42.mods.eclipses.tileentities; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class TileEntityJarBodyModel extends ModelBase { //fields ModelRenderer Shape1; ModelRenderer Shape2; public TileEntityJarBodyModel() { textureWidth = 64; textureHeight = 32; Shape1 = new ModelRenderer(this, 0, 0); Shape1.addBox(0F, 0F, 0F, 12, 14, 12); Shape1.setRotationPoint(-6F, 10F, -6F); Shape1.setTextureSize(64, 32); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F); /*Shape2 = new ModelRenderer(this, 0, 0); Shape2.addBox(0F, 0F, 0F, 10, 2, 10); Shape2.setRotationPoint(-5F, 8F, -5F); Shape2.setTextureSize(64, 32); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F);*/ } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Shape1.render(f5); //Shape2.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } Model Contents: // Date: 9/5/2014 8:20:37 PM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package net.mc42.mods.eclipses.tileentities; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class TileEntityJarContentsModel extends ModelBase { //fields ModelRenderer Shape1; ModelRenderer Shape2; public TileEntityJarContentsModel() { textureWidth = 16; textureHeight = 16; Shape1 = new ModelRenderer(this, 0, 0); Shape1.addBox(0F, 0F, 0F, 10, /*12*/0, 10); Shape1.setRotationPoint(-5F, /*11F*/23F, -5F); Shape1.setTextureSize(16, 16); Shape1.mirror = false; setRotation(Shape1, 0F, 0F, 0F); /*Shape2 = new ModelRenderer(this, 0, 0); Shape2.addBox(0F, 0F, 0F, 10, 2, 10); Shape2.setRotationPoint(-5F, 8F, -5F); Shape2.setTextureSize(16, 16); Shape2.mirror = false; setRotation(Shape2, 0F, 0F, 0F);*/ } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Shape1.render(f5); //Shape2.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } Image Files: Any help is very appreciated!
September 6, 201411 yr I had this problem once. Try making the texture a little bit more opaque and see if it works. Check out my mod, Realms of Chaos, here. If I helped you, be sure to press the "Thank You" button!
September 6, 201411 yr I think you missed the blend function. Try adding something like "GL11.glBlendFunc(sourceFactor, destintationFactor)" after glEnable blend, it should work I guess.
September 6, 201411 yr Author I think you missed the blend function. Try adding something like "GL11.glBlendFunc(sourceFactor, destintationFactor)" after glEnable blend, it should work I guess. What are the sourceFactor and destinationFactor?
September 6, 201411 yr Here is the frequently used one: GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Here is more information on blending: http://relativity.net.au/gaming/java/Transparency.html
September 6, 201411 yr Author Thanks, but no luck. It seems to have something to do with how and where I placed them from. I'm goning to try total transparency next. EDIT: Worked.
September 6, 201411 yr Hi A general comment about alpha blending is that the order of rendering the faces is very important. If you render the rear pane alpha first, then the front pane alpha next, it will look different to rendering the front pane alpha first and the back pane alpha second. This is because of the effects of depth testing, and additionally the way alpha blending calculates the final colour. In your case, when the furthest-away faces are rendered first, then the closest faces are blended over the top, you will see the furthest-away faces. But if your closest faces are rendered first, when the furthest-away faces get rendered, they are behind the closest faces so they get culled i.e. not drawn at all. You can see this very clearly in the top screenshot, which looks like it must have rendered left - back - right - front. You can turn off writing to the depth buffer using GL11.glDepthMask(false); but the faces still wind up looking different depending on which one is rendered first. I have solved this problem in the past by writing an IBSRH which made sure to render the furthest faces first, by checking the player position relative to the block. -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.