Skip to content

Instantly share code, notes, and snippets.

@nikolaykasyanov
Created March 16, 2012 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolaykasyanov/2050016 to your computer and use it in GitHub Desktop.
Save nikolaykasyanov/2050016 to your computer and use it in GitHub Desktop.
Collada loading with Ardor3d
public static Node loadColladaModel(final String modelFileStr) throws Exception {
final int a = modelFileStr.lastIndexOf("/");
String modelDirStr = modelFileStr.substring(0, a);
final String modelNameStr = modelFileStr.substring(modelFileStr.lastIndexOf("/") + 1);
final File modelDir = new File(modelDirStr);
modelDirStr = modelDir.getAbsolutePath();
final ColladaImporter importer = new ColladaImporter();
final SimpleResourceLocator modelLocator = new SimpleResourceLocator(new URL("file:" + modelDirStr));
final SimpleResourceLocator textureLocator = new SimpleResourceLocator(new URL("file:" + modelDirStr));
importer.setModelLocator(modelLocator);
importer.setTextureLocator(textureLocator);
importer.setLoadAnimations(false);
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, modelLocator);
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, textureLocator);
final ColladaStorage storage = importer.load(modelNameStr);
Node modelRoot = storage.getScene();
return modelRoot;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment