You probably guessed I'm just modifying the flagrush game, but the error is
a null pointer exception:
backwheel = ((Node)model).getChild("backwheel");
Well the knight model doesnt have a backwheel, so thats probably where its going wrong
Ill try just loading the knight in, and adding it to the scene if I can.
//evaluate the format
if (modelFormat.equals("3ds")){
formatConverter = new MaxToJme();
} else if (modelFormat.equals("md2")){
formatConverter = new Md2ToJme();
} else if (modelFormat.equals("md3")){
formatConverter = new Md3ToJme();
} else if (modelFormat.equals("ms3d")){
formatConverter = new MilkToJme();
} else if (modelFormat.equals("ase")){
formatConverter = new AseToJme();
} else if (modelFormat.equals("obj")){
formatConverter = new ObjToJme();
}
formatConverter.setProperty("mtllib", modelURL);
I am not sure you can load a model using the .max file type. .max is the native format for 3DSMax files, so you must convert it in a compatible format for jME like .3ds, .obj or anything else. There are some tutorials about that.
take a look at the classes TextureKey and SimpleResourceLocator to get your textures working.
your have to apply a LightState to the model, then it wont be white anymore. (maybe black then? ;)), however your model is most propably converted correctly anyhow, even withour a light in the converter.
Modellers do not (usually) actually add the texture data in to the model file. They just save the path to the texture and what it was applied to. So jME (and anything else) still needs to be able to find the texture file, aswell as the model file.
If your textures are in a place that jME can find them, then they will "just work" - as soon as you load the model they will be visible (certainly with MS3D).
Colors, if you used materials then they should work right out of the box also.
There is one thing I noticed missing from Trussel's code that also drove me mad last week when I was trying to load object files into my level editor. Most obj exporters list their textures without path names, at least blender does. You must specify the "texdir" property in converter.setProperty so that the model importer can create a texture key specifying where to find the texture.
If you have an OBJ file like "ninja.obj" put the materials in the same directory and name it the same thing (like "ninja.mtl") and the code I posted will automatically see it and load it.
But I did this before and it wasn't enough for me. I had to specify the "texdir" in order for the textures to load. Taking a look at the ObjToJme code it makes sense since it constructs a texture key directly and doesn't load the texture using the TextureManager.loadTexture method which uses the ResourceLocatorTool when a string parameter is passed as the file. If the "texdir" property is not set, then it will only look in the application's main directory. At least this is what I found.
Hmm… I use material libraries and that code worked fine for me. I'm not sure about the texkey, that may be something else that I'm not using at this point (I'm only using model loading for testing right now).