• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    OpenGL et la transparence

    Sans suite
    3
    3
    1067
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • RedRelay
      RedRelay Moddeurs confirmés dernière édition par

      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 réponse Dernière réponse Répondre Citer 0
      • Gugu
        Gugu dernière édition par

        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 réponse Dernière réponse Répondre Citer 0
        • jglrxavpok
          jglrxavpok Modérateurs dernière édition par

          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 réponse Dernière réponse Répondre Citer 0
          • 1 / 1
          • Premier message
            Dernier message
          Design by Woryk
          Contact / Mentions Légales

          MINECRAFT FORGE FRANCE © 2018

          Powered by NodeBB