Problem multi texturing Spatial

when I want to do multi-texturing

but my texture after plating

covers only half of my mesh

I was that "normal" my mesh and completely covered

i presume you meant splatting?

make sure you have texture wrap mode set to repeat…

  TextureState ts = display.getRenderer().createTextureState();
           ts.setEnabled(true);
          
           Texture t1 = TextureManager.loadTexture(
                 TestVertexProgramState.class.getClassLoader().getResource(
              "jmetest/data/images/MOIfuv_mesh.obj_head.001.tga"),
 Texture.MinificationFilter.BilinearNearestMipMap,
    Texture.MagnificationFilter.Bilinear);
        
           t1.setWrap(Texture.WrapMode.Repeat);
           ts.setTexture(t1);



MultiTexturing pass :


Normal  :



in "normal" mode it is the texture mapping uv mesh

in "multi-texture pass" I again the texture to apply on the mesh

can you pm me the model with the textures and i'll check it in scene worker…

.copyTextureCoordinates(0, 1, 1);


in the Spatial object  there is no function (copyTextureCoordinates)

you need to access the Geometry object in the node heirarchy…

from rootnode?

just from your imported model…


I just do not access a geometry from a space "geometry" Extend "Spatial"

there must be a geometry somewhere in your imported model hierarchy…

ie.



import model

node

  trimesh

node

  trimesh



it's these trimeshes that you copy the texture coordinates on…

 loadedSpatial = (Spatial) xmlImporter.load(modelUrl);



where is my hierarchy ?

I just do not import my mesh other than in a Spatial ?

Well, it differs what hottbj-exporter delivers to you (you are using this,right?)

I think in most cases you get an Node and the child of the node will be the geometry.



Try:


Node loadedSpatial = (Node) xmlImporter.load(modelUrl);
Geometry geo = (Geometry)result.getChild(0);
geo.copyTextureCoordinates(0, 1, 1);



If that might throw an nullpointer-exception it might be that the geom-itself is exported (wihtout node)

private void createShaded(Node g) {
          

           TextureState ts = display.getRenderer().createTextureState();
           ts.setEnabled(true);
          
           Texture t1 = TextureManager.loadTexture(
                 TestVertexProgramState.class.getClassLoader().getResource(
              "jmetest/data/images/MOIfuv_mesh.obj_head.001.png"),  Texture.MinificationFilter.BilinearNearestMipMap,
Texture.MagnificationFilter.Bilinear);
        
           t1.setWrap(Texture.WrapMode.Repeat);
           ts.setTexture(t1);
      
    
           RenderPass rp1 = new RenderPass();
           rp1.setPassState(ts);
        
           rp1.add(g);
          
    
           pManager.add(rp1);
  

        
       }



   Node Sshaded = loadModel(new URL( "file:C:/Users/aznur/Desktop/default-jme.xml"));


           createShaded(Sshaded) ;
        
           
           
            Geometry geo = (Geometry)Sshaded.getChild(0);
           geo.copyTextureCoordinates(0, 1, 1);
           
           rootNode.attachChild( Sshaded );
           
           rootNode.updateRenderState();
           rootNode.updateGeometricState(0, true);
         



yes i use hottbj-exporter
its still not working I do not understand

it might have multiple geometries, iterate over all children and copy the texture coordinates



furthermore, in your code above, i dont see where you set the second texture to the texturestate and also:


t1.setWrap(Texture.WrapMode.Repeat);



that could be the problem you are having, remove that line.

try using this on the imported model…

ie.



copyTextureCoords(Sshaded, 0, 1, 1);



final   static   public   void   copyTextureCoords(Spatial cl_s, int i_from, int i_to, float f_factor) {
   if(cl_s instanceof Geometry) {
      ((Geometry)cl_s).copyTextureCoordinates(i_from, i_to, f_factor);
   } else if(cl_s instanceof Node) {
      Node      lcl_n = (Node)cl_s;
      for(Spatial lcl_child : lcl_n.getChildren()) {
         copyTextureCoords(lcl_child, i_from, i_to, f_factor);
      }
   }
}


problem solved with import md5