本文整理匯總了Java中com.jme3.asset.AssetManager.loadMaterial方法的典型用法代碼示例。如果您正苦於以下問題:Java AssetManager.loadMaterial方法的具體用法?Java AssetManager.loadMaterial怎麽用?Java AssetManager.loadMaterial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.asset.AssetManager
的用法示例。
在下文中一共展示了AssetManager.loadMaterial方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMaterialFileIfNeed
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Create a material of the geometry as a file if need.
*
* @param geometry the sky geometry.
*/
@BackgroundThread
private @NotNull Material createMaterialFileIfNeed(@NotNull final Geometry geometry) {
final TextField materialNameField = getMaterialNameField();
final ChooseFolderControl materialFolderControl = getMaterialFolderControl();
final Material material = geometry.getMaterial();
final String content = MaterialSerializer.serializeToString(material);
final Path folder = materialFolderControl.getFolder();
final Path materialFile = folder.resolve(materialNameField.getText() + "." + FileExtensions.JME_MATERIAL);
try {
Files.write(materialFile, content.getBytes("UTF-8"), WRITE, TRUNCATE_EXISTING, CREATE);
} catch (final IOException e) {
throw new RuntimeException(e);
}
final Path assetFile = EditorUtil.getAssetFile(materialFile);
final String assetPath = EditorUtil.toAssetPath(assetFile);
final AssetManager assetManager = EDITOR.getAssetManager();
return assetManager.loadMaterial(assetPath);
}
示例2: processSave
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* The process of saving the file.
*
* @param file the file to save
*/
@FXThread
private void processSave(@NotNull final Path file) {
final TreeNode<?> node = getNode();
final Material material = (Material) node.getElement();
final String materialContent = MaterialSerializer.serializeToString(material);
try (final PrintWriter out = new PrintWriter(Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE))) {
out.print(materialContent);
} catch (final IOException e) {
EditorUtil.handleException(LOGGER, this, e);
return;
}
final Path assetFile = notNull(getAssetFile(file));
final AssetManager assetManager = EDITOR.getAssetManager();
final Material savedMaterial = assetManager.loadMaterial(notNull(toAssetPath(assetFile)));
final PropertyOperation<ChangeConsumer, Material, AssetKey> operation =
new PropertyOperation<>(material, "AssetKey", savedMaterial.getKey(), null);
operation.setApplyHandler(Material::setKey);
final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer());
changeConsumer.execute(operation);
}
示例3: updateMaterial
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Updating a material from the file.
*/
@FXThread
private void updateMaterial(@NotNull final Path file) {
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
final String assetPath = toAssetPath(assetFile);
final M currentModel = getCurrentModel();
final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class);
NodeUtils.addGeometryWithMaterial(currentModel, geometries, assetPath);
if (geometries.isEmpty()) return;
final AssetManager assetManager = EDITOR.getAssetManager();
final Material material = assetManager.loadMaterial(assetPath);
geometries.forEach(geometry -> geometry.setMaterial(material));
final TonegodTranslucentBucketFilter translucentBucketFilter = EDITOR.getTranslucentBucketFilter();
translucentBucketFilter.refresh();
}
示例4: showMaterial
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Show a j3m material.
*
* @param path the path to material.
*/
@JMEThread
private void showMaterial(@NotNull final String path) {
prepareProcessor();
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final Material material = assetManager.loadMaterial(path);
testBox.setMaterial(material);
tryToLoad(testBox);
final Node rootNode = editor.getPreviewNode();
rootNode.detachChild(modelNode);
}
示例5: loadMaterial
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* 載入材質
* @param j3mFile
* @return
*/
public static Material loadMaterial(String j3mFile) {
AssetManager am = LuoYing.getAssetManager();
return am.loadMaterial(j3mFile);
}