Transparency quad and textures

Hello,



i would like to display a quad with a texture on it.

Just guessing here, since I don't have alot of experience myself, but have you checked so your texture is actually transparent in that area?

Yes i'm sure of it

More guessing… It seems you haven't set the actual test functions. Maybe try something like:


      as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
      as.setDstFunction(AlphaState.DB_ONE);
      as.setTestFunction(AlphaState.TF_GREATER);



Not sure *exactly* what that does, but... :)

No it doesn't work…

I tested this code and run fine.



      Quad q= new Quad("DiceInfo",1,1);
      q.setLightCombineMode(LightState.OFF);
      q.setTextureCombineMode(TextureState.REPLACE);

      URL textu=DiceUI.class.getClassLoader().getResource("resources/images/frame6.gif");
      AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();

      as.setEnabled(true);
      as.setBlendEnabled(true);
      as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
      as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
      as.setTestEnabled(true);
      as.setTestFunction(AlphaState.TF_GREATER);

      TextureState ts =
         DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      ts.setEnabled(true);
      Texture texture =
         TextureManager.loadTexture(
            textu,
            Texture.MM_LINEAR,
            Texture.FM_LINEAR);
      ts.setTexture(texture);
      q.setRenderState(ts);
      q.setRenderState(as);
      q.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
      rootNode.attachChild(q);
   



Thank you very much for your help. It works fine for me too !!!

Is there any way to asjust the transparency dynamically, so you can easily fade in or out an object?



I have a suspicion you can't do this without dynamically adjusting a texture with the required alpha level?


Is there any way to asjust the transparency dynamically, so you can easily fade in or out an object?

The colors of a mesh can do this (iterate over vertice colors and change the alpha value).

doh! thanks!

As seen above the following src and dst functions use the alpha from the image.


        alpha.setSrcFunction( AlphaState.SB_SRC_ALPHA );
        alpha.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );



Check that your image really has correct alpha.

Overall transparency can be caused by setSolidColor with an alpha value of 0.5f - do you call that one?

Agh, turns out the transparency worked fine, but I had forgotten to turn off the LightStates for my Quads which made them look as if semi-transparent. heh