コード例 #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
  public void applySettings(WizardDescriptor wiz) {
    // reset
    wiz.putProperty("path", null);
    wiz.putProperty("manager", null);
    wiz.putProperty("dataobject", null);
    wiz.putProperty("assetdata", null);
    wiz.putProperty("mainkey", null);
    wiz.putProperty("destpath", null);

    wiz.putProperty("assetlist", null);
    wiz.putProperty("failedlist", null);
    wiz.putProperty("model", null);

    UberAssetLocator.resetLocatedList();
    UberAssetLocator.setFindMode(true);
    manager.clearCache();
    wiz.putProperty("path", currentPath);
    wiz.putProperty("manager", manager);
    wiz.putProperty("dataobject", dataObject);
    wiz.putProperty("assetdata", data);
    wiz.putProperty("mainkey", mainKey);
    if (mainKey != null) {
      wiz.putProperty(
          "destpath",
          "Models/"
              + mainKey.getName().replaceAll(mainKey.getExtension(), "").replaceAll("\\.", "")
              + "/");
    }
  }
コード例 #3
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) {
   }
 }
コード例 #4
0
  public void requestPreview(
      String textureName,
      String displayName,
      int width,
      int height,
      JComponent picLabel,
      JLabel infoLabel) {
    TextureKey key = new TextureKey(textureName);
    picPreview = picLabel;
    assetManager.deleteFromCache(key);
    Texture t = assetManager.loadTexture(key);
    Spatial geom = quad;
    if (key.getTextureTypeHint() == Texture.Type.TwoDimensional) {
      material.setTexture("ColorMap", t);
      geom.setMaterial(material);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + "    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight());
      }
    } else if (key.getTextureTypeHint() == Texture.Type.ThreeDimensional) {
      geom = quad3D;
      assetManager.deleteFromCache(key);
      key.setTextureTypeHint(Texture.Type.ThreeDimensional);
      t = assetManager.loadTexture(key);
      material3D.setTexture("Texture", t);
      geom.setMaterial(material3D);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + " (Texture3D)    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight()
                + "    d : "
                + t.getImage().getDepth());
      }
    } else if (key.getTextureTypeHint() == Texture.Type.CubeMap) {
      assetManager.deleteFromCache(key);
      geom = SkyFactory.createSky(assetManager, textureName, SkyFactory.EnvMapType.CubeMap);
      if (infoLabel != null) {
        infoLabel.setText(
            " "
                + displayName
                + " (CubeMap)    w : "
                + t.getImage().getWidth()
                + "    h : "
                + t.getImage().getHeight());
      }
    }

    PreviewRequest request = new PreviewRequest(this, geom, width, height);
    request.getCameraRequest().setLocation(new Vector3f(0, 0, 5.3f));
    request.getCameraRequest().setLookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y.mult(-1));
    SceneApplication.getApplication().createPreview(request);
  }