Texture problem... some are missing

Hi, I’m  having problems with my textures… I’m very new to jME and would appreciate it very much if someone could point me in the right direction  :smiley:

Here is a screenshot of my app:

As you can see the problem is that not all of the textures show correctly :frowning: On one of my other models the textures were on the inside, but not on this one… At first I didn’t have any textures, but when I added some ResourceLocator code it worked…

What do you think could be the problem here?

I’ll include some sourcecode too… first a short version and then a longer version:


      URL modelFile = BergenWindow.class.getClassLoader().getResource("..\res/models/group01-skansenFireStation/skansen.obj");
      FormatConverter converter = new ObjModelConverter(); //ObjToJme();
      URL modelFolder = BergenWindow.class.getClassLoader().getResource("..\res/models/group01-skansenFireStation/");

         SimpleResourceLocator srl = new SimpleResourceLocator(modelFile);
         SimpleResourceLocator sr2 = new SimpleResourceLocator(modelFolder);
      catch(Exception e)
      converter.setProperty("mtllib", modelFolder);
      converter.setProperty("texdir", modelFolder);
      //convert and load again..
        ByteArrayOutputStream BO = new ByteArrayOutputStream();
        try {
            // Use the format converter to convert .obj to .jme
            converter.convert(modelFile.openStream(), BO);
            Spatial ship = (Spatial) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

            ship.setModelBound(new BoundingSphere());
            // Put her on the scene graph
        } catch (IOException e) {   // Just in case anything happens
            System.out.println("Damn exceptions!" + e);

long version..(messy!):

package net.gulost.monkeybergen3d.gui;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import net.gulost.monkeybergen3d.model.ObjModelConverter;
import net.gulost.monkeybergen3d.model.ObjModelLoader;
import net.gulost.monkeybergen3d.skybox.BergenSkybox;
import net.gulost.monkeybergen3d.terrain.BergenTerrain;
import net.gulost.monkeybergen3d.terrain.ESRIBasedHeightMap;

import jmetest.TutorialGuide.HelloTerrain;
import jmetest.effects.water.TestQuadWater;

import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.bounding.BoundingSphere;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.SceneElement;
import com.jme.scene.Skybox;
import com.jme.scene.Spatial;
import com.jme.scene.TriMesh;
import com.jme.scene.shape.AxisRods;
import com.jme.scene.shape.Box;
import com.jme.scene.state.CullState;
import com.jme.scene.state.FogState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.MaterialState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.util.TextureManager;
import com.jme.util.export.binary.BinaryImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.ObjToJme;
import com.jmex.terrain.TerrainBlock;
import com.jmex.terrain.util.MidPointHeightMap;

 * BergenWindow
 * This class puts the terrain, skybox, buildings, etc. in the scene. For stuff to be
 * rendered you have to attach it to the rootNode.
 * Most of the action is done in DefaultWindow..
 * @author Thomas
public class BergenWindow extends DefaultWindow
    * instansvariabler
    * ps. husk at vi allerede har; camera, rootNode, etc.
   private BergenSkybox       skybox;
   private BergenTerrain      terrain;
    * Main entry of application
    * @param args maybe increase memory?
    public static void main(String[] args)
        DefaultWindow application = new BergenWindow();
        //application.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG, "image.png");

     * Initialize stuff here...f.eks.:
     * - camera
     * - light
     * - input handler/bindings (f.eks. styre kamera etter kurve)
   public void simpleInit()
      display.setTitle("Bergen 3D - gulost.net");
      display.getRenderer().enableStatistics(false); //don't gather stats..
      //TODO: create the skybox
      skybox = new BergenSkybox();
      //Debug stuff:
      //rootNode.attachChild(new Box("origo",new Vector3f(0,0,0),new Vector3f(1,1,1)));
      rootNode.attachChild(new AxisRods("debugAxis", true, 10, 1));

      //TODO: generate terrain, add to scenegraph. textures
      terrain = new BergenTerrain();
      //TODO: add buildings, position them correctly
      //TODO: find a good camera position
      //TODO: create curves that the camera should follow..

    * All child nodes of rootNode gets rendered.
    * This method is for additional rendering, e.g.
    * menus, stats, ui, etc...
   public void simpleRender()

    * Update application logic.. Very simple version, 1 update per frame..
    * TODO: set a fixed framerate?
    * Here I will update positions, states, etc.. f.eks. camera position..
   public void simpleUpdate()
      //TODO: update camera position
      //update skybox position
           skybox.updateGeometricState(0.0f, true);

   private void setupCamera()
      // TODO
      // - look at something nice
      // - lock movement keys
      // - lock mouse-look?
      // - setup splines
      // - make camera move along splines..
      //placing camera..
      camera.setLocation(new Vector3f(10,50,10));
      camera.lookAt(new Vector3f(64,0,64), new Vector3f(0,1,0));

   private void loadBuildings()
       * the real deal :) fors

What is the output from the resource locater tool when you run this?

hmm… can't see any output from resource locator tool… I suspect that I might be useing this the wrong way? Do you have any examples of how to use it correctly?

I've seen this in sketchup files where they had odd polygons that were covering up the more interesting model (my guess is they are supposed to be drawn for interior views maybe?)  Not sure if this is the same issue, but it kind of looks the same.

hey there,

i don't know if its still valid but:

         SimpleResourceLocator srl = new SimpleResourceLocator(modelFile);
         SimpleResourceLocator sr2 = new SimpleResourceLocator(modelFolder);

shouldn't the last line be to add the second SimpleResourceLocator?:


so long,

Haha, didn't even notice that.

that comes from copy & paste from forums and then debugging  XD