Multitexture Problem!

I tried to use multi textures, but as soon I add a second texture (paint texture), both textures disappear ?!

PathUtil.locateResource(PathUtil.APPLICATION_DIRECTORY, child.getChild("color").getValue()) --> returns an url path(is working)


public void paintPart(Element child, Node object){
      
      TextureState texture_state = display.getRenderer().createTextureState();
      texture_state.setEnabled(true);
      
      Texture baseMap = TextureManager.loadTexture(
                PathUtil.locateResource(PathUtil.APPLICATION_DIRECTORY, child.getChild("color").getValue()),
                Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);
        //baseMap.setWrap(Texture.WrapMode.Repeat);
        //baseMap.setAnisotropicFilterPercent(Cash.ANISOTROPIC);
        texture_state.setTexture(baseMap, 0);
       
        if(child.getChild("paint")!= null){
           System.out.println("is Loading");
           Texture paintMap = TextureManager.loadTexture(
                    PathUtil.locateResource(PathUtil.APPLICATION_DIRECTORY, child.getChild("paint").getValue()),
                    Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);
           //paintMap.setWrap(Texture.WrapMode.Repeat);
           //paintMap.setAnisotropicFilterPercent(Cash.ANISOTROPIC);
            texture_state.setTexture(paintMap, 1);
        }
       
        object.setRenderState(texture_state);
       
        /*BlendState alpha = display.getRenderer().createBlendState();
      alpha.setBlendEnabled(true);
      alpha.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
      alpha.setDestinationFunction(BlendState.DestinationFunction.One);
      alpha.setTestEnabled(true);
      alpha.setTestFunction(BlendState.TestFunction.GreaterThan);
      alpha.setEnabled(true);*/
      
      BlendState as = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
        as.setBlendEnabled(false);
        as.setTestEnabled(true);
        as.setTestFunction(BlendState.TestFunction.GreaterThan);
        as.setReference(0.5f);
        as.setEnabled(true);
      
      object.setRenderState(as);

      
   }

Well for me something similar worked, try using scne monitor as it might give you a hint what happens.



Also do you copy the texture coordiantes from the first texture unit to the second? else you might end seing only one single pixel of the second.

…do you copy the texture coordiantes from the first texture unit to the second…



No, how can I do that?

No, how can I do that?


Hi and welcome to jME! It's always nice to see new people come to this engine!
Did you ever heard of the jmetest-package or the wiki/userguide? There are quite useful information.

e.g. how MultiTexture is working: http://www.jmonkeyengine.com/wiki/doku.php/multitexturing

or even an example for:

- hardware multitexture: jmetest.renderer.TestMultitexture
- software multitexture: jmetest.renderer.TestMultitexturePass

and in all three sources you can find:

t.copyTextureCoordinates(0, 1, 1.0f);



In this case t is the spatial the TextureCoordinates are already added for layer 0. Here you copy it to layer 1 with scale 1.0f

Good luck for your further work.