Created
March 16, 2012 13:11
-
-
Save nikolaykasyanov/2050016 to your computer and use it in GitHub Desktop.
Collada loading with Ardor3d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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