• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    OpenGL et la transparence

    Sans suite
    3
    3
    1038
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RedRelay
      RedRelay Moddeurs confirmés last edited by

      Hey 🙂
      Voila le contexte, je veux mettre un chunk dans une boite translucide et ça fonctionne presque.
      Enfait, selon le coté ou je regarde ça marche plus ou moins bien 🙂

      Voici quelques screens, suivit du code :

      Le coté qui va bien :

      Les autres :

      Voici le code concerné :

      ​ private void highligthChunk(ForgeFactionChunk c) {
      
      EntityPlayer player = Minecraft.getMinecraft().thePlayer;
      
      int xPos = c.xPosition<<4;
      int zPos = c.zPosition<<4;
      
      drawChunkFaceY(player, xPos, zPos);
      
      drawChunkFaceX(player, xPos, zPos);
      
      drawChunkFaceX(player, xPos+16, zPos);
      
      drawChunkFaceZ(player, xPos, zPos);
      
      drawChunkFaceZ(player, xPos, zPos+16);
      
      }
      private void drawChunkFaceX(EntityPlayer player, int xPos, int zPos) {
      
      if(player.posX < xPos) {
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos);
      GL11.glVertex3f(xPos,0,zPos);
      GL11.glVertex3f(xPos,0,zPos+16);
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos+16);
      }else {
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos+16);
      GL11.glVertex3f(xPos,0,zPos+16);
      GL11.glVertex3f(xPos,0,zPos);
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos);
      }
      }
      
      private void drawChunkFaceY(EntityPlayer player, int xPos, int zPos) {
      int y = player.worldObj.getActualHeight();
      if(player.posY < y) {
      GL11.glVertex3f(xPos+16,y,zPos+16);
      GL11.glVertex3f(xPos,y,zPos+16);
      GL11.glVertex3f(xPos,y,zPos);
      GL11.glVertex3f(xPos+16,y,zPos);
      }else {
      GL11.glVertex3f(xPos+16,y,zPos);
      GL11.glVertex3f(xPos,y,zPos);
      GL11.glVertex3f(xPos,y,zPos+16);
      GL11.glVertex3f(xPos+16,y,zPos+16);
      }
      }
      
      private void drawChunkFaceZ(EntityPlayer player, int xPos, int zPos) {
      if(player.posZ < zPos) {
      GL11.glVertex3f(xPos+16,player.worldObj.getActualHeight(),zPos);
      GL11.glVertex3f(xPos+16,0,zPos);
      GL11.glVertex3f(xPos,0,zPos);
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos);
      
      }else {
      GL11.glVertex3f(xPos,player.worldObj.getActualHeight(),zPos);
      GL11.glVertex3f(xPos,0,zPos);
      GL11.glVertex3f(xPos+16,0,zPos);
      GL11.glVertex3f(xPos+16,player.worldObj.getActualHeight(),zPos);
      }
      }
      

      Avez-vous une petite idée de comment faire pour résoudre ce problème ? Merci 🙂

      –------------------------------------------------------------------------------------
      Si tu trouves mon intervention pertinente, n'hésite pas a m…

      1 Reply Last reply Reply Quote 0
      • Gugu
        Gugu last edited by

        Renseigne toi sur le Z-Buffer pour OpenGL, c’est un truc qui apparait souvent quand on fait un render de cube basique, ou les faces passent devant les autres, alors qu’elles sont derrière

        "If you have a comprehensive explanation for everything then it decreases uncertainty and anxiety and reduces your cognitive load. And if you can use that simplifying algorithm to put yourself on the side of moral virtue then you’re constantly a good person with a minimum of effort."
        ― Jordan B. Peterson

        1 Reply Last reply Reply Quote 0
        • jglrxavpok
          jglrxavpok Modérateurs last edited by

          Il faut aussi dessiner les faces dans l’ordre: les plus loin en premier, les plus proches en dernier en activant GL_ALPHA_TEST et en donnant une valeur de référence pour l’alpha via glAlphaFunc (ou Ref je sais plus) comme 0.001f par exemple.
          Essaie ça, cela devrait aider 😉

          Sent from my GT-I9000 using Tapatalk 2

          Modérateur sur MFF. 
          Mon Github: http://github.com/jglrxavpok
          Mon compte Steam si vous voulez jouer à CS:GO ou TF2 avec moi: https://steamcommunity.com/id/jglrxavpok/

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Design by Woryk
          Contact / Mentions Légales

          MINECRAFT FORGE FRANCE © 2018

          Powered by NodeBB