Problème de rendu (vitre) d'un model Techne
-
Salut a tous !
J’ai suivit le tuto de se forum pour crée un model sous Techne, j’en ai pas mal c*** car j’avais des erreurs que je ne comprenais pas, mais j’ai réussis ! J’ai crée une chaise, une table de nuit (4 coloris) ainsi qu’une poubelle et une petite cagette. Mais là n’est pas le problème.
J’ai réalisé un model d’une vitrine, et qui dit vitrine dit vitre… Ce qui veux dire “transparence et opacité” voilà où est le problème >< Ces foutu vitres ! Elle ne s’affiche pas du tout comme je le veux, mais vraiment pas du tout.
Comment faire en sorte que les vitres soient des vitres et non un bloc blanc et moche ? Car sous Techne c’est niquel. Surment un truc a placer, un boue de code, mais je n’ai pas la moindre idée de quoi et comment. C’est pour cela que je me tourne vers vous. Étant encore au stade de Novice, je ne connais pas tout.
Voici la Vitrine sous Techne
Et le rendu IG
C’est moche… Et aucune idée de comment résoudre le problème, en espérant que l’on peut le résoudre.
EDIT : Je poste mes codes au cas ou… Même si je ne pense pas que se sois primordial vue que je n’ai aucune erreur ^^’
TileEntityVitrine
package bigShell; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; public class TileEntityVitrine extends TileEntity { public byte direction; public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); direction = nbtTag.getByte("direction"); } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); for(int i = 0; i < 5; i++) { nbtTag.setByte("direction", direction); } } public void setDirection(byte direct) { direction = direct; } public byte getDirection() { return direction; } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound); } public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { this.readFromNBT(pkt.data); } }
ModelVitrine
package bigShell.Client; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelVitrine extends ModelBase { //fields ModelRenderer Shape1; ModelRenderer Shape2; ModelRenderer Shape3; ModelRenderer Shape4; ModelRenderer Shape5; ModelRenderer Shape6; ModelRenderer Shape7; ModelRenderer Shape8; ModelRenderer Shape9; ModelRenderer Shape10; ModelRenderer Shape11; ModelRenderer Shape12; ModelRenderer Shape13; ModelRenderer Shape14; ModelRenderer Shape15; ModelRenderer Shape16; ModelRenderer Shape17; ModelRenderer Shape18; ModelRenderer Shape19; ModelRenderer Shape20; ModelRenderer Shape21; ModelRenderer Shape22; ModelRenderer Shape23; ModelRenderer Shape24; ModelRenderer Shape25; ModelRenderer Shape26; ModelRenderer Shape27; ModelRenderer Shape28; ModelRenderer Shape29; ModelRenderer Shape30; ModelRenderer Shape31; ModelRenderer Shape32; public ModelVitrine() { textureWidth = 128; textureHeight = 128; Shape1 = new ModelRenderer(this, 124, 0); Shape1.addBox(0F, 0F, 0F, 1, 28, 1); Shape1.setRotationPoint(7F, -7F, -8F); Shape1.setTextureSize(128, 128); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F); Shape2 = new ModelRenderer(this, 119, 0); Shape2.addBox(0F, 0F, 0F, 1, 28, 1); Shape2.setRotationPoint(-8F, -7F, -8F); Shape2.setTextureSize(128, 128); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F); Shape3 = new ModelRenderer(this, 114, 0); Shape3.addBox(0F, 0F, 0F, 1, 28, 1); Shape3.setRotationPoint(-8F, -7F, 7F); Shape3.setTextureSize(128, 128); Shape3.mirror = true; setRotation(Shape3, 0F, 0F, 0F); Shape4 = new ModelRenderer(this, 109, 0); Shape4.addBox(0F, 0F, 0F, 1, 28, 1); Shape4.setRotationPoint(7F, -7F, 7F); Shape4.setTextureSize(128, 128); Shape4.mirror = true; setRotation(Shape4, 0F, 0F, 0F); Shape5 = new ModelRenderer(this, 64, 30); Shape5.addBox(0F, 0F, 0F, 16, 1, 16); Shape5.setRotationPoint(-8F, -8F, -8F); Shape5.setTextureSize(128, 128); Shape5.mirror = true; setRotation(Shape5, 0F, 0F, 0F); Shape6 = new ModelRenderer(this, 64, 48); Shape6.addBox(0F, 0F, 0F, 16, 1, 16); Shape6.setRotationPoint(-8F, 21F, -8F); Shape6.setTextureSize(128, 128); Shape6.mirror = true; setRotation(Shape6, 0F, 0F, 0F); Shape7 = new ModelRenderer(this, 78, 0); Shape7.addBox(0F, 0F, 0F, 1, 1, 14); Shape7.setRotationPoint(-8F, -7F, -7F); Shape7.setTextureSize(128, 128); Shape7.mirror = true; setRotation(Shape7, 0F, 0F, 0F); Shape8 = new ModelRenderer(this, 47, 0); Shape8.addBox(0F, 0F, 0F, 1, 1, 14); Shape8.setRotationPoint(7F, -7F, -7F); Shape8.setTextureSize(128, 128); Shape8.mirror = true; setRotation(Shape8, 0F, 0F, 0F); Shape9 = new ModelRenderer(this, 78, 16); Shape9.addBox(0F, 0F, 0F, 14, 1, 1); Shape9.setRotationPoint(-7F, -7F, 7F); Shape9.setTextureSize(128, 128); Shape9.mirror = true; setRotation(Shape9, 0F, 0F, 0F); Shape10 = new ModelRenderer(this, 78, 19); Shape10.addBox(0F, 0F, 0F, 14, 1, 1); Shape10.setRotationPoint(-7F, -7F, -8F); Shape10.setTextureSize(128, 128); Shape10.mirror = true; setRotation(Shape10, 0F, 0F, 0F); Shape11 = new ModelRenderer(this, 73, 16); Shape11.addBox(0F, 0F, 0F, 1, 2, 1); Shape11.setRotationPoint(7F, 22F, 7F); Shape11.setTextureSize(128, 128); Shape11.mirror = true; setRotation(Shape11, 0F, 0F, 0F); Shape12 = new ModelRenderer(this, 68, 16); Shape12.addBox(0F, 0F, 0F, 1, 2, 1); Shape12.setRotationPoint(7F, 22F, -8F); Shape12.setTextureSize(128, 128); Shape12.mirror = true; setRotation(Shape12, 0F, 0F, 0F); Shape13 = new ModelRenderer(this, 73, 20); Shape13.addBox(0F, 0F, 0F, 1, 2, 1); Shape13.setRotationPoint(-8F, 22F, -8F); Shape13.setTextureSize(128, 128); Shape13.mirror = true; setRotation(Shape13, 0F, 0F, 0F); Shape14 = new ModelRenderer(this, 68, 20); Shape14.addBox(0F, 0F, 0F, 1, 2, 1); Shape14.setRotationPoint(-8F, 22F, 7F); Shape14.setTextureSize(128, 128); Shape14.mirror = true; setRotation(Shape14, 0F, 0F, 0F); Shape15 = new ModelRenderer(this, 7, 32); Shape15.addBox(0F, 0F, 0F, 14, 1, 14); Shape15.setRotationPoint(-7F, 7F, -7F); Shape15.setTextureSize(128, 128); Shape15.mirror = true; setRotation(Shape15, 0F, 0F, 0F); Shape16 = new ModelRenderer(this, 33, 48); Shape16.addBox(0F, 0F, 0F, 1, 3, 14); Shape16.setRotationPoint(7F, 6F, -7F); Shape16.setTextureSize(128, 128); Shape16.mirror = true; setRotation(Shape16, 0F, 0F, 0F); Shape17 = new ModelRenderer(this, 2, 48); Shape17.addBox(0F, 0F, 0F, 1, 3, 14); Shape17.setRotationPoint(-8F, 6F, -7F); Shape17.setTextureSize(128, 128); Shape17.mirror = true; setRotation(Shape17, 0F, 0F, 0F); Shape18 = new ModelRenderer(this, 78, 22); Shape18.addBox(0F, 0F, 0F, 14, 3, 1); Shape18.setRotationPoint(-7F, 6F, -8F); Shape18.setTextureSize(128, 128); Shape18.mirror = true; setRotation(Shape18, 0F, 0F, 0F); Shape19 = new ModelRenderer(this, 41, 16); Shape19.addBox(0F, 0F, 0F, 12, 1, 1); Shape19.setRotationPoint(-6F, 7F, 7F); Shape19.setTextureSize(128, 128); Shape19.mirror = true; setRotation(Shape19, 0F, 0F, 0F); Shape20 = new ModelRenderer(this, 41, 19); Shape20.addBox(0F, 0F, 0F, 12, 1, 1); Shape20.setRotationPoint(-6F, -6F, 7F); Shape20.setTextureSize(128, 128); Shape20.mirror = true; setRotation(Shape20, 0F, 0F, 0F); Shape21 = new ModelRenderer(this, 41, 22); Shape21.addBox(0F, 0F, 0F, 12, 1, 1); Shape21.setRotationPoint(-6F, 20F, 7F); Shape21.setTextureSize(128, 128); Shape21.mirror = true; setRotation(Shape21, 0F, 0F, 0F); Shape22 = new ModelRenderer(this, 36, 0); Shape22.addBox(0F, 0F, 0F, 1, 27, 1); Shape22.setRotationPoint(6F, -6F, 7F); Shape22.setTextureSize(128, 128); Shape22.mirror = true; setRotation(Shape22, 0F, 0F, 0F); Shape23 = new ModelRenderer(this, 31, 0); Shape23.addBox(0F, 0F, 0F, 1, 27, 1); Shape23.setRotationPoint(-7F, -6F, 7F); Shape23.setTextureSize(128, 128); Shape23.mirror = true; setRotation(Shape23, 0F, 0F, 0F); Shape24 = new ModelRenderer(this, 0, 66); Shape24.addBox(0F, 0F, 0F, 12, 12, 1); Shape24.setRotationPoint(-6F, -5F, 7F); Shape24.setTextureSize(128, 128); Shape24.mirror = true; setRotation(Shape24, 0F, 0F, 0F); Shape25 = new ModelRenderer(this, 27, 66); Shape25.addBox(0F, 0F, 0F, 12, 12, 1); Shape25.setRotationPoint(-6F, 8F, 7F); Shape25.setTextureSize(128, 128); Shape25.mirror = true; setRotation(Shape25, 0F, 0F, 0F); Shape26 = new ModelRenderer(this, 0, 80); Shape26.addBox(0F, 0F, 0F, 1, 12, 14); Shape26.setRotationPoint(-8F, -6F, -7F); Shape26.setTextureSize(128, 128); Shape26.mirror = true; setRotation(Shape26, 0F, 0F, 0F); Shape27 = new ModelRenderer(this, 31, 80); Shape27.addBox(0F, 0F, 0F, 1, 12, 14); Shape27.setRotationPoint(-8F, 9F, -7F); Shape27.setTextureSize(128, 128); Shape27.mirror = true; setRotation(Shape27, 0F, 0F, 0F); Shape28 = new ModelRenderer(this, 62, 80); Shape28.addBox(0F, 0F, 0F, 1, 12, 14); Shape28.setRotationPoint(7F, -6F, -7F); Shape28.setTextureSize(128, 128); Shape28.mirror = true; setRotation(Shape28, 0F, 0F, 0F); Shape29 = new ModelRenderer(this, 93, 80); Shape29.addBox(0F, 0F, 0F, 1, 12, 14); Shape29.setRotationPoint(7F, 9F, -7F); Shape29.setTextureSize(128, 128); Shape29.mirror = true; setRotation(Shape29, 0F, 0F, 0F); Shape30 = new ModelRenderer(this, 0, 15); Shape30.addBox(0F, 0F, 0F, 14, 12, 1); Shape30.setRotationPoint(-7F, -6F, -8F); Shape30.setTextureSize(128, 128); Shape30.mirror = true; setRotation(Shape30, 0F, 0F, 0F); Shape31 = new ModelRenderer(this, 0, 0); Shape31.addBox(0F, 0F, 0F, 14, 12, 1); Shape31.setRotationPoint(-7F, 9F, -8F); Shape31.setTextureSize(128, 128); Shape31.mirror = true; setRotation(Shape31, 0F, 0F, 0F); Shape32 = new ModelRenderer(this, 41, 0); Shape32.addBox(0F, 0F, 0F, 1, 1, 1); Shape32.setRotationPoint(4F, 7F, 7.5F); Shape32.setTextureSize(128, 128); Shape32.mirror = true; setRotation(Shape32, 0F, 0F, 0F); } public void render(float f) { Shape1.render(f); Shape2.render(f); Shape3.render(f); Shape4.render(f); Shape5.render(f); Shape6.render(f); Shape7.render(f); Shape8.render(f); Shape9.render(f); Shape10.render(f); Shape11.render(f); Shape12.render(f); Shape13.render(f); Shape14.render(f); Shape15.render(f); Shape16.render(f); Shape17.render(f); Shape18.render(f); Shape19.render(f); Shape20.render(f); Shape21.render(f); Shape22.render(f); Shape23.render(f); Shape24.render(f); Shape25.render(f); Shape26.render(f); Shape27.render(f); Shape28.render(f); Shape29.render(f); Shape30.render(f); Shape31.render(f); Shape32.render(f); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } }
TileEntityVitrineSpecialRender
package bigShell.Client; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import bigShell.TileEntityTableNuit3; import bigShell.TileEntityVitrine; import bigShell.ClientProxy.ClientProxy.IInventoryRenderer; public class TileEntityVitrineSpecialRender extends TileEntitySpecialRenderer implements IInventoryRenderer { private final ModelVitrine model = new ModelVitrine(); public static final ResourceLocation textureLocation = new ResourceLocation("bigshell", "textures/blocks/ModelVitrine.png"); public TileEntityVitrineSpecialRender() { this.setTileEntityRenderer(TileEntityRenderer.instance); } @Override public void renderInventory(double x, double y, double z) { this.renderTileEntityVitrineAt(null, x, y, z, 0.0F); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { this.renderTileEntityVitrineAt((TileEntityVitrine)te, x, y, z, f); } public void renderTileEntityVitrineAt(TileEntityVitrine te, double x, double y, double z, float f) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5F, y + 1.5F, z + 0.5F); this.bindTexture(textureLocation); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); if(te != null) { GL11.glRotatef(90F * te.getDirection(), 0.0F, 1.0F, 0.0F); } this.model.render(0.0625F); GL11.glPopMatrix(); } }
BlockVitrine
package bigShell.Block; import bigShell.TileEntityVitrine; import bigShell.TileEntityTableNuit1; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockVitrine extends Block { public BlockVitrine(int id) { super(id, Material.iron); } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityVitrine(); } public boolean hasTileEntity(int metadata) { return true; } public boolean renderAsNormalBlock() { return false; } public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public int getRenderType() { return -1; } //public void registerIcons(IconRegister icon) { //this.blockIcon = icon.registerIcon(""); public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; TileEntity te = world.getBlockTileEntity(x, y, z); if(te != null && te instanceof TileEntityVitrine) { ((TileEntityVitrine)te).setDirection((byte)direction); world.markBlockForUpdate(x, y, z); } } }
Merci d’avance.
-
Tu as réglé ton bloc pour qu’il ne soit pas opaque ?
Si non, ajoute quelque chose genre
.isOpaque(false);
-
J’ai vu ça il y a n’y a pas longtemps :
http://www.minecraftforge.net/forum/index.php/topic,16150.0.html -
public boolean isOpaqueCube() { return false; }
Mon bloc n’est pas opaque Gugu
Merci Robin, je vais tenter de déchiffré cette langue :3
EDIT : Bon, bah j’ai rien compris xD Mais j’ai trouvé une idée de se que je dois faire, mais aucune idée du comment… Il faudrait que j’active la transparence sur certain shape… Mais comment ^^
-
Déjà, j’imagine que ta texture comporte une couche alpha? Si non, c’est là d’où vient le problème.
-
Nop, pas de couche Alpha, je n’ai malheureusement pas beaucoup de connaissance en Java et je ne sais pas vraiment comment en mettre une, même si j’ai une petite idée.
Merci de m’avoir mit sur une piste
-
Ba si, pour faire de la transparence sur un png tu as forcement une couche alpha, et justement ta fonction de rendu ne la prend pas en compte, c’est pour ça que le rendu voulu n’est pas obtenu.
-
Oui, c’est ce que je voulais dire, j’ai une couche alpha sur le PNG mais je ne sais pas comment l’appliquer sur mon rendu en faite ^^
-
Juste avant model.render
ajoute:GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
J’avais déjà testé se code, cette fois ci je l’ai mit avant le render mais toujours le même résultat, je regarderai mieux se soir quand j’aurais Eclipse sous les yeux.
Merci.