One more time: texture troubles after Collada import

Hi!



I've a problem after importing a quite simple building model with the ColladaImporter. But first things first:

I have made a Collada file with Google SketchUp. It should look like this: http://www.panten.org/hs/haus/haus.htm.



The model looks ok, but it seems so that only one of the textures is loaded and attached all over the model. I've already read all related topics in this forum, but they are all something different and no hint works.



This is how it looks: http://www.panten.org/hs/haus/render.htm



This is my loading method:


public Node loadModel(String modelName, boolean kmzStruct)
   {
      String modelPath = "models/";
      String texturePath = "";
      
      if(kmzStruct)
      {
         String rawName = modelName.substring(0, modelName.length()-4);
         modelPath = "models/" + rawName + "/models/";
         texturePath = "models/" + rawName + "/images/";
      }
      
      try
      {
         ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, new SimpleResourceLocator(loadURL(modelPath)));
         ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(loadURL(texturePath)));
        } catch (URISyntaxException e1) {
            System.out.println("Unable to add texture directory to RLT: " + e1.toString());
        }
       
      
      System.out.println((ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, modelName)).getPath());
      
      InputStream modInput = null;
      try {
         modInput = new FileInputStream((ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, modelName)).getPath());
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      
      if (modInput != null)
      {
         ColladaImporter.load(modInput, modelName);
         Node mod = ColladaImporter.getModel();
         ColladaImporter.cleanUp();

         if (mod != null)
         {
            mod.setModelBound(new BoundingBox());
              mod.updateModelBound();
             
            return mod;
         }
      }
      return null;
   }



Edit your post to have the code tag around it "[ code ]" without the spaces. It's hard to read code like you have it, and it spreads out your post very far.

I think there is a weird issue with the ResourceLocaterTool not being able to deal with a '/' at the end.



I could be all wrong here though…

hmm no, the trailing slash is actually needed for the resource locator :slight_smile:

maybe it was the leading slash, I thought I remember something funny with it…



Anyways, sorry I was no help.

I guess that this has nothing to do with the slashes in the path string. I tried all possible combinations and no one worked.



I debugged through the ColladaImporter an it finds all of the texture files and handle them properly (i think). But there is still only one texture displayed on the model.



I also made a simple cube model and applied simple colors to the surface. SketchUp defines them in the dae-file. But jME renders a white cube…?!



I'm going to become desperate… :frowning:

You updated the renderstates and such?

renanse said:

You updated the renderstates and such?


On rootNode, yes.

You don't ever apply a texture state from what I can see…

Trussell said:

You don't ever apply a texture state from what I can see...

I thought that the ColladaImporter handles the textures for this model? Or do I get something wrong there? How should I do this?

AFAIK the only importer that handles that is the OBJ importer, but I've never used Collada.

IMO Trying to import Collada is a waste of time. From my talk with Josh, the importer in jME supports a certain "flavor" of the collada format which is only made correctly from the NCSoft exporter, all other exporters are pretty much out in the cold. Just wait till the official release of the mesh.xml importer and use that instead as it is much, much more reliable.

I dunno… I'm doing a little side project with jME 2.0 and needed some models.  I went to google's sketchup 3d warehouse and pulled down some files (make sure they are collada) and loaded them in with no issues, (including textures.)



Obviously that doesn't mean all sketchup collada files will load, but the ones I tried did.  This one is one of those I tried:



http://sketchup.google.com/3dwarehouse/details?mid=c578e41c68afef6eb8b8393544f4a61&prevstart=0



To do it, first I set up a texture locator…  (Note that I decided to have things in a data folder in my working directory, but you can set it up other ways too of course.)


      try {
         SimpleResourceLocator loc = new SimpleResourceLocator(
               new File("./data/textures/").toURI());
         ResourceLocatorTool.addResourceLocator(
               ResourceLocatorTool.TYPE_TEXTURE, loc);
      } catch (Exception e) {
         e.printStackTrace();
      }



Then I loaded in the model like so:

      ExtraPluginManager.registerExtraPlugin("GOOGLEEARTH", new GoogleEarthPlugin());
      try {
         ColladaImporter.load(
               new FileInputStream(new File("./data/models/nyt.dae")), "building");
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }
      Spatial building = ColladaImporter.getModel();
      building.setModelBound(new BoundingBox());
      building.updateModelBound();



The first line registers a plugin to handle the GOOGLECODE tags (some extra info in google collada files that deals with culling.)  The rest is all pretty straightforward I would guess.  In later code (not shown) I then go on to scale it and center it and a few other things.  Since I'm using SimpleGame and this is done during init, I then attach it to my rootNode and it is automatically updated (render states, geometric state, etc.)

I think this was already talked about in some threads, but it happens to often. Did You looked in the DAE File for "blinn", this you should replace with "phong". In the exporter it should be also possible to change this.



a question: The ColladaImporter works ok, as long as I don't use skinning. This Importer is only written for the NCSOft exporter, fine, I can live with that. But why does this importer does't warn me, that it doesn't support my used format?  :x

One thing I'd also mention is that just like when exporting skinned models to other formats, I recall our artists at NCsoft had to make sure they did a few things before exporting.  Unfortunately I do not know the exact steps, but it was your typical stuff like having a single root bone, baking matrices, etc.

hmm, ok. Then I should go on expedition. to find out whats missing  :slight_smile:

@renanse

Your code works! But only after I switched to jMonkey 2.0. Until now I worked with 1.0 and it seems, that the old ColladaImporter really can't handle the SketchUp Textures.



Thanks!