Im stuck, I created a 3ds model, i loaded it using ModelLoader utility, it loads up fine and converts it to jme, no problems. I even reopened it in the LoadModel utility as a .jme loads fine.
Now when i load it in my program it sits there for about 2 mins, gives me a warning saying it cant find the texture but it then displays the model in the program with the texture just fine. It just takes over two mins to load it. So i think it must be a problem with the JME so i reopen it in ModelLoader instantly, so i think it must have something to do with it not displaying the texture. From what i know though is that the 3ds/jme file has its texture marked in it and finds the location from it, if it was exported from like 3Ds Max with the texture.
Now to start off i have src and data which is on the same level and set using the Java Build Path and adding them on there. Using this MutiformatLocator inside a Method in initSystem()
try {
MultiFormatResourceLocator loc = new MultiFormatResourceLocator(ResourceLocatorTool.class.getResource(""), ".jpg", ".png", ".tga");
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, loc);
} catch (URISyntaxException e) {
e.printStackTrace();
}
try {
MultiFormatResourceLocator loc2 = new MultiFormatResourceLocator(ResourceLocatorTool.class.getResource(""), ".3ds");
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, loc2);
} catch (URISyntaxException e) {
e.printStackTrace();
}
The terrain gets textures fine using inside a buildTerrain():
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
pt.addTexture(new ImageIcon(ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "/images/terrain/dirt.png")), -128, 0, 128);
pt.addTexture(new ImageIcon(ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "/images/terrain/grass.png")), 0, 128, 255);
pt.addTexture(new ImageIcon(ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "/images/terrain/snow.png")), 128, 255, 384);
pt.createTexture(64);
/images/ect ect are within the data folder and load fine
same with the skybox
but it dies out on the buildPlayer model:
private void buildPlayer() {
//Load Model
System.out.println("1");
URL model = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, "/models/fighter1.jme");
System.out.println("2");
try {
BinaryImporter binaryImporter = new BinaryImporter(); // Used to convert the jme usable file to a Node
InputStream fileInput = null;
fileInput=model.openStream();
System.out.println("3");
Node plane = (Node)binaryImporter.load(fileInput); //importer returns a Loadable, cast to Node
System.out.println("4");
// scale model to maximum extent of 5.0
plane.updateGeometricState( 0, true );
BoundingVolume worldBound = plane.getWorldBound();
if ( worldBound == null ) {
plane.setModelBound( new BoundingBox() );
plane.updateModelBound();
plane.updateGeometricState( 0, true );
worldBound = plane.getWorldBound();
System.out.println("5");
}
if ( worldBound != null ) // check not still null (no geoms)
{
Vector3f center = worldBound.getCenter();
BoundingBox boundingBox = new BoundingBox( center, 0, 0, 0 );
boundingBox.mergeLocal( worldBound );
Vector3f extent = boundingBox.getExtent( null );
float maxExtent = Math.max( Math.max( extent.x, extent.y ), extent.z );
if ( maxExtent != 0 ) {
Node scaledModel = new Node( "scaled model" );
scaledModel.attachChild( plane );
scaledModel.setLocalScale( 5.0f / maxExtent );
plane = scaledModel;
System.out.println("6");
}
}
// shrink this baby down some
plane.setLocalRotation( new Quaternion().fromAngleAxis( - FastMath.PI/2, new Vector3f(1,0,0)) );
player = new Node("Player Node");
player.attachChild(plane);
scene.attachChild(player);
player.setLocalTranslation(new Vector3f(100,0, 100));
player.updateWorldBound();
System.out.println("7");
// Put her on the scene graph
} catch (IOException e) { // Just in case anything happens
System.out.println("Damn exceptions!" + e);
e.printStackTrace();
System.exit(0);
}
}
it gets the model with:
URL model = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, "/models/fighter1.jme");
converts it into a input stream
InputStream fileInput = null;
fileInput=model.openStream();
then sits out here at the binary importer for over two mins
Node plane = (Node)binaryImporter.load(fileInput);
says:
com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: /C:/Documents and Settings/...removedForSpace.../models/FIGHTER.TGA
my guess it has to do with the /C:/ becouse thats where the texture is located
so maybe its looking for it? then timing out?
after a few mins it continues on and loads the model fine with texture.
I pulled most of the loader from ModelLoader since it works fine there.
anyone with any ideas?