I am having problems loading a .3ds model. I am using the ncsa model loader used in Killer Game Programming in Java. I think this problem is caused by the program being inside of a jar because the code works when the class files are on their own. The code that actually loads the model is here. I encountered a similar problem when loading images from within a .jar but remedied this with a solution not applicable to 3D models. Any advice on how to get this loader working would be appreciated.:
private void loadModel(String fn)
{
FileWriter ofw = null;
System.out.println( "Loading: " + fn );
try {
ModelLoader loader = new ModelLoader(); // the NCSA portfolio loader
// System.out.println("Loader flags: " + loader.getFlags());
loadedScene = loader.load(fn); // the loaded scene
// Rotate and scale the model
if(loadedScene != null ) {
loadedBG = loadedScene.getSceneGroup(); // the model's BG
Transform3D t3d = new Transform3D();
t3d.rotX( -Math.PI/2.0 ); // models are often on their face; fix that
Vector3d scaleVec = calcScaleFactor(loadedBG, fn); // scale the model
t3d.setScale( scaleVec );
TransformGroup tg = new TransformGroup(t3d);
tg.addChild(loadedBG);
sceneBG.addChild(tg); // add (tg->loadedBG) to scene
}
else
System.out.println("Load error with: " + fn);
}
catch( IOException ioe )
{ System.err.println("Could not find object file: " + fn); }
} // end of loadModel()