コード例 #1
0
 @Override
 public Spatial loadAsset() {
   ProgressHandle handle = ProgressHandleFactory.createHandle("Converting OgreBinary");
   handle.start();
   // mesh
   OgreXMLConvertOptions options = new OgreXMLConvertOptions(getPrimaryFile().getPath());
   options.setBinaryFile(true);
   OgreXMLConvert conv = new OgreXMLConvert();
   conv.doConvert(options, handle);
   // try skeleton
   if (getPrimaryFile().existsExt("skeleton")) {
     OgreXMLConvertOptions options2 =
         new OgreXMLConvertOptions(
             getPrimaryFile()
                 .getParent()
                 .getFileObject(getPrimaryFile().getName(), "skeleton")
                 .getPath());
     options2.setBinaryFile(true);
     OgreXMLConvert conv2 = new OgreXMLConvert();
     conv2.doConvert(options2, handle);
   }
   handle.progress("Convert Model");
   ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
   if (mgr == null) {
     DialogDisplayer.getDefault()
         .notifyLater(
             new NotifyDescriptor.Message(
                 "File is not part of a project!\nCannot load without ProjectAssetManager."));
     return null;
   }
   String assetKey = mgr.getRelativeAssetPath(options.getDestFile());
   FileLock lock = null;
   try {
     lock = getPrimaryFile().lock();
     listListener.start();
     Spatial spatial = mgr.loadModel(assetKey);
     // replace transient xml files in list of assets for this model
     replaceXmlFiles();
     listListener.stop();
     savable = spatial;
     lock.releaseLock();
     File deleteFile = new File(options.getDestFile());
     deleteFile.delete();
     handle.finish();
     return spatial;
   } catch (IOException ex) {
     Exceptions.printStackTrace(ex);
     if (lock != null) {
       lock.releaseLock();
     }
   }
   File deleteFile = new File(options.getDestFile());
   deleteFile.delete();
   handle.finish();
   return null;
 }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public void showMaterial(ProjectAssetManager assetManager, String materialFileName) {
   if (!init) {
     initWidget();
   }
   try {
     MaterialKey key = new MaterialKey(assetManager.getRelativeAssetPath(materialFileName));
     assetManager.deleteFromCache(key);
     Material mat = (Material) assetManager.loadAsset(key);
     if (mat != null) {
       currentMaterial = mat;
       doShowMaterial(mat);
     }
   } catch (Exception e) {
   }
 }