本文整理汇总了Java中com.jme3.scene.Spatial.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Spatial.setName方法的具体用法?Java Spatial.setName怎么用?Java Spatial.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.Spatial
的用法示例。
在下文中一共展示了Spatial.setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importModel
import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
* Import the external model in a background thread.
*/
@BackgroundThread
private void importModel() {
final Path modelFile = notNull(getFileToCreate());
final Path parent = modelFile.getParent();
final VarTable vars = getVars();
final Path importedFile = vars.get(PROP_FILE);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial model;
FolderAssetLocator.setIgnore(true);
try {
model = assetManager.loadModel(importedFile.toString());
} finally {
FolderAssetLocator.setIgnore(false);
}
if (EDITOR_CONFIG.isAutoTangentGenerating()) {
TangentGenerator.useMikktspaceGenerator(model);
}
final Path texturesFolder = vars.get(PROP_TEXTURES_FOLDER, parent);
final boolean overwriteTextures = vars.getBoolean(PROP_OVERWRITE_TEXTURES);
final boolean needExportMaterials = vars.getBoolean(PROP_NEED_MATERIALS_EXPORT);
final Path materialsFolder = vars.get(PROP_MATERIALS_FOLDER, parent);
final boolean overwriteMaterials = vars.getBoolean(PROP_OVERWRITE_MATERIALS, false);
final Array<Texture> textures = ArrayFactory.newArray(Texture.class);
final Array<Geometry> geometries = ArrayFactory.newArray(Geometry.class);
NodeUtils.visitGeometry(model, geometry -> {
final Material material = geometry.getMaterial();
if (needExportMaterials) geometries.add(geometry);
material.getParams().stream()
.filter(MatParamTexture.class::isInstance)
.map(MatParam::getValue)
.filter(Texture.class::isInstance)
.map(Texture.class::cast)
.filter(texture -> texture.getKey() != null)
.forEach(textures::add);
});
copyTextures(texturesFolder, overwriteTextures, textures);
if (needExportMaterials) {
exportMaterials(materialsFolder, overwriteMaterials, geometries);
}
final Path assetFile = notNull(getAssetFile(modelFile));
final String assetPath = toAssetPath(assetFile);
model.setName(assetPath);
final BinaryExporter exporter = BinaryExporter.getInstance();
try (final OutputStream out = Files.newOutputStream(modelFile, WRITE, TRUNCATE_EXISTING, CREATE)) {
exporter.save(model, out);
} catch (final IOException e) {
throw new RuntimeException(e);
}
notifyFileCreated(modelFile, true);
}