Posted December 24, 201410 yr I'm confused on the differences and uses of the TileEntitySpecialRenderer vs the ISimpleRenderingHandler (yes I understand that TESR is a class and ISRH is an interface) I've tried both options for what I wish to do, but I can't seem to find the solution. I want to render a standard block with 3 textures (separate files) overlain on each other on each side. The first texture is completely transparent, the second is a semi-transparent, and the third is one that will switch between icons depending on the block's settings (In, out, or off). I've searched and searched to find a way to use separate files for the textures, and the closest I've gotten is using the default block texture map in the bindtexture for a TileEntitySpecialRenderer. @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { bindTexture(TextureMap.locationBlocksTexture); Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslated(x,y,z); tessellator.startDrawingQuads(); // tessellator.addVertexWithUV(0, 0, 0, 0, 0); // tessellator.addVertexWithUV(0, 1, 0, 0, 1); // tessellator.addVertexWithUV(1, 1, 0, 1, 1); // tessellator.addVertexWithUV(1, 0, 0, 1, 0); tessellator.addVertexWithUV(0, 0, 0, 0, 0); tessellator.addVertexWithUV(1, 0, 0, 1, 0); tessellator.addVertexWithUV(1, 1, 0, 1, 1); tessellator.addVertexWithUV(0, 1, 0, 0, 1); tessellator.draw(); GL11.glPopMatrix(); } but I'm can't figure out how to point to my textures in that texture map. Current Rendering: http://i1381.photobucket.com/albums/ah231/actsof000/2014-12-24_152702_zpsd7d4e443.png[/img] Here are my textures, the red is the semi-transparent, and the clearer one is the third overlay(Sorry for the crude paint job) http://i1381.photobucket.com/albums/ah231/actsof000/2014-12-24_1527021_zpse7894145.png[/img] Overall, I am simply guessing on what I am doing in this method. If you can suggest a good tutorial, example, explanation, etc please do so.
December 24, 201410 yr Author This is what IIcon is for. It gives you the U/V coordinates on the texture map. Okay. How do I use the IIcon in the TESR then?
December 24, 201410 yr Author Well, you get the IIcon from your Block. Then you get the U/V coordinates from it (the methods should be self-explanatory) and use those to apply the correct vertices in the tessellator. Oh okay! So when I get the IIcon I would get the U/V from the texture I wish to display correct? and I would use the U/V Max/Min corresponding to the x,y,z point I am drawing on the block? Okay, how would I go about using both the TESR and the ISRH in the same class? Why does my block not render as a block in my inventory? (sorry for the numerous questions. It seems as connections are made, more are broken haha)
December 25, 201410 yr Hi This link might help to understand the Tessellator and the icon.getMaxU() etc http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html You can use both an ISBRH and a TESR, for example the BlockBeacon does something similar (renders the base as blocks and the beam in TESR). This can make sense if you have a part which doesn't change / isn't animated (goes in the ISBRH) and a part which is animated (goes in the TESR). Like dieSieben says though, generally it doesn't make sense. If you do want to do this, just define both an ISBRH for the block and add a TileEntity with TESR as well, if you do it right they will both be called. Are your textures "opaque with holes", like glass blocks, or are some coloured see-through, like ice? If the former, you can do everything in an ISBRH easily. Just tessellate the same quad three times with a different icon each time. If the latter, stick with a TESR I reckon. It is hard to do both in an ISBRH because you will have to render in two different passes and the coloured see-through pass always comes second. You will need to learn about alpha blending in OpenGL, if you don't already know how to use it, and remember to restore the OpenGL settings back to what they were before you changed them. -TGG
December 25, 201410 yr Author Okay. Well I'm definitely taking this step by step. How do I render the texture on the outside versus the inside of the block like it is doing on the bottom? http://i1381.photobucket.com/albums/ah231/actsof000/2014-12-25_1023431_zps9c6d2afc.png[/img] Code: @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { bindTexture(TextureMap.locationBlocksTexture); Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslated(x,y,z); double Umin = IconRegistry.getIcon("Cell_Side_Red").getMinU(); double Vmin = IconRegistry.getIcon("Cell_Side_Red").getMinV(); double Umax = IconRegistry.getIcon("Cell_Side_Red").getMaxU(); double Vmax = IconRegistry.getIcon("Cell_Side_Red").getMaxV(); tessellator.startDrawingQuads(); //Render side 0 (down) tessellator.addVertexWithUV(0,0,0,Umax,Vmax); tessellator.addVertexWithUV(0,0,1,Umax,Vmin); tessellator.addVertexWithUV(1,0,1,Umin,Vmin); tessellator.addVertexWithUV(1,0,0,Umin,Vmax); //Render side 2 (north) tessellator.addVertexWithUV(0, 0, 0, Umin, Vmin); tessellator.addVertexWithUV(0, 1, 0, Umin, Vmax); tessellator.addVertexWithUV(1, 1, 0, Umax, Vmax); tessellator.addVertexWithUV(1, 0, 0, Umax, Vmin); //Render side 5 (east) tessellator.addVertexWithUV(1, 0, 0, Umax, Vmin); tessellator.addVertexWithUV(1,1,0, Umax, Vmax); tessellator.addVertexWithUV(1,1,1, Umin, Vmax); tessellator.addVertexWithUV(1,0,1, Umin, Vmin); //Render side 3 (south) tessellator.addVertexWithUV(1,0,1, Umax, Vmin); tessellator.addVertexWithUV(1,1,1, Umax, Vmax); tessellator.addVertexWithUV(0,1,1, Umin, Vmax); tessellator.addVertexWithUV(0, 0, 1, Umin, Vmin); tessellator.draw(); GL11.glPopMatrix(); }
December 25, 201410 yr Hi //Render side 0 (down) 1. tessellator.addVertexWithUV(0,0,0,Umax,Vmax); 2. tessellator.addVertexWithUV(0,0,1,Umax,Vmin); 3. tessellator.addVertexWithUV(1,0,1,Umin,Vmin); 4. tessellator.addVertexWithUV(1,0,0,Umin,Vmax); Your face is pointing the wrong way because your coordinates are anti-clockwise when viewed from the top. They need to be anti-clockwise when viewed from the bottom. Just reverse the order of those statements above, i.e. change them to 4. 3. 2. 1. -TGG
December 25, 201410 yr Author Okay, so i transferred my renders over to an ISBRH. And if i'm not mistaken I deleted all of the GLenable/disable stuff because the ISBRH does that for you. Is there a way to fix the clipping of textures between each other Code: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { BaseCell BC = (BaseCell)block; if(BC.renderPass == 1) { // bindTexture(TextureMap.locationBlocksTexture); Tessellator tessellator = Tessellator.instance; // GL11.glPushMatrix(); // GL11.glTranslated(x, y, z); // GL11.glEnable(GL11.GL_BLEND); // GL11.glDisable(GL11.GL_LIGHTING); tessellator.addTranslation(x,y,z); RenderUtils.RenderFullBlock(IconRegistry.getIcon("Cell_Side_Red"), tessellator); RenderUtils.RenderFullBlock(IconRegistry.getIcon("Cell_Side_1"), tessellator); tessellator.addTranslation(-x, -y, -z); // GL11.glEnable(GL11.GL_LIGHTING); // GL11.glDisable(GL11.GL_BLEND); // GL11.glPopMatrix(); } return true; } http://i1381.photobucket.com/albums/ah231/actsof000/2014-12-25_164445_zps0cdc85ed.png[/img]
December 25, 201410 yr Hi I'm not sure what you mean by 'clipping' but you might try this: in order to make sure that the second face passes the 'depth test' (i.e. don't get hidden behind the first face), you can try nudging the second face outwards by a tiny amount If you're drawing the faces manually, for example your first face is 1. tessellator.addVertexWithUV(0,0,0,Umax,Vmax); 2. tessellator.addVertexWithUV(0,0,1,Umax,Vmin); 3. tessellator.addVertexWithUV(1,0,1,Umin,Vmin); 4. tessellator.addVertexWithUV(1,0,0,Umin,Vmax); then you could draw your second face at 1. tessellator.addVertexWithUV(0,-0.001,0,Umax,Vmax); 2. tessellator.addVertexWithUV(0,-0.001,1,Umax,Vmin); 3. tessellator.addVertexWithUV(1,-0.001,1,Umin,Vmin); 4. tessellator.addVertexWithUV(1,-0.001,0,Umin,Vmax); Likewise your opposite face at 1. tessellator.addVertexWithUV(0,1,0,Umax,Vmax); 2. tessellator.addVertexWithUV(0,1,1,Umax,Vmin); 3. tessellator.addVertexWithUV(1,1,1,Umin,Vmin); 4. tessellator.addVertexWithUV(1,1,0,Umin,Vmax); could be followed by the second face at 1. tessellator.addVertexWithUV(0,1.001,0,Umax,Vmax); 2. tessellator.addVertexWithUV(0,1.001,1,Umax,Vmin); 3. tessellator.addVertexWithUV(1,1.001,1,Umin,Vmin); 4. tessellator.addVertexWithUV(1,1.001,0,Umin,Vmax); -TGG
December 26, 201410 yr Author I suppose it isn't necessarily a clipping issue if that didn't work. This is the result: http://i1381.photobucket.com/albums/ah231/actsof000/Untitled_zps96c5a5fd.png[/img] Code: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { BaseCell BC = (BaseCell)block; if(BC.renderPass == 1) { // bindTexture(TextureMap.locationBlocksTexture); Tessellator tessellator = Tessellator.instance; // GL11.glPushMatrix(); // GL11.glTranslated(x, y, z); // GL11.glEnable(GL11.GL_BLEND); // GL11.glDisable(GL11.GL_LIGHTING); tessellator.addTranslation(x,y,z); RenderUtils.RenderFullBlock(IconRegistry.getIcon("Cell_Side_Red"), tessellator); // RenderUtils.RenderFullBlock(IconRegistry.getIcon("Cell_Side_1"), tessellator); double Umin = IconRegistry.getIcon("Cell_Side_1").getMinU(); double Vmin = IconRegistry.getIcon("Cell_Side_1").getMinV(); double Umax = IconRegistry.getIcon("Cell_Side_1").getMaxU(); double Vmax = IconRegistry.getIcon("Cell_Side_1").getMaxV(); // tessellator.startDrawingQuads(); //Render side 0 (down) tessellator.addVertexWithUV(0.9, 0, 0, Umin, Vmax); tessellator.addVertexWithUV(0.9,0,0.9,Umin,Vmin); tessellator.addVertexWithUV(0,0,0.9,Umax,Vmin); tessellator.addVertexWithUV(0,0,0,Umax,Vmax); //Render side 1(up) tessellator.addVertexWithUV(1,1.1,1,Umax,Vmax); tessellator.addVertexWithUV(1,1.1,0,Umax,Vmin); tessellator.addVertexWithUV(0,1.1,0,Umin,Vmin); tessellator.addVertexWithUV(0,1.1,1,Umin,Vmax); //Render side 2 (north) tessellator.addVertexWithUV(0, 0, 0, Umin, Vmin); tessellator.addVertexWithUV(0, 0.9, 0, Umin, Vmax); tessellator.addVertexWithUV(0.9, 0.9, 0, Umax, Vmax); tessellator.addVertexWithUV(0.9, 0, 0, Umax, Vmin); //Render side 3 (south) tessellator.addVertexWithUV(1.1,0,1.1, Umax, Vmin); tessellator.addVertexWithUV(1.1,1.1,1.1, Umax, Vmax); tessellator.addVertexWithUV(0,1.1,1.1, Umin, Vmax); tessellator.addVertexWithUV(0, 0, 1.1, Umin, Vmin); //Render side 4 (west) tessellator.addVertexWithUV(0,0,0,Umin,Vmax); tessellator.addVertexWithUV(0,0,0.9,Umax,Vmax); tessellator.addVertexWithUV(0,0.9,0.9, Umax, Vmin); tessellator.addVertexWithUV(0,0.9,0,Umin,Vmin); //Render side 5 (east) tessellator.addVertexWithUV(1.1, 0, 0, Umax, Vmin); tessellator.addVertexWithUV(1.1,1.1,0, Umax, Vmax); tessellator.addVertexWithUV(1.1,1.1,1.1, Umin, Vmax); tessellator.addVertexWithUV(1.1,0,1.1, Umin, Vmin); tessellator.addTranslation(-x, -y, -z); // GL11.glEnable(GL11.GL_LIGHTING); // GL11.glDisable(GL11.GL_BLEND); // GL11.glPopMatrix(); } return true; } After further observation of the screenshots, it seems as though the block is rendered above the overlay texture. Could that be due to it being render in pass 1?
December 26, 201410 yr Author Indeed that seemed to do the trick. Final Code: @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { BaseCell BC = (BaseCell)block; Tessellator tessellator = Tessellator.instance; tessellator.addTranslation(x, y, z); if(BC.renderPass == 1) { RenderUtils.RenderFullBlock(IconRegistry.getIcon("Cell_Side_Red"), tessellator); } double Umin = IconRegistry.getIcon("Cell_Side_1").getMinU(); double Vmin = IconRegistry.getIcon("Cell_Side_1").getMinV(); double Umax = IconRegistry.getIcon("Cell_Side_1").getMaxU(); double Vmax = IconRegistry.getIcon("Cell_Side_1").getMaxV(); //Render side 0 (down) tessellator.addVertexWithUV(1,-0.001,0,Umin,Vmax); tessellator.addVertexWithUV(1,-0.001,1,Umin,Vmin); tessellator.addVertexWithUV(0,-0.001,1,Umax,Vmin); tessellator.addVertexWithUV(0,-0.001,0,Umax,Vmax); //Render side 1(up) tessellator.addVertexWithUV(1,1.001,1,Umax,Vmax); tessellator.addVertexWithUV(1,1.001,0,Umax,Vmin); tessellator.addVertexWithUV(0,1.001,0,Umin,Vmin); tessellator.addVertexWithUV(0,1.001,1,Umin,Vmax); //Render side 2 (north) tessellator.addVertexWithUV(0, 0, -0.001, Umin, Vmin); tessellator.addVertexWithUV(0, 1, -0.001, Umin, Vmax); tessellator.addVertexWithUV(1, 1, -0.001, Umax, Vmax); tessellator.addVertexWithUV(1, 0, -0.001, Umax, Vmin); //Render side 3 (south) tessellator.addVertexWithUV(1,0,1.001, Umax, Vmin); tessellator.addVertexWithUV(1,1,1.001, Umax, Vmax); tessellator.addVertexWithUV(0,1,1.001, Umin, Vmax); tessellator.addVertexWithUV(0,0,1.001, Umin, Vmin); //Render side 4 (west) tessellator.addVertexWithUV(-0.001,0,0,Umin,Vmax); tessellator.addVertexWithUV(-0.001,0,1,Umax,Vmax); tessellator.addVertexWithUV(-0.001,1,1,Umax,Vmin); tessellator.addVertexWithUV(-0.001,1,0,Umin,Vmin); //Render side 5 (east) tessellator.addVertexWithUV(1.001,0,0, Umax, Vmin); tessellator.addVertexWithUV(1.001,1,0, Umax, Vmax); tessellator.addVertexWithUV(1.001,1,1, Umin, Vmax); tessellator.addVertexWithUV(1.001,0,1, Umin, Vmin); tessellator.addTranslation(-x, -y, -z); return true; }
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.