public Spatial load(AssetInfo assetInfo) throws IOException {
try {
this.setup(assetInfo);
List<FileBlockHeader> sceneBlocks = new ArrayList<FileBlockHeader>();
BlenderKey blenderKey = blenderContext.getBlenderKey();
LoadingResults loadingResults = blenderKey.prepareLoadingResults();
AnimationHelper animationHelper = blenderContext.getHelper(AnimationHelper.class);
animationHelper.loadAnimations();
for (FileBlockHeader block : blocks) {
switch (block.getCode()) {
case FileBlockHeader.BLOCK_OB00:// Object
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
Object object = objectHelper.toObject(block.getStructure(blenderContext), blenderContext);
if (object instanceof LightNode) {
loadingResults.addLight((LightNode) object);
} else if (object instanceof CameraNode) {
loadingResults.addCamera((CameraNode) object);
} else if (object instanceof Node) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "{0}: {1}--> {2}", new Object[] { ((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName() });
}
if (this.isRootObject(loadingResults, (Node) object)) {
loadingResults.addObject((Node) object);
}
}
break;
// case FileBlockHeader.BLOCK_MA00:// Material
// MaterialHelper materialHelper = blenderContext.getHelper(MaterialHelper.class);
// MaterialContext materialContext = materialHelper.toMaterialContext(block.getStructure(blenderContext), blenderContext);
// if (blenderKey.isLoadUnlinkedAssets() && blenderKey.shouldLoad(FeaturesToLoad.MATERIALS)) {
// loadingResults.addMaterial(this.toMaterial(block.getStructure(blenderContext)));
// }
// break;
case FileBlockHeader.BLOCK_SC00:// Scene
if (blenderKey.shouldLoad(FeaturesToLoad.SCENES)) {
sceneBlocks.add(block);
}
break;
case FileBlockHeader.BLOCK_WO00:// World
if (blenderKey.shouldLoad(FeaturesToLoad.WORLD)) {
Structure worldStructure = block.getStructure(blenderContext);
String worldName = worldStructure.getName();
if (blenderKey.getUsedWorld() == null || blenderKey.getUsedWorld().equals(worldName)) {
LandscapeHelper landscapeHelper = blenderContext.getHelper(LandscapeHelper.class);
Light ambientLight = landscapeHelper.toAmbientLight(worldStructure);
if(ambientLight != null) {
loadingResults.addLight(new LightNode(null, ambientLight));
}