本文整理汇总了Java中com.jme3.asset.AssetNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java AssetNotFoundException类的具体用法?Java AssetNotFoundException怎么用?Java AssetNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssetNotFoundException类属于com.jme3.asset包,在下文中一共展示了AssetNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMaterialImpl
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
/**
* Update the {@link Material} in the {@link EditorThread}.
*
* @param material the new material.
*/
@JMEThread
protected void updateMaterialImpl(@NotNull final Material material) {
final Geometry testBox = getTestBox();
testBox.setMaterial(material);
final Geometry testQuad = getTestQuad();
testQuad.setMaterial(material);
final Geometry testSphere = getTestSphere();
testSphere.setMaterial(material);
final RenderManager renderManager = EDITOR.getRenderManager();
try {
renderManager.preloadScene(testBox);
} catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) {
handleMaterialException(e);
testBox.setMaterial(EDITOR.getDefaultMaterial());
testQuad.setMaterial(EDITOR.getDefaultMaterial());
testSphere.setMaterial(EDITOR.getDefaultMaterial());
}
}
示例2: update
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
@Override
@JMEThread
public void update() {
final long stamp = syncLock();
try {
final JMEThreadExecutor executor = JMEThreadExecutor.getInstance();
executor.execute();
//System.out.println(cam.getRotation());
//System.out.println(cam.getLocation());
super.update();
} catch (final AssetNotFoundException | RendererException | AssertionError | ArrayIndexOutOfBoundsException |
NullPointerException | StackOverflowError | IllegalStateException | UnsupportedOperationException e) {
LOGGER.warning(e);
finishWorkOnError(e);
} finally {
syncUnlock(stamp);
}
listener.setLocation(cam.getLocation());
listener.setRotation(cam.getRotation());
}
示例3: loadProp
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
public void loadProp(SceneryItem sceneryItem, final SceneryInstance pageInstance) throws AssetNotFoundException {
final AbstractProp prop = propFactory.getProp(sceneryItem);
pageInstance.addPropSpatial(prop);
app.enqueue(new Callable<Void>() {
public Void call() {
Visibility vis = PropUserDataBuilder.getVisibility(prop.getSpatial());
PropUserDataBuilder.setVisible(prop.getSpatial(),
(BuildAppState.buildMode && (vis.equals(Visibility.BUILD_MODE) || vis.equals(Visibility.BOTH)))
|| (!BuildAppState.buildMode && (vis.equals(Visibility.GAME) || vis.equals(Visibility.BOTH))));
if (sceneryNode == null) {
throw new IllegalArgumentException("NULL scenery node???");
}
sceneryNode.attachChild(prop.getSpatial());
LOG.info(String.format("Attached %s at local %s world %s", prop.getName(), prop.getSpatial().getLocalTranslation(),
prop.getSpatial().getWorldTranslation()));
return null;
}
});
for (Listener l : listeners) {
l.propLoaded(prop);
}
}
示例4: read
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
mesh = (Mesh) ic.readSavable("mesh", null);
material = null;
String matName = ic.readString("materialName", null);
if (matName != null) {
// Material name is set,
// Attempt to load material via J3M
try {
material = im.getAssetManager().loadMaterial(matName);
} catch (AssetNotFoundException ex) {
// Cannot find J3M file.
logger.log(Level.FINE, "Could not load J3M file {0} for Geometry.",
matName);
}
}
// If material is NULL, try to load it from the geometry
if (material == null) {
material = (Material) ic.readSavable("material", null);
}
ignoreTransform = ic.readBoolean("ignoreTransform", false);
}
示例5: getInputStream
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
protected InputStream getInputStream(String uri) {
try {
int l = uri.lastIndexOf('#');
if (l != -1) {
uri = uri.substring(0, l);
}
while (uri.startsWith("/")) {
uri = uri.substring(1);
}
AssetInfo info = ToolKit.get().getApplication().getAssetManager().locateAsset(new AssetKey<String>(uri));
if (info == null)
throw new AssetNotFoundException(uri);
return info.openStream();
} catch (AssetNotFoundException anfe) {
XRLog.exception(String.format("Item at URI %s not found", uri));
} catch (Exception e) {
XRLog.exception(String.format("Failed to load %s", uri), e);
}
return null;
}
示例6: getImageResource
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
@Override
public ImageResource getImageResource(String uri) {
if (ImageUtil.isEmbeddedBase64Image(uri)) {
return loadEmbeddedBase64ImageResource(uri);
} else {
uri = resolveURI(uri);
try {
Texture tex = ToolKit.get().getApplication().getAssetManager().loadTexture(new TextureKey(uri));
return new ImageResource(uri, new XHTMLFSImage(tex.getImage(), this, uri));
} catch (AssetNotFoundException anfe) {
XRLog.exception(String.format("Image at URI %s not found", uri));
} catch (Exception e) {
XRLog.exception(String.format("Failed to load %s", uri), e);
}
return new ImageResource(uri, new XHTMLFSImage(getMissingImage(), this, uri));
}
}
示例7: getStylesheets
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
@Override
public Collection<Stylesheet> getStylesheets() {
// Try to locate a stylesheet for this layout
String cn = loader.getName();
String ext = loader.getExtension();
if (ext == null || ext.equals(""))
throw new IllegalArgumentException("Layout path must have an extension.");
cn = cn.substring(0, cn.length() - ext.length()) + "css";
AssetKey<Stylesheet> ss = new AssetKey<>(cn);
/// TODO probably wrong now?
List<Stylesheet> all = new ArrayList<Stylesheet>(screen.getStylesheets());
try {
Stylesheet sheet = screen.getApplication().getAssetManager().loadAsset(ss);
if (sheet != null)
all.add(sheet);
} catch (AssetNotFoundException anfe) {
// Don't care?
}
return all;
}
示例8: displayPreview
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
private void displayPreview() {
if (!"".equals(textureName)) {
exec.execute(new Runnable() {
@Override
public void run() {
try{
if (texPreview == null) {
texPreview = new TexturePreview(manager);
}
texPreview.requestPreview(textureName, "", 80, 25, texturePreview, null);
} catch (AssetNotFoundException a) {
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
}
}
});
}
}
示例9: locate
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
public AssetInfo locate(AssetManager assetManager, AssetKey assetKey) {
// Load the asset from root, based on the name of the file in the key
// (THIS IS THE ONLY PART THAT DIFFERS FROM FILELOCATOR)
String fileName = assetKey.getName().substring(assetKey.getFolder().length());
// This is copied verbatim from FileLocator in the engine.
File file = new File(root, fileName);
if (file.exists() && file.isFile()) {
try {
// Now, check asset name requirements
String canonical = file.getCanonicalPath();
String absolute = file.getAbsolutePath();
if (!canonical.endsWith(absolute)) {
throw new AssetNotFoundException("Asset name doesn't match requirements.\n"
+ "\"" + canonical + "\" doesn't match \"" + absolute + "\"");
}
} catch (IOException ex) {
throw new AssetLoadException("Failed to get file canonical path " + file, ex);
}
return new AssetInfoFile(assetManager, assetKey, file);
} else {
return null;
}
}
示例10: loadProjectData
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
/**
* 载入项目工程自定义的数据
* @throws LuoYingException
*/
private static void loadProjectData() throws LuoYingException {
try {
String dataConfigStr = (String) app.getAssetManager().loadAsset(PROJECT_CONFIG_FILE);
// 从config中读取 data xml配置文件
ByteArrayInputStream bais = new ByteArrayInputStream(dataConfigStr.getBytes());
BufferedReader br = new BufferedReader(new InputStreamReader(bais, "utf-8"));
String line;
while ((line = br.readLine()) != null) {
if (line.trim().length() <= 0)
continue;
if (line.trim().startsWith("#"))
continue;
loadData(line);
}
} catch (AssetNotFoundException anfe) {
LOG.log(Level.WARNING, "Data config file \"{0}\" not found!", PROJECT_CONFIG_FILE);
} catch (IOException ioe) {
LOG.log(Level.WARNING, "Could not load config file \"{0}\" ", PROJECT_CONFIG_FILE);
}
}
示例11: loadComponents
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
/**
* Loads the components if a components file with the same name exists.
*
* @param manager the manager object.
* @param p the prefab to load the component file from.
* @param mk the modelkey of the original object.
*/
private void loadComponents(AssetManager manager, Prefab p, ModelKey mk) {
String folder = mk.getFolder();
String name = mk.getName();
String baseName = Files.getNameWithoutExtension(name);
String components = folder + baseName + ".components";
try {
Object result = manager.loadAsset(components);
if (result instanceof ComponentList) {
ComponentList cl = (ComponentList) result;
p.addComponents(cl);
}
} catch (AssetNotFoundException ex) {
// not an error, it is possible that there is no components file.
}
}
示例12: createPrefab
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
public static Spatial createPrefab(NamedNodeMap map, AssetManager manager) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
String meshFile = getAttrContent("mesh", map);
if (meshFile == null || meshFile.length() == 0) {
return null;
}
String name = getAttrContent("name", map);
String shadowMode = getAttrContent("shadowmode", map);
try {
Spatial result = manager.loadModel(meshFile);
result.setName(name);
result.setShadowMode(ShadowMode.valueOf(shadowMode));
return result;
} catch (AssetNotFoundException ex) {
return null;
}
}
示例13: getHeightMapAt
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
public HeightMap getHeightMapAt(Vector3f location) {
// HEIGHTMAP image (for the terrain heightmap)
int x = (int) location.x;
int z = (int) location.z;
AbstractHeightMap heightmap = null;
//BufferedImage im = null;
try {
String name = namer.getName(x, z);
logger.log(Level.FINE, "Loading heightmap from file: {0}", name);
final Texture texture = assetManager.loadTexture(new TextureKey(name));
// CREATE HEIGHTMAP
heightmap = new ImageBasedHeightMap(texture.getImage());
heightmap.setHeightScale(1);
heightmap.load();
} catch (AssetNotFoundException e) {
logger.log(Level.SEVERE, "Asset Not found! ", e);
}
return heightmap;
}
示例14: locate
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
public AssetInfo locate(AssetManager manager, AssetKey key) {
String name = key.getName();
File file = new File(root, name);
if (file.exists() && file.isFile()){
try {
// Now, check asset name requirements
String canonical = file.getCanonicalPath();
String absolute = file.getAbsolutePath();
if (!canonical.endsWith(absolute)){
throw new AssetNotFoundException("Asset name doesn't match requirements.\n"+
"\"" + canonical + "\" doesn't match \"" + absolute + "\"");
}
} catch (IOException ex) {
throw new AssetLoadException("Failed to get file canonical path " + file, ex);
}
return new AssetInfoFile(manager, key, file);
}else{
return null;
}
}
示例15: tryToLoad
import com.jme3.asset.AssetNotFoundException; //导入依赖的package包/类
/**
* Try to load and show the model.
*
* @param model the model.
*/
@JMEThread
private void tryToLoad(@NotNull final Spatial model) {
try {
final Editor editor = Editor.getInstance();
final RenderManager renderManager = editor.getRenderManager();
renderManager.preloadScene(model);
modelNode.attachChild(model);
} catch (final RendererException | AssetNotFoundException | UnsupportedOperationException e) {
EditorUtil.handleException(LOGGER, this, e);
}
}