本文整理匯總了Java中com.jme3.asset.AssetManager.loadModel方法的典型用法代碼示例。如果您正苦於以下問題:Java AssetManager.loadModel方法的具體用法?Java AssetManager.loadModel怎麽用?Java AssetManager.loadModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.asset.AssetManager
的用法示例。
在下文中一共展示了AssetManager.loadModel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showObject
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Show a j3o object.
*
* @param path the path to object.
* @param external true if the object is external object.
*/
@JMEThread
private void showObject(@NotNull final String path, final boolean external) {
prepareProcessor();
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final Spatial model;
FolderAssetLocator.setIgnore(external);
try {
model = assetManager.loadModel(path);
if (external && EDITOR_CONFIG.isAutoTangentGenerating()) {
TangentGenerator.useMikktspaceGenerator(model);
}
} finally {
FolderAssetLocator.setIgnore(false);
}
tryToLoad(model);
final Node rootNode = editor.getPreviewNode();
rootNode.detachChild(modelNode);
}
示例2: processOpen
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* The process of opening file.
*
* @param file the file
*/
protected void processOpen(@NotNull final Path file) {
final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
final ModelChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
final String assetPath = toAssetPath(assetFile);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial loadedModel = assetManager.loadModel(assetPath);
final Geometry geometry = NodeUtils.findGeometry(loadedModel);
if (geometry == null) {
LOGGER.warning(this, "not found a geometry in the model " + assetPath);
return;
}
final TreeNode<?> treeNode = getNode();
final ParticleEmitterNode element = (ParticleEmitterNode) treeNode.getElement();
changeConsumer.execute(new ChangeEmitterMeshOperation(geometry.getMesh(), element));
}
示例3: processOpen
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* The process of opening file.
*
* @param file the file
*/
@FXThread
protected void processOpen(@NotNull final Path file) {
final NodeTree<?> nodeTree = getNodeTree();
final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
final SceneLayer defaultLayer = getDefaultLayer(consumer);
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
final String assetPath = toAssetPath(assetFile);
final ModelKey modelKey = new ModelKey(assetPath);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial loadedModel = assetManager.loadModel(modelKey);
loadedModel.setUserData(LOADED_MODEL_KEY, true);
if (defaultLayer != null) {
SceneLayer.setLayer(defaultLayer, loadedModel);
}
final TreeNode<?> treeNode = getNode();
final Node parent = (Node) treeNode.getElement();
consumer.execute(new AddChildOperation(loadedModel, parent));
}
示例4: dropExternalObject
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* Add the external object to this node.
*
* @param node this node.
* @param cons the change consumer.
* @param path the path to the external object.
*/
protected void dropExternalObject(@NotNull final T node, @NotNull final ChangeConsumer cons,
@NotNull final Path path) {
final SceneLayer defaultLayer = getDefaultLayer(cons);
final Path assetFile = notNull(getAssetFile(path), "Not found asset file for " + path);
final String assetPath = toAssetPath(assetFile);
final ModelKey modelKey = new ModelKey(assetPath);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial loadedModel = assetManager.loadModel(assetPath);
final AssetLinkNode assetLinkNode = new AssetLinkNode(modelKey);
assetLinkNode.attachLinkedChild(loadedModel, modelKey);
if (defaultLayer != null) {
SceneLayer.setLayer(defaultLayer, loadedModel);
}
cons.execute(new AddChildOperation(assetLinkNode, node));
}
示例5: preDelete
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
public void preDelete(@NotNull final Path file) {
super.preDelete(file);
final AssetManager assetManager = EDITOR.getAssetManager();
final Path assetFile = notNull(getAssetFile(file));
final String assetPath = toAssetPath(assetFile);
final Spatial model = assetManager.loadModel(assetPath);
NodeUtils.visitGeometry(model, geometry -> {
final Material material = geometry.getMaterial();
final String assetName = material.getAssetName();
if (!StringUtils.isEmpty(assetName)) assetKeys.add(assetName);
});
}
示例6: fix
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* 示例:
* <pre>
* <code>
* fix("Models/trees/dry/dry389.j3o", "dry389-geom-1");
* </code>
* </pre>
* @param file
* @param childGeometryName
*/
public final static void fix(String file, String... childGeometryName) {
AssetManager am = LuoYing.getAssetManager();
// 1.重設material
Spatial spatial = am.loadModel(file);
if (spatial instanceof Geometry) {
resetMaterial((Geometry) spatial);
} else {
Node model = (Node) spatial;
for (String geoName : childGeometryName) {
Geometry geo = (Geometry) model.getChild(geoName);
if (geo == null) {
continue;
}
resetMaterial(geo);
}
}
// 2.處理為Unshaded
// GeometryUtils.makeUnshaded(spatial);
// 3.保存到係統
ModelFileUtils.saveTo(spatial, file);
Logger.getLogger(TreeFixUtils.class.getName()).log(Level.INFO, "Convert ok!");
}
示例7: main
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static void main(String[] args) {
AssetManager am = LuoYing.getAssetManager();
// Spatial spatial = am.loadModel("Models/env/terrain/treasure.j3o");
Spatial spatial = am.loadModel("Models/env/terrain/scene.j3o");
// Spatial spatial = am.loadModel("Models/env/rock/rock.j3o");
// Spatial spatial = am.loadModel("Models/monster/raptor/raptor.mesh.j3o");
spatial.setLocalScale(5);
try {
j3oToHeightmap(spatial, "C:\\Users\\huliqing\\Desktop\\tttt\\test.jpg");
} catch (IOException ex) {
Logger.getLogger(HeightmapUtils.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例8: processOpen
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* The process of opening file.
*
* @param file the file
*/
protected void processOpen(@NotNull final Path file) {
final NodeTree<ModelChangeConsumer> nodeTree = getNodeTree();
final ModelChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer());
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
final String assetPath = EditorUtil.toAssetPath(assetFile);
final ModelKey modelKey = new ModelKey(assetPath);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial loadedModel = assetManager.loadModel(modelKey);
final Geometry geometry = NodeUtils.findGeometry(loadedModel);
if (geometry == null) {
LOGGER.warning(this, "not found a geometry in the model " + assetPath);
return;
}
final TreeNode<?> treeNode = getNode();
final ParticleEmitterNode emitterNode = (ParticleEmitterNode) treeNode.getElement();
final ParticleGeometry particleGeometry = emitterNode.getParticleGeometry();
final ParticleDataMeshInfo meshInfo = new ParticleDataMeshInfo(ParticleDataTemplateMesh.class, geometry.getMesh());
changeConsumer.execute(new ChangeParticleMeshOperation(meshInfo, particleGeometry));
}
示例9: processOpen
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
* The process of opening file.
*
* @param file the file
*/
@FXThread
protected void processOpen(@NotNull final Path file) {
final NodeTree<?> nodeTree = getNodeTree();
final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
final SceneLayer defaultLayer = EditorUtil.getDefaultLayer(consumer);
final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
final String assetPath = toAssetPath(assetFile);
final ModelKey modelKey = new ModelKey(assetPath);
final AssetManager assetManager = EDITOR.getAssetManager();
final Spatial loadedModel = assetManager.loadModel(modelKey);
final AssetLinkNode assetLinkNode = new AssetLinkNode(modelKey);
assetLinkNode.attachLinkedChild(loadedModel, modelKey);
assetLinkNode.setUserData(LOADED_MODEL_KEY, true);
if (defaultLayer != null) {
SceneLayer.setLayer(defaultLayer, assetLinkNode);
}
final TreeNode<?> treeNode = getNode();
final Node parent = (Node) treeNode.getElement();
consumer.execute(new AddChildOperation(assetLinkNode, parent));
}
示例10: create
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static Node create(AssetManager assetManager) {
logger.fine("Loading model \"TallGrass\" with specific factory");
Node model = (Node)assetManager.loadModel("Models/props/TallGrass.j3o");
model.setQueueBucket(RenderQueue.Bucket.Transparent);
return model;
}
示例11: create
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static Node create(AssetManager assetManager) {
logger.fine("Loading model \"Gauze\" with specific factory");
Node model = (Node)assetManager.loadModel("Models/I_Gauze.j3o");
model.setQueueBucket(RenderQueue.Bucket.Transparent);
return model;
}
示例12: getPrototype
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
private Spatial getPrototype(String modelPath) throws IllegalStateException {
if (modelPath.isEmpty()) {
return null;
}
if (!modelPrototypes.containsKey(modelPath)) {
try {
AssetManager assetManager = RendererPlatform.getAssetManager();
Spatial s = assetManager.loadModel("/models/" + modelPath);
// Material cube1Mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
// Material cube1Mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
// cube1Mat.setTexture("ColorMap", assetManager.loadTexture("textures/wuerfel/dots2.png"));
// cube1Mat.setBoolean("SeparateTexCoord", true);
// cube1Mat.setColor("Color", ColorRGBA.White);
// cube1Mat.setBoolean("VertexColor", true);
// Texture cube1Tex = assetManager.loadTexture("textures/wuerfel/dots2.png");
// cube1Mat.setTexture("DiffuseMap", cube1Tex);
// cube1Mat.setBoolean("UseAlpha", true);
// cube1Mat.setTexture("DiffuseMap", assetManager.loadTexture("textures/wuerfel/dots2.png"));
// cube1Mat.setTexture("NormalMap", assetManager.loadTexture("textures/wuerfel/dots2.png"));
// cube1Mat.setBoolean("UseMaterialColors", true);
// cube1Mat.setColor("Diffuse", ColorRGBA.White);
// cube1Mat.setColor("Specular", ColorRGBA.White);
// cube1Mat.setFloat("Shininess", 64f); // [0,128]
// s.setMaterial(cube1Mat);
modelPrototypes.put(modelPath, s);
} catch (Exception e) {
LogUtil.warning("Model not found : /models/" + modelPath + " (" + e + ")");
return null;
}
}
return modelPrototypes.get(modelPath);
}
示例13: testLoadJ3o
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Test
void testLoadJ3o() {
final AssetManager assetManager = getApplication().getAssetManager();
final Spatial model = assetManager.loadModel("com/ss/editor/extension/testCube.j3o");
Assertions.assertNotNull(model);
}
示例14: testLoadJ3s
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Test
void testLoadJ3s() {
final AssetManager assetManager = getApplication().getAssetManager();
final SceneNode model = (SceneNode) assetManager.loadModel("com/ss/editor/extension/testScene.j3s");
Assertions.assertNotNull(model);
}
示例15: findResource
import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
@FXThread
protected @Nullable Geometry findResource(@NotNull final AssetManager assetManager, @NotNull final ModelKey modelKey) {
final Spatial spatial = assetManager.loadModel(modelKey);
return NodeUtils.findGeometry(spatial);
}