Loading a Model with Texture in StandardGame [Solved]

I'm totally new to jME and currently evaluate it for game development. Getting started was really a breeze and most of the Engine API just feels natural. However, since I'm trying to get some more extensive development done I switched from SimpleGame to StandardGame right after working through the tutorials. It took me quite a while to understand the concept behind GameStates - thanks to darkfrogs excellent documentation it was quite comprehensible.

When loading a model in StandardGame the textures get loaded, but not assigned properly. I checked by adding some debug output to the texture loader code and it really loads the right textures. They just don't get assigned to the model when rendering it. The texture being used is not the "no texture" texture, but a font texture which seams to be builtin to jME.

This is the Code I currently use for loading a Model with a StandardGame:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import com.jme.scene.Node;
import com.jmex.editors.swing.settings.GameSettingsPanel;
import com.jmex.game.StandardGame;
import com.jmex.game.state.DebugGameState;
import com.jmex.game.state.GameStateManager;
import com.jmex.model.collada.ColladaImporter;
import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;

public class Main {

   public static Node loadColladaModel(String pathName, String modelName) {
      InputStream source;
      try {
         source = new FileInputStream("data/" + pathName + "/" + modelName + ".DAE");
      } catch (FileNotFoundException e) {
         throw new RuntimeException(e);
      URL textureDirectory;
      try {
         textureDirectory = FileURL.makeURL("data/" + pathName);
         // FIXME jME's way of creating the texture URLs requires a trailing slash
         //       This is just a workaround for the jME behaviour.
         textureDirectory = new URL(textureDirectory.toString() + "/");
      } catch (MalformedURLException e) {
         throw new RuntimeException(e);
      ColladaImporter.load(source, textureDirectory, modelName);
      return ColladaImporter.getModel();

   public static void main(String[] args) throws Exception {
      // Instantiate StandardGame
      StandardGame game = new StandardGame("hexogen");
      // Show settings screen
      // Start StandardGame, it will block until it has initialized successfully, then return
      // Create a DebugGameState - has all the built-in features that SimpleGame provides
      // NOTE: for a distributable game implementation you'll want to use something like
      // BasicGameState instead and provide control features yourself.
      final DebugGameState state = new DebugGameState();

      // Load model and add it to the current state
      state.getRootNode().attachChild(loadColladaModel("nes", "nes"));
      // Add it to the manager
      // Activate the game state

I guess I just forgot something crucial or just did it entirely wrong. Please enlighten me. :)

I'm using the latest HEAD from CVS. StandardGame didn't work for me at all when using the 0.11 release.

Guessing wildly, a call to state.getRootNode().updateRenderState() right after attaching the model could solve your problem. I could be wrong though :wink:

Yes! That did the trick. :slight_smile:

Vielen herzlichen Dank!

(Thank you very much!)

Bitte helfe gern  :smiley:

(who let the crazy germans in?  }:-@)