當前位置: 首頁>>代碼示例>>Java>>正文


Java AssetManager.loadAsset方法代碼示例

本文整理匯總了Java中com.jme3.asset.AssetManager.loadAsset方法的典型用法代碼示例。如果您正苦於以下問題:Java AssetManager.loadAsset方法的具體用法?Java AssetManager.loadAsset怎麽用?Java AssetManager.loadAsset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.asset.AssetManager的用法示例。


在下文中一共展示了AssetManager.loadAsset方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processOpen

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void processOpen(@NotNull final ResourceElement element) {
    super.processOpen(element);

    final ComboBox<String> textureParamNameBox = getTextureParamNameComboBox();
    final SingleSelectionModel<String> selectionModel = textureParamNameBox.getSelectionModel();
    final String textureParamName = selectionModel.getSelectedItem();

    final CheckBox transformBox = getApplyLightingTransformCheckBox();

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Path file = element.getFile();
    final Path assetFile = getAssetFile(file);

    if (assetFile == null) {
        throw new RuntimeException("AssetFile can't be null.");
    }

    final Material material = assetManager.loadAsset(new MaterialKey(toAssetPath(assetFile)));

    final Consumer<ParticlesMaterial> consumer = getConsumer();
    consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:ParticlesAssetEditorDialog.java

示例2: handleExternalChanges

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void handleExternalChanges() {
    super.handleExternalChanges();

    final Path assetFile = notNull(getAssetFile(getEditFile()));
    final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Material material = assetManager.loadAsset(materialKey);

    reload(material);

    final EditorOperationControl operationControl = getOperationControl();
    operationControl.clear();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:MaterialFileEditor.java

示例3: doOpenFile

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void doOpenFile(@NotNull final Path file) throws IOException {
    super.doOpenFile(file);

    final Path assetFile = notNull(getAssetFile(file));
    final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Material material = assetManager.loadAsset(materialKey);

    final MaterialEditor3DState editor3DState = getEditor3DState();
    editor3DState.changeMode(ModelType.BOX);

    reload(material);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:MaterialFileEditor.java

示例4: validate

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {

    final ComboBox<String> comboBox = getTextureParamNameComboBox();
    final ObservableList<String> items = comboBox.getItems();
    items.clear();

    final Path file = element == null ? null : element.getFile();

    if (file != null && !Files.isDirectory(file)) {

        final AssetManager assetManager = EDITOR.getAssetManager();
        final Path assetFile = getAssetFile(file);

        if (assetFile == null) {
            throw new RuntimeException("AssetFile can't be null.");
        }

        final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));
        final Material material = assetManager.loadAsset(materialKey);
        final MaterialDef materialDef = material.getMaterialDef();

        final Collection<MatParam> materialParams = materialDef.getMaterialParams();
        materialParams.stream()
                .filter(param -> param.getVarType() == VarType.Texture2D)
                .filter(matParam -> material.getTextureParam(matParam.getName()) != null)
                .forEach(filtred -> items.add(filtred.getName()));

        final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();

        if (!items.isEmpty()) {
            selectionModel.select(0);
        } else {
            selectionModel.select(null);
        }
    }

    super.validate(warningLabel, element);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:41,代碼來源:ParticlesAssetEditorDialog.java

示例5: doOpenFile

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void doOpenFile(@NotNull final Path file) throws IOException {
    super.doOpenFile(file);

    final Path assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null.");
    final ModelKey modelKey = new ModelKey(toAssetPath(assetFile));

    final AssetManager assetManager = EDITOR.getAssetManager();

    Spatial loadedScene = assetManager.loadAsset(modelKey);

    final SceneNode model = (SceneNode) loadedScene;
    model.depthFirstTraversal(this::updateVisibility);

    MaterialUtils.cleanUpMaterialParams(model);

    final SceneEditor3DState editor3DState = getEditor3DState();
    editor3DState.openModel(model);

    handleAddedObject(model);

    setCurrentModel(model);
    setIgnoreListeners(true);
    try {
        refreshTree();
    } finally {
        setIgnoreListeners(false);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:31,代碼來源:SceneFileEditor.java

示例6: doOpenFile

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected void doOpenFile(@NotNull final Path file) throws IOException {
    super.doOpenFile(file);

    final Path assetFile = notNull(getAssetFile(file), "Asset file for " + file + " can't be null.");
    final ModelKey modelKey = new ModelKey(toAssetPath(assetFile));

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Spatial model = assetManager.loadAsset(modelKey);

    MaterialUtils.cleanUpMaterialParams(model);

    final ModelEditor3DState editor3DState = getEditor3DState();
    editor3DState.openModel(model);

    handleAddedObject(model);

    setCurrentModel(model);
    setIgnoreListeners(true);
    try {

        final ComboBox<String> fastSkyComboBox = getFastSkyComboBox();
        fastSkyComboBox.getSelectionModel().select(FAST_SKY_LIST.first());

        refreshTree();

    } finally {
        setIgnoreListeners(false);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:32,代碼來源:ModelFileEditor.java

示例7: attachLinkedChildren

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Loads the linked children AssetKeys from the AssetManager and attaches them to the Node<br>
 * If they are already attached, they will be reloaded.
 * @param manager
 */
public void attachLinkedChildren(AssetManager manager) {
    detachLinkedChildren();
    for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext();) {
        ModelKey assetKey = it.next();
        Spatial curChild = assetChildren.get(assetKey);
        if (curChild != null) {
            curChild.removeFromParent();
        }
        Spatial child = manager.loadAsset(assetKey);
        attachChild(child);
        assetChildren.put(assetKey, child);
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:AssetLinkNode.java

示例8: Material

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public Material(AssetManager contentMan, String defName) {
    this((MaterialDef) contentMan.loadAsset(new AssetKey(defName)));
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:4,代碼來源:Material.java

示例9: convertImpl

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Convert a file using settings from the dialog.
 */
@BackgroundThread
private void convertImpl(@NotNull final Path source, @NotNull final VarTable vars) throws IOException {

    final String filename = vars.getString(PROP_RESULT_NAME);
    final Path destinationFolder = notNull(getRealFile(vars.get(PROP_DESTINATION, Path.class)));
    final Path destination = destinationFolder.resolve(filename + "." + FileExtensions.JME_OBJECT);
    final boolean isOverwrite = Files.exists(destination);

    final Path assetFile = notNull(getAssetFile(source), "Not found asset file for " + source);
    final ModelKey modelKey = new ModelKey(toAssetPath(assetFile));

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Spatial model = assetManager.loadAsset(modelKey);

    if (EDITOR_CONFIG.isAutoTangentGenerating()) {
        TangentGenerator.useMikktspaceGenerator(model);
    }

    if (vars.getBoolean(PROP_EXPORT_MATERIALS)) {

        final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class);
        final ObjectDictionary<String, Geometry> mapping = DictionaryFactory.newObjectDictionary();

        final Path materialsFolder = vars.get(PROP_MATERIALS_FOLDER);
        final boolean canOverwrite = vars.getBoolean(PROP_OVERWRITE_MATERIALS);

        NodeUtils.visitGeometry(model, geometry -> checkAndAdd(geometries, geometry));
        geometries.forEach(geometry -> generateNames(mapping, geometry));
        mapping.forEach((materialName, geometry) -> storeMaterials(materialsFolder, canOverwrite, materialName, geometry));
    }

    final BinaryExporter exporter = BinaryExporter.getInstance();

    try (final OutputStream out = Files.newOutputStream(destination, WRITE, TRUNCATE_EXISTING, CREATE)) {
        exporter.save(model, out);
    }

    if (isOverwrite) {
        notifyFileChanged(destination);
    } else {
        notifyFileCreated(destination);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:47,代碼來源:AbstractModelFileConverter.java

示例10: load

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static Sprite load(final String name, final AssetManager assetManager) {
    SpriteLoader.register(assetManager);
    return assetManager.loadAsset(new SpriteKey(name));
}
 
開發者ID:NintendoStuff,項目名稱:worldcup,代碼行數:5,代碼來源:Sprite.java

示例11: load

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static AnimatedSprite load(final String name, final AssetManager assetManager) {
    AnimatedSpriteLoader.register(assetManager);
    return assetManager.loadAsset(new AnimatedSpriteKey(name));
}
 
開發者ID:NintendoStuff,項目名稱:worldcup,代碼行數:5,代碼來源:AnimatedSprite.java

示例12: attachLinkedChild

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public void attachLinkedChild(AssetManager manager, ModelKey key) {
    addLinkedChild(key);
    Spatial child = manager.loadAsset(key);
    assetChildren.put(key, child);
    attachChild(child);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:7,代碼來源:AssetLinkNode.java

示例13: AudioNode

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Creates a new <code>AudioNode</code> with the given audio file.
 * 
 * @param audioRenderer The audio renderer to use for playing. Cannot be null.
 * @param assetManager The asset manager to use to load the audio file
 * @param name The filename of the audio file
 * @param stream If true, the audio will be streamed gradually from disk, 
 *               otherwise, it will be buffered.
 * @param streamCache If stream is also true, then this specifies if
 * the stream cache is used. When enabled, the audio stream will
 * be read entirely but not decoded, allowing features such as 
 * seeking, looping and determining duration.
 */
public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name, boolean stream, boolean streamCache) {
    this(audioRenderer);
    this.key = new AudioKey(name, stream, streamCache);
    this.data = (AudioData) assetManager.loadAsset(key);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:AudioNode.java


注:本文中的com.jme3.asset.AssetManager.loadAsset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。