I have been using jME 1.0. I had some code that loaded my .obj files (using ObjToJme). It worked perfectly and loading each model relatively quickly.
I just recently updated my jME version to 2.0 and now my loading times have went waaaay up. Each model takes about 4 seconds to loading, where before I could load all 80 or so models in less than 6 seconds. Is there a new way to load obj files and convert them to .jme? Here is the code I am using:
if (materialLocation == null)
Logger.getLogger("FIRSTLogger").log(Level.SEVERE,
"Material not found");
if (textureLocation == null)
Logger.getLogger("FIRSTLogger").log(Level.SEVERE,
"Texture not found");
converter.setProperty("mtllib", materialLocation);
converter.setProperty("texdir", textureLocation);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
try {
converter.convert(modelURL.openStream(), BO);
Yes, I do see the warning messages. I've always seen those and have tried to get rid of them, but couldn't figure out how. They didn't seem to slow down loading times before, but maybe they are this time around.
Could you give me any hints on what to do with the ResourceLocator as you say?
EDIT: I've figured out how to do as you say:
try{
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
new SimpleResourceLocator(textureLocation));
}
catch(Exception e){
e.printStackTrace();
}
It got rid of the warnings, but didn't speed up loading times. The following is what I get from the console.
Jul 18, 2009 10:31:52 AM com.jme.scene.Node <init>
INFO: Node created.
Jul 18, 2009 10:31:52 AM com.jme.util.geom.GeometryTool minimizeVerts
INFO: mesh: temp0 (com.jme.scene.TriMesh) old: 160 new: 104
Jul 18, 2009 10:31:52 AM com.jme.scene.Node attachChild
INFO: Child (temp0) attached to this node (obj file)
Looking through the source for jME, I have found that the time consumer is:
TextureManager.loadTexture(this, key); in Texture.class
So, it seems Core-Dump is onto something.
It seems that the texture I specified is a .jpg. The TextureManager.loadImage method tries to get a loader for the texture, but it always returns null (ImageLoader loader = loaders.get(fileExt.toLowerCase())
JPG support hasn't been lost, AFAIK, it has always just used existing code in the JRE to convert them as JPEG is a bitch of a format to convert - I think sun use an external C library for the job (or at least they used to).
It could possibly be a JRE issue tho - Have you changed JRE recently (especially up to 6) as I think these libraries are changing as part of the "open sourceing" of java, and proprietary libraries are being replaced (such as the com.sun.* packages) - it could be related?
Might be worth trying to run against an earlier JRE.
Alternatively, convert your imagery to another format. JPEG isnt widely used as a game graphics format - generally a non lossy format is preferred.
Thanks JOC. I have converted my textures to tga and it works fine now! I believe the problem was something with the jre I was using. I didn't test it, but I had actually downgraded to java 5 from 6 (to make it mac compatible). So, in all regards you were right I believe.