diff --git a/jme3-android/src/main/java/com/jme3/asset/AndroidAssetManager.java b/jme3-android/src/main/java/com/jme3/asset/AndroidAssetManager.java
deleted file mode 100644
index 9873a8476..000000000
--- a/jme3-android/src/main/java/com/jme3/asset/AndroidAssetManager.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2009-2012 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jme3.asset;
-
-import com.jme3.asset.plugins.AndroidLocator;
-import com.jme3.asset.plugins.ClasspathLocator;
-import com.jme3.audio.plugins.AndroidAudioLoader;
-import com.jme3.audio.plugins.NativeVorbisLoader;
-import com.jme3.audio.plugins.WAVLoader;
-import com.jme3.system.AppSettings;
-import com.jme3.system.android.JmeAndroidSystem;
-import com.jme3.texture.plugins.AndroidBufferImageLoader;
-import com.jme3.texture.plugins.AndroidNativeImageLoader;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * AndroidAssetManager
is an implementation of DesktopAssetManager for Android
- *
- * @author larynx
- */
-public class AndroidAssetManager extends DesktopAssetManager {
-
- private static final Logger logger = Logger.getLogger(AndroidAssetManager.class.getName());
-
- private void registerLoaderSafe(String loaderClass, String ... extensions) {
- try {
- Class extends AssetLoader> loader = (Class extends AssetLoader>) Class.forName(loaderClass);
- registerLoader(loader, extensions);
- } catch (Exception e){
- logger.log(Level.WARNING, "Failed to load AssetLoader", e);
- }
- }
-
- /**
- * AndroidAssetManager constructor
- * If URL == null then a default list of locators and loaders for android is set
- * @param configFile
- */
- public AndroidAssetManager(URL configFile) {
- System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
-
- // Set Default Android config
- registerLocator("", AndroidLocator.class);
- registerLocator("", ClasspathLocator.class);
-
- registerLoader(AndroidNativeImageLoader.class, "jpg", "jpeg", "bmp", "gif", "png");
-
- if (JmeAndroidSystem.getAudioRendererType().equals(AppSettings.ANDROID_MEDIAPLAYER)) {
- registerLoader(AndroidAudioLoader.class, "ogg", "mp3", "wav");
- } else if (JmeAndroidSystem.getAudioRendererType().equals(AppSettings.ANDROID_OPENAL_SOFT)) {
- registerLoader(WAVLoader.class, "wav");
- registerLoader(NativeVorbisLoader.class, "ogg");
- } else {
- throw new IllegalStateException("No Audio Renderer Type defined!");
- }
-
- registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3m");
- registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3md");
- registerLoader(com.jme3.material.plugins.ShaderNodeDefinitionLoader.class, "j3sn");
- registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");
- registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
- registerLoader(com.jme3.font.plugins.BitmapFontLoader.class, "fnt");
-
- // Less common loaders (especially on Android)
- registerLoaderSafe("com.jme3.texture.plugins.DDSLoader", "dds");
- registerLoaderSafe("com.jme3.texture.plugins.PFMLoader", "pfm");
- registerLoaderSafe("com.jme3.texture.plugins.HDRLoader", "hdr");
- registerLoaderSafe("com.jme3.texture.plugins.TGALoader", "tga");
- registerLoaderSafe("com.jme3.scene.plugins.OBJLoader", "obj");
- registerLoaderSafe("com.jme3.scene.plugins.MTLLoader", "mtl");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.MeshLoader", "mesh.xml");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.SkeletonLoader", "skeleton.xml");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.MaterialLoader", "material");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.SceneLoader", "scene");
-
-
- logger.fine("AndroidAssetManager created.");
- }
-
-}
diff --git a/jme3-android/src/main/java/com/jme3/asset/AndroidImageInfo.java b/jme3-android/src/main/java/com/jme3/asset/AndroidImageInfo.java
index b509f9f4d..8d064f5fe 100644
--- a/jme3-android/src/main/java/com/jme3/asset/AndroidImageInfo.java
+++ b/jme3-android/src/main/java/com/jme3/asset/AndroidImageInfo.java
@@ -20,6 +20,7 @@ import java.util.logging.Logger;
*
* @author Kirill Vainer
*/
+@Deprecated
public class AndroidImageInfo extends ImageRaster {
private static final Logger logger = Logger.getLogger(AndroidImageInfo.class.getName());
diff --git a/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java b/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
index c2dfa7b17..fc6ef7683 100644
--- a/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
+++ b/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
@@ -6,9 +6,6 @@ import android.graphics.Bitmap;
import android.os.Environment;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
-import com.jme3.asset.AndroidAssetManager;
-import com.jme3.asset.AndroidImageInfo;
-import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.audio.android.AndroidAL;
import com.jme3.audio.android.AndroidALC;
@@ -19,14 +16,10 @@ import com.jme3.audio.openal.ALC;
import com.jme3.audio.openal.EFX;
import com.jme3.system.*;
import com.jme3.system.JmeContext.Type;
-import com.jme3.texture.Image;
-import com.jme3.texture.image.DefaultImageRaster;
-import com.jme3.texture.image.ImageRaster;
import com.jme3.util.AndroidScreenshots;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.URL;
import java.nio.ByteBuffer;
import java.util.logging.Level;
@@ -41,6 +34,11 @@ public class JmeAndroidSystem extends JmeSystemDelegate {
} catch (UnsatisfiedLinkError e) {
}
}
+
+ @Override
+ public String getPlatformAssetConfigPath() {
+ return "com/jme3/asset/Android.cfg";
+ }
@Override
public void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException {
@@ -58,27 +56,6 @@ public class JmeAndroidSystem extends JmeSystemDelegate {
bitmapImage.recycle();
}
- @Override
- public ImageRaster createImageRaster(Image image, int slice) {
- if (image.getEfficentData() != null) {
- return (AndroidImageInfo) image.getEfficentData();
- } else {
- return new DefaultImageRaster(image, slice);
- }
- }
-
- @Override
- public AssetManager newAssetManager(URL configFile) {
- logger.log(Level.FINE, "Creating asset manager with config {0}", configFile);
- return new AndroidAssetManager(configFile);
- }
-
- @Override
- public AssetManager newAssetManager() {
- logger.log(Level.FINE, "Creating asset manager with default config");
- return new AndroidAssetManager(null);
- }
-
@Override
public void showErrorDialog(String message) {
final String finalMsg = message;
@@ -122,21 +99,6 @@ public class JmeAndroidSystem extends JmeSystemDelegate {
AL al = new AndroidAL();
EFX efx = new AndroidEFX();
return new ALAudioRenderer(al, alc, efx);
-/*
- if (settings.getAudioRenderer().equals(AppSettings.ANDROID_MEDIAPLAYER)) {
- logger.log(Level.INFO, "newAudioRenderer settings set to Android MediaPlayer / SoundPool");
- audioRendererType = AppSettings.ANDROID_MEDIAPLAYER;
- return new AndroidMediaPlayerAudioRenderer(activity);
- } else if (settings.getAudioRenderer().equals(AppSettings.ANDROID_OPENAL_SOFT)) {
- logger.log(Level.INFO, "newAudioRenderer settings set to Android OpenAL Soft");
- audioRendererType = AppSettings.ANDROID_OPENAL_SOFT;
- return new AndroidMediaPlayerAudioRenderer(activity);
- } else {
- logger.log(Level.INFO, "AudioRenderer not set. Defaulting to Android MediaPlayer / SoundPool");
- audioRendererType = AppSettings.ANDROID_MEDIAPLAYER;
- return new AndroidMediaPlayerAudioRenderer(activity);
- }
-*/
}
@Override
@@ -145,6 +107,7 @@ public class JmeAndroidSystem extends JmeSystemDelegate {
return;
}
initialized = true;
+ System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
logger.log(Level.INFO, getBuildInfo());
}
diff --git a/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidBufferImageLoader.java b/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidBufferImageLoader.java
index 33bcb369e..bf2abb7a4 100644
--- a/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidBufferImageLoader.java
+++ b/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidBufferImageLoader.java
@@ -50,6 +50,7 @@ import java.nio.ByteBuffer;
*
* @author Kirill Vainer
*/
+@Deprecated
public class AndroidBufferImageLoader implements AssetLoader {
private final byte[] tempData = new byte[16 * 1024];
diff --git a/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidImageLoader.java b/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidImageLoader.java
index 739e031de..f3c1464a2 100644
--- a/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidImageLoader.java
+++ b/jme3-android/src/main/java/com/jme3/texture/plugins/AndroidImageLoader.java
@@ -8,6 +8,7 @@ import com.jme3.texture.Image;
import com.jme3.texture.image.ColorSpace;
import java.io.IOException;
+@Deprecated
public class AndroidImageLoader implements AssetLoader {
public Object load(AssetInfo info) throws IOException {
diff --git a/jme3-android/src/main/resources/com/jme3/asset/Android.cfg b/jme3-android/src/main/resources/com/jme3/asset/Android.cfg
new file mode 100644
index 000000000..b793e9f0f
--- /dev/null
+++ b/jme3-android/src/main/resources/com/jme3/asset/Android.cfg
@@ -0,0 +1,8 @@
+INCLUDE com/jme3/asset/General.cfg
+
+# Android specific locators
+LOCATOR / com.jme3.asset.plugins.AndroidLocator
+
+# Android specific loaders
+LOADER com.jme3.texture.plugins.AndroidNativeImageLoader : jpg, bmp, gif, png, jpeg
+LOADER com.jme3.audio.plugins.NativeVorbisLoader : ogg
diff --git a/jme3-core/src/main/java/com/jme3/animation/AnimControl.java b/jme3-core/src/main/java/com/jme3/animation/AnimControl.java
index 615fe2fd8..13328cddf 100644
--- a/jme3-core/src/main/java/com/jme3/animation/AnimControl.java
+++ b/jme3-core/src/main/java/com/jme3/animation/AnimControl.java
@@ -56,12 +56,12 @@ import java.util.Map.Entry;
* 4) Animation event listeners
* 5) Animated model cloning
* 6) Animated model binary import/export
+ * 7) Hardware skinning
+ * 8) Attachments
+ * 9) Add/remove skins
*
* Planned:
- * 1) Hardware skinning
- * 2) Morph/Pose animation
- * 3) Attachments
- * 4) Add/remove skins
+ * 1) Morph/Pose animation
*
* @author Kirill Vainer
*/
diff --git a/jme3-core/src/main/java/com/jme3/app/Application.java b/jme3-core/src/main/java/com/jme3/app/Application.java
index 8c05f2b18..2bcd6a4d9 100644
--- a/jme3-core/src/main/java/com/jme3/app/Application.java
+++ b/jme3-core/src/main/java/com/jme3/app/Application.java
@@ -174,28 +174,30 @@ public class Application implements SystemListener {
}
private void initAssetManager(){
+ URL assetCfgUrl = null;
+
if (settings != null){
String assetCfg = settings.getString("AssetConfigURL");
if (assetCfg != null){
- URL url = null;
try {
- url = new URL(assetCfg);
+ assetCfgUrl = new URL(assetCfg);
} catch (MalformedURLException ex) {
}
- if (url == null) {
- url = Application.class.getClassLoader().getResource(assetCfg);
- if (url == null) {
+ if (assetCfgUrl == null) {
+ assetCfgUrl = Application.class.getClassLoader().getResource(assetCfg);
+ if (assetCfgUrl == null) {
logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
return;
}
}
- assetManager = JmeSystem.newAssetManager(url);
}
}
+ if (assetCfgUrl == null) {
+ String assetCfg = JmeSystem.getPlatformAssetConfigPath();
+ assetCfgUrl = Thread.currentThread().getContextClassLoader().getResource(assetCfg);
+ }
if (assetManager == null){
- assetManager = JmeSystem.newAssetManager(
- Thread.currentThread().getContextClassLoader()
- .getResource("com/jme3/asset/Desktop.cfg"));
+ assetManager = JmeSystem.newAssetManager(assetCfgUrl);
}
}
diff --git a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
index 735a57be8..50b6e38af 100644
--- a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
+++ b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
@@ -33,6 +33,9 @@ package com.jme3.asset;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Locale;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -42,97 +45,77 @@ import java.util.logging.Logger;
*
* The config file is specified with the following format:
*
+ * "INCLUDE"
*
* @author Kirill Vainer
*/
-public class AssetConfig {
+public final class AssetConfig {
- private AssetManager manager;
-
- public AssetConfig(AssetManager manager){
- this.manager = manager;
- }
-
- public void loadText(InputStream in) throws IOException{
- Scanner scan = new Scanner(in);
- while (scan.hasNext()){
- String cmd = scan.next();
- if (cmd.equals("LOADER")){
- String loaderClass = scan.next();
- String colon = scan.next();
- if (!colon.equals(":")){
- throw new IOException("Expected ':', got '"+colon+"'");
- }
- String extensionsList = scan.nextLine();
- String[] extensions = extensionsList.split(",");
- for (int i = 0; i < extensions.length; i++){
- extensions[i] = extensions[i].trim();
- }
- Class clazz = acquireClass(loaderClass);
- if (clazz != null) {
- manager.registerLoader(clazz, extensions);
- } else {
- Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find loader {0}", loaderClass);
- }
- } else if (cmd.equals("LOCATOR")) {
- String rootPath = scan.next();
- String locatorClass = scan.nextLine().trim();
- Class clazz = acquireClass(locatorClass);
- if (clazz != null) {
- manager.registerLocator(rootPath, clazz);
- } else {
- Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find locator {0}", locatorClass);
- }
- } else {
- throw new IOException("Expected command, got '" + cmd + "'");
- }
- }
- }
+ private static final Logger logger = Logger.getLogger(AssetConfig.class.getName());
- private Class acquireClass(String name) {
+ private AssetConfig() { }
+
+ private static Class acquireClass(String name) {
try {
- Class clazz = Class.forName(name);
- return clazz;
+ return Class.forName(name);
} catch (ClassNotFoundException ex) {
return null;
}
}
- /*
- private static String readString(DataInput dataIn) throws IOException{
- int length = dataIn.readUnsignedShort();
- char[] chrs = new char[length];
- for (int i = 0; i < length; i++){
- chrs[i] = (char) dataIn.readUnsignedByte();
- }
- return String.valueOf(chrs);
- }
-
- public void loadBinary(DataInput dataIn) throws IOException{
- // read signature and version
-
- // how many locator entries?
- int locatorEntries = dataIn.readUnsignedShort();
- for (int i = 0; i < locatorEntries; i++){
- String locatorClazz = readString(dataIn);
- String rootPath = readString(dataIn);
- manager.registerLocator(rootPath, locatorClazz);
- }
-
- int loaderEntries = dataIn.readUnsignedShort();
- for (int i = 0; i < loaderEntries; i++){
- String loaderClazz = readString(dataIn);
- int numExtensions = dataIn.readUnsignedByte();
- String[] extensions = new String[numExtensions];
- for (int j = 0; j < numExtensions; j++){
- extensions[j] = readString(dataIn);
+ public static void loadText(AssetManager assetManager, URL configUrl) throws IOException{
+ InputStream in = configUrl.openStream();
+ try {
+ Scanner scan = new Scanner(in);
+ scan.useLocale(Locale.US); // Fix commas / periods ??
+ while (scan.hasNext()){
+ String cmd = scan.next();
+ if (cmd.equals("LOADER")){
+ String loaderClass = scan.next();
+ String colon = scan.next();
+ if (!colon.equals(":")){
+ throw new IOException("Expected ':', got '"+colon+"'");
+ }
+ String extensionsList = scan.nextLine();
+ String[] extensions = extensionsList.split(",");
+ for (int i = 0; i < extensions.length; i++){
+ extensions[i] = extensions[i].trim();
+ }
+ Class clazz = acquireClass(loaderClass);
+ if (clazz != null) {
+ assetManager.registerLoader(clazz, extensions);
+ } else {
+ logger.log(Level.WARNING, "Cannot find loader {0}", loaderClass);
+ }
+ } else if (cmd.equals("LOCATOR")) {
+ String rootPath = scan.next();
+ String locatorClass = scan.nextLine().trim();
+ Class clazz = acquireClass(locatorClass);
+ if (clazz != null) {
+ assetManager.registerLocator(rootPath, clazz);
+ } else {
+ logger.log(Level.WARNING, "Cannot find locator {0}", locatorClass);
+ }
+ } else if (cmd.equals("INCLUDE")) {
+ String includedCfg = scan.nextLine().trim();
+ URL includedCfgUrl = Thread.currentThread().getContextClassLoader().getResource(includedCfg);
+ if (includedCfgUrl != null) {
+ loadText(assetManager, includedCfgUrl);
+ } else {
+ logger.log(Level.WARNING, "Cannot find config include {0}", includedCfg);
+ }
+ } else if (cmd.trim().startsWith("#")) {
+ scan.nextLine();
+ continue;
+ } else {
+ throw new IOException("Expected command, got '" + cmd + "'");
+ }
}
-
- manager.registerLoader(loaderClazz, extensions);
+ } finally {
+ if (in != null) in.close();
}
}
- */
}
diff --git a/jme3-core/src/main/java/com/jme3/asset/AssetManager.java b/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
index b1d623070..a077512ef 100644
--- a/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
+++ b/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
@@ -46,6 +46,8 @@ import com.jme3.shader.ShaderGenerator;
import com.jme3.shader.ShaderKey;
import com.jme3.texture.Texture;
import com.jme3.texture.plugins.TGALoader;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.EnumSet;
import java.util.List;
@@ -75,7 +77,15 @@ import java.util.List;
*
- * Once the asset has been loaded,
+ * Once the asset has been loaded, it will be
+ * {@link AssetProcessor#postProcess(com.jme3.asset.AssetKey, java.lang.Object)
+ * post-processed} by the {@link AssetKey#getProcessorType() key's processor}.
+ * If the key specifies a {@link AssetKey#getCacheType() cache type}, the asset
+ * will be cached in the specified cache. Next, the {@link AssetProcessor}
+ * will be requested to {@link AssetProcessor#createClone(java.lang.Object) }
+ * generate a clone for the asset. Some assets do not require cloning,
+ * such as immutable or shared assets. Others, like models, must be cloned
+ * so that modifications to one instance do not leak onto others.
*/
public interface AssetManager {
@@ -100,46 +110,13 @@ public interface AssetManager {
*/
public List
+
+
+Assets in jME3 are cached in such a way that if there are no instances of
+that asset anymore in memory, then jME3 is likely to reclaim them.
+Some asset types must be cloned prior to being used, for example, 3D models
+cannot be stored in the cache as-is, because the user is likely to modify them
+after loading them. To handle this, a copy of the asset is stored in the
+cache instead. The asset cache that implements these rules is the
+{@link com.jme3.asset.cache.WeakRefCloneAssetCache} and it is used
+for caching most asset types.
+
+
+
+
diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
index 311a3bcfc..b6ad6ace4 100644
--- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
+++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java
@@ -863,10 +863,12 @@ public class RenderManager {
private void setViewPort(Camera cam) {
// this will make sure to update viewport only if needed
if (cam != prevCam || cam.isViewportChanged()) {
- viewX = (int) (cam.getViewPortLeft() * cam.getWidth());
- viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
- viewWidth = ((int)(cam.getViewPortRight() * cam.getWidth())) - ((int)(cam.getViewPortLeft() * cam.getWidth()));
- viewHeight = ((int)(cam.getViewPortTop() * cam.getHeight())) - ((int)(cam.getViewPortBottom() * cam.getHeight()));
+ viewX = (int) (cam.getViewPortLeft() * cam.getWidth());
+ viewY = (int) (cam.getViewPortBottom() * cam.getHeight());
+ int viewX2 = (int) (cam.getViewPortRight() * cam.getWidth());
+ int viewY2 = (int) (cam.getViewPortTop() * cam.getHeight());
+ viewWidth = viewX2 - viewX;
+ viewHeight = viewY2 - viewY;
uniformBindingManager.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);
renderer.setClipRect(viewX, viewY, viewWidth, viewHeight);
diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystem.java b/jme3-core/src/main/java/com/jme3/system/JmeSystem.java
index 637b24304..a29262726 100644
--- a/jme3-core/src/main/java/com/jme3/system/JmeSystem.java
+++ b/jme3-core/src/main/java/com/jme3/system/JmeSystem.java
@@ -35,6 +35,7 @@ import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.input.SoftTextDialogInput;
import com.jme3.texture.Image;
+import com.jme3.texture.image.DefaultImageRaster;
import com.jme3.texture.image.ImageRaster;
import java.io.File;
import java.io.IOException;
@@ -166,6 +167,15 @@ public class JmeSystem {
return systemDelegate.newAudioRenderer(settings);
}
+ public static String getPlatformAssetConfigPath() {
+ checkDelegate();
+ return systemDelegate.getPlatformAssetConfigPath();
+ }
+
+ /**
+ * @deprecated Directly create an image raster via {@link DefaultImageRaster}.
+ */
+ @Deprecated
public static ImageRaster createImageRaster(Image image, int slice) {
checkDelegate();
return systemDelegate.createImageRaster(image, slice);
diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
index 6b204456b..a129f6423 100644
--- a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
+++ b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
@@ -32,9 +32,11 @@
package com.jme3.system;
import com.jme3.asset.AssetManager;
+import com.jme3.asset.DesktopAssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.input.SoftTextDialogInput;
import com.jme3.texture.Image;
+import com.jme3.texture.image.DefaultImageRaster;
import com.jme3.texture.image.ImageRaster;
import java.io.File;
import java.io.IOException;
@@ -117,15 +119,25 @@ public abstract class JmeSystemDelegate {
public void setSoftTextDialogInput(SoftTextDialogInput input) {
softTextDialogInput = input;
}
+
public SoftTextDialogInput getSoftTextDialogInput() {
return softTextDialogInput;
}
- public abstract void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException;
-
- public abstract AssetManager newAssetManager(URL configFile);
+ public final AssetManager newAssetManager(URL configFile) {
+ return new DesktopAssetManager(configFile);
+ }
- public abstract AssetManager newAssetManager();
+ public final AssetManager newAssetManager() {
+ return new DesktopAssetManager(null);
+ }
+
+ @Deprecated
+ public final ImageRaster createImageRaster(Image image, int slice) {
+ return new DefaultImageRaster(image, slice);
+ }
+
+ public abstract void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException;
public abstract void showErrorDialog(String message);
@@ -181,13 +193,13 @@ public abstract class JmeSystemDelegate {
return sb.toString();
}
+ public abstract String getPlatformAssetConfigPath();
+
public abstract JmeContext newContext(AppSettings settings, JmeContext.Type contextType);
public abstract AudioRenderer newAudioRenderer(AppSettings settings);
public abstract void initialize(AppSettings settings);
- public abstract ImageRaster createImageRaster(Image image, int slice);
-
public abstract void showSoftKeyboard(boolean show);
}
diff --git a/jme3-core/src/main/resources/com/jme3/asset/Desktop.cfg b/jme3-core/src/main/resources/com/jme3/asset/Desktop.cfg
index 08e6492f5..df72654a1 100644
--- a/jme3-core/src/main/resources/com/jme3/asset/Desktop.cfg
+++ b/jme3-core/src/main/resources/com/jme3/asset/Desktop.cfg
@@ -1,7 +1,8 @@
-LOCATOR / com.jme3.asset.plugins.ClasspathLocator
+INCLUDE com/jme3/asset/General.cfg
+# Desktop-specific loaders
LOADER com.jme3.texture.plugins.AWTLoader : jpg, bmp, gif, png, jpeg
-LOADER com.jme3.audio.plugins.WAVLoader : wav
+LOADER com.jme3.audio.plugins.OGGLoader : oggLOADER com.jme3.audio.plugins.WAVLoader : wav
LOADER com.jme3.audio.plugins.OGGLoader : ogg
LOADER com.jme3.cursors.plugins.CursorLoader : ani, cur, ico
LOADER com.jme3.material.plugins.J3MLoader : j3m
diff --git a/jme3-core/src/main/resources/com/jme3/asset/General.cfg b/jme3-core/src/main/resources/com/jme3/asset/General.cfg
new file mode 100644
index 000000000..c0098ffe5
--- /dev/null
+++ b/jme3-core/src/main/resources/com/jme3/asset/General.cfg
@@ -0,0 +1,26 @@
+# Generic locators that should be supported on all platforms.
+LOCATOR / com.jme3.asset.plugins.ClasspathLocator
+
+# Generic loaders that should be supported on all platforms.
+LOADER com.jme3.audio.plugins.WAVLoader : wav
+LOADER com.jme3.cursors.plugins.CursorLoader : ani, cur, ico
+LOADER com.jme3.material.plugins.J3MLoader : j3m
+LOADER com.jme3.material.plugins.J3MLoader : j3md
+LOADER com.jme3.material.plugins.ShaderNodeDefinitionLoader : j3sn
+LOADER com.jme3.font.plugins.BitmapFontLoader : fnt
+LOADER com.jme3.texture.plugins.DDSLoader : dds
+LOADER com.jme3.texture.plugins.PFMLoader : pfm
+LOADER com.jme3.texture.plugins.HDRLoader : hdr
+LOADER com.jme3.texture.plugins.TGALoader : tga
+LOADER com.jme3.export.binary.BinaryImporter : j3o
+LOADER com.jme3.export.binary.BinaryImporter : j3f
+LOADER com.jme3.scene.plugins.OBJLoader : obj
+LOADER com.jme3.scene.plugins.MTLLoader : mtl
+LOADER com.jme3.scene.plugins.ogre.MeshLoader : meshxml, mesh.xml
+LOADER com.jme3.scene.plugins.ogre.SkeletonLoader : skeletonxml, skeleton.xml
+LOADER com.jme3.scene.plugins.ogre.MaterialLoader : material
+LOADER com.jme3.scene.plugins.ogre.SceneLoader : scene
+LOADER com.jme3.scene.plugins.blender.BlenderModelLoader : blend
+LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
+LOADER com.jme3.scene.plugins.fbx.SceneLoader : fbx
+LOADER com.jme3.scene.plugins.fbx.SceneWithAnimationLoader : fba
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
index 43feaa113..dbeff428a 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
@@ -41,6 +41,16 @@ import java.util.logging.Logger;
/**
* The
+ * The root path must be a valid HTTP(S) {@link URL} pointing to ZIP or
+ * ZIP-like file (such as a JAR). For example,
+ * The locator is designed in such a way that it does not require downloading
+ * the entire
+ * The root path must be a valid {@link URL}, for example, AssetManager
. Any currently added listeners are
- * cleared and then the given listener is added.
- *
- * @param listener The listener to set
- * @deprecated Please use {@link #addAssetEventListener(com.jme3.asset.AssetEventListener) }
- * to listen for asset events.
- */
- @Deprecated
- public void setAssetEventListener(AssetEventListener listener);
-
/**
* Manually locates an asset with the given {@link AssetKey}.
* This method should be used for debugging or internal uses.
@@ -233,6 +198,23 @@ public interface AssetManager {
*/
public AssetInfo locateAsset(AssetKey> key);
+ /**
+ * Load an asset from an {@link InputStream}.
+ * In some cases it may be required to load an asset from memory
+ * or arbitrary streams so that registering a custom locator and key
+ * type is not necessary.
+ *
+ * @param
- * loadAsset(new AssetKey(name)).
- *
+ * Load an asset by name, calling this method is the same as calling
+ * loadAsset(new AssetKey(name))
.
*
* @param name The name of the asset to load.
* @return The loaded asset, or null if failed to be loaded.
@@ -265,7 +248,7 @@ public interface AssetManager {
/**
* Loads texture file, supported types are BMP, JPG, PNG, GIF,
- * TGA and DDS.
+ * TGA, DDS, PFM, and HDR.
*
* @param key The {@link TextureKey} to use for loading.
* @return The loaded texture, or null if failed to be loaded.
@@ -276,8 +259,10 @@ public interface AssetManager {
/**
* Loads texture file, supported types are BMP, JPG, PNG, GIF,
- * TGA and DDS.
+ * TGA, DDS, PFM, and HDR.
*
+ * The texture will be loaded with mip-mapping enabled.
+ *
* @param name The name of the texture to load.
* @return The texture that was loaded
*
@@ -306,7 +291,8 @@ public interface AssetManager {
/**
* Loads a 3D model with a ModelKey.
- * Models can be jME3 object files (J3O) or OgreXML/OBJ files.
+ * Models can be jME3 object files (J3O), OgreXML (mesh.xml), BLEND, FBX
+ * and OBJ files.
* @param key Asset key of the model to load
* @return The model that was loaded
*
@@ -315,8 +301,9 @@ public interface AssetManager {
public Spatial loadModel(ModelKey key);
/**
- * Loads a 3D model. Models can be jME3 object files (J3O) or
- * OgreXML/OBJ files.
+ * Loads a 3D model. Models can be jME3 object files (J3O),
+ * OgreXML (mesh.xml), BLEND, FBX and OBJ files.
+ *
* @param name Asset name of the model to load
* @return The model that was loaded
*
@@ -381,4 +368,53 @@ public interface AssetManager {
*/
public ShaderGenerator getShaderGenerator(EnumSetnull
.
+ *
+ * @throws IllegalArgumentException If {@link AssetKey#getCacheType() caching}
+ * is disabled for the key.
+ */
+ public WeakRefCloneAssetCache
caches cloneable assets in a weak-key
* cache, allowing them to be collected when memory is low.
* The cache stores weak references to the asset keys, so that
* when all clones of the original asset are collected, will cause the
diff --git a/jme3-core/src/main/java/com/jme3/asset/cache/package.html b/jme3-core/src/main/java/com/jme3/asset/cache/package.html
new file mode 100644
index 000000000..4aca0c878
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/asset/cache/package.html
@@ -0,0 +1,30 @@
+
+
+
+
+com.jme3.asset.cache
contains the {@link com.jme3.asset.cache.AssetCache}
+interface as well as its implementations.
+
+AssetCaches
+The asset cache implementations are used by {@link com.jme3.asset.AssetManager}
+to cache loaded assets for faster access if they are requested again.
+ClasspathLocator
looks up an asset in the classpath.
+ *
+ * This locator is used by default in all jME3 projects (unless
+ * {@link AssetManager#unregisterLocator(java.lang.String, java.lang.Class) unregistered}
+ * ).
+ * Unlike Java's default resource loading mechanism, the ClasspathLocator
+ * enforces case-sensitivity on platforms which do not have it such as Windows.
+ * Therefore, it is critical to provide a path matching the case of the file on
+ * the filesystem. This also ensures that the file can be loaded if it was
+ * later included in a .JAR
file instead of a folder.
+ *
* @author Kirill Vainer
*/
public class ClasspathLocator implements AssetLocator {
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/FileLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/FileLocator.java
index 88d4d3ee0..f46a97516 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/FileLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/FileLocator.java
@@ -37,6 +37,7 @@ import java.io.*;
/**
* FileLocator
allows you to specify a folder where to
* look for assets.
+ *
* @author Kirill Vainer
*/
public class FileLocator implements AssetLocator {
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/HttpZipLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/HttpZipLocator.java
index af7026206..7edda53e4 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/HttpZipLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/HttpZipLocator.java
@@ -52,6 +52,23 @@ import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import java.util.zip.ZipEntry;
+/**
+ * HttpZipLocator
is similar to {@link ZipLocator}, except
+ * it allows loading assets from a .ZIP
file on the web instead of
+ * on the local filesystem.
+ *
+ * https://www.example.com/my/sub/path/assets.zip
.
+ * .ZIP
file from the web in order to load
+ * assets from it. Instead, the ZIP header is extracted first, and then
+ * is used to lookup assets from within the ZIP file and download them
+ * as requested by the user.
+ *
+ * @author Kirill Vainer
+ */
public class HttpZipLocator implements AssetLocator {
private static final Logger logger = Logger.getLogger(HttpZipLocator.class.getName());
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/UrlLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/UrlLocator.java
index 1de7008d8..31cfe0f2c 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/UrlLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/UrlLocator.java
@@ -46,6 +46,10 @@ import java.util.logging.Logger;
* UrlLocator
is a locator that combines a root URL
* and the given path in the AssetKey to construct a new URL
* that allows locating the asset.
+ *
+ * https://www.example.com/assets/
+ *
* @author Kirill Vainer
*/
public class UrlLocator implements AssetLocator {
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ZipLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ZipLocator.java
index 9f1508f44..d20816f34 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ZipLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ZipLocator.java
@@ -40,7 +40,13 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
- * ZipLocator
is a locator that looks up resources in a .ZIP file.
+ * ZipLocator
is a locator that looks up resources in a
+ * .ZIP
file.
+ *
+ * The root path must be a valid ZIP or ZIP-like {@link File file},
+ * for example,
+ * C:\My App\data.zip
+ *
* @author Kirill Vainer
*/
public class ZipLocator implements AssetLocator {
diff --git a/jme3-core/src/tools/java/jme3tools/converters/FolderConverter.java b/jme3-core/src/tools/java/jme3tools/converters/FolderConverter.java
deleted file mode 100644
index a2edda488..000000000
--- a/jme3-core/src/tools/java/jme3tools/converters/FolderConverter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2009-2012 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package jme3tools.converters;
-
-import com.jme3.asset.AssetManager;
-import com.jme3.system.JmeSystem;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-
-public class FolderConverter {
-
- private static AssetManager assetManager;
- private static File sourceRoot;
- private static JarOutputStream jarOut;
- private static long time;
-
- private static void process(File file) throws IOException{
- String name = file.getName().replaceAll("[\\/\\.]", "_");
- JarEntry entry = new JarEntry(name);
- entry.setTime(time);
-
- jarOut.putNextEntry(entry);
- }
-
- public static void main(String[] args) throws IOException{
- if (args.length == 0){
- System.out.println("Usage: java -jar FolderConverter ");
- System.out.println();
- System.out.println(" Converts files from input to output");
- System.exit(1);
- }
-
- sourceRoot = new File(args[0]);
-
- File jarFile = new File(sourceRoot.getParent(), sourceRoot.getName()+".jar");
- FileOutputStream out = new FileOutputStream(jarFile);
- jarOut = new JarOutputStream(out);
-
- assetManager = JmeSystem.newAssetManager();
- assetManager.registerLocator(sourceRoot.toString(),
- "com.jme3.asset.plugins.FileSystemLocator");
- for (File f : sourceRoot.listFiles()){
- process(f);
- }
- }
-
-}
diff --git a/jme3-core/src/tools/java/jme3tools/converters/model/FloatToFixed.java b/jme3-core/src/tools/java/jme3tools/converters/model/FloatToFixed.java
deleted file mode 100644
index 7e2b83e14..000000000
--- a/jme3-core/src/tools/java/jme3tools/converters/model/FloatToFixed.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright (c) 2009-2012 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package jme3tools.converters.model;
-
-import com.jme3.bounding.BoundingBox;
-import com.jme3.math.Transform;
-import com.jme3.math.Vector2f;
-import com.jme3.math.Vector3f;
-import com.jme3.scene.Geometry;
-import com.jme3.scene.Mesh;
-import com.jme3.scene.VertexBuffer;
-import com.jme3.scene.VertexBuffer.Format;
-import com.jme3.scene.VertexBuffer.Type;
-import com.jme3.scene.VertexBuffer.Usage;
-import com.jme3.scene.mesh.IndexBuffer;
-import com.jme3.util.BufferUtils;
-import java.nio.*;
-
-@Deprecated
-public class FloatToFixed {
-
- private static final float shortSize = Short.MAX_VALUE - Short.MIN_VALUE;
- private static final float shortOff = (Short.MAX_VALUE + Short.MIN_VALUE) * 0.5f;
-
- private static final float byteSize = Byte.MAX_VALUE - Byte.MIN_VALUE;
- private static final float byteOff = (Byte.MAX_VALUE + Byte.MIN_VALUE) * 0.5f;
-
- @Deprecated
- public static void convertToFixed(Geometry geom, Format posFmt, Format nmFmt, Format tcFmt){
- geom.updateModelBound();
- BoundingBox bbox = (BoundingBox) geom.getModelBound();
- Mesh mesh = geom.getMesh();
-
- VertexBuffer positions = mesh.getBuffer(Type.Position);
- VertexBuffer normals = mesh.getBuffer(Type.Normal);
- VertexBuffer texcoords = mesh.getBuffer(Type.TexCoord);
- VertexBuffer indices = mesh.getBuffer(Type.Index);
-
- // positions
- FloatBuffer fb = (FloatBuffer) positions.getData();
- if (posFmt != Format.Float){
- Buffer newBuf = VertexBuffer.createBuffer(posFmt, positions.getNumComponents(),
- mesh.getVertexCount());
- Transform t = convertPositions(fb, bbox, newBuf);
- t.combineWithParent(geom.getLocalTransform());
- geom.setLocalTransform(t);
-
- VertexBuffer newPosVb = new VertexBuffer(Type.Position);
- newPosVb.setupData(positions.getUsage(),
- positions.getNumComponents(),
- posFmt,
- newBuf);
- mesh.clearBuffer(Type.Position);
- mesh.setBuffer(newPosVb);
- }
-
- // normals, automatically convert to signed byte
- fb = (FloatBuffer) normals.getData();
-
- ByteBuffer bb = BufferUtils.createByteBuffer(fb.capacity());
- convertNormals(fb, bb);
-
- normals = new VertexBuffer(Type.Normal);
- normals.setupData(Usage.Static, 3, Format.Byte, bb);
- normals.setNormalized(true);
- mesh.clearBuffer(Type.Normal);
- mesh.setBuffer(normals);
-
- // texcoords
- fb = (FloatBuffer) texcoords.getData();
- if (tcFmt != Format.Float){
- Buffer newBuf = VertexBuffer.createBuffer(tcFmt,
- texcoords.getNumComponents(),
- mesh.getVertexCount());
- convertTexCoords2D(fb, newBuf);
-
- VertexBuffer newTcVb = new VertexBuffer(Type.TexCoord);
- newTcVb.setupData(texcoords.getUsage(),
- texcoords.getNumComponents(),
- tcFmt,
- newBuf);
- mesh.clearBuffer(Type.TexCoord);
- mesh.setBuffer(newTcVb);
- }
- }
-
- public static void compressIndexBuffer(Mesh mesh){
- int vertCount = mesh.getVertexCount();
- VertexBuffer vb = mesh.getBuffer(Type.Index);
- Format targetFmt;
- if (vb.getFormat() == Format.UnsignedInt && vertCount <= 0xffff){
- if (vertCount <= 256)
- targetFmt = Format.UnsignedByte;
- else
- targetFmt = Format.UnsignedShort;
- }else if (vb.getFormat() == Format.UnsignedShort && vertCount <= 0xff){
- targetFmt = Format.UnsignedByte;
- }else{
- return;
- }
-
- IndexBuffer src = mesh.getIndexBuffer();
- Buffer newBuf = VertexBuffer.createBuffer(targetFmt, vb.getNumComponents(), src.size());
-
- VertexBuffer newVb = new VertexBuffer(Type.Index);
- newVb.setupData(vb.getUsage(), vb.getNumComponents(), targetFmt, newBuf);
- mesh.clearBuffer(Type.Index);
- mesh.setBuffer(newVb);
-
- IndexBuffer dst = mesh.getIndexBuffer();
- for (int i = 0; i < src.size(); i++){
- dst.put(i, src.get(i));
- }
- }
-
- private static void convertToFixed(FloatBuffer input, IntBuffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- input.clear();
- output.clear();
- for (int i = 0; i < input.capacity(); i++){
- output.put( (int) (input.get() * (float)(1<<16)) );
- }
- output.flip();
- }
-
- private static void convertToFloat(IntBuffer input, FloatBuffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- input.clear();
- output.clear();
- for (int i = 0; i < input.capacity(); i++){
- output.put( ((float)input.get() / (float)(1<<16)) );
- }
- output.flip();
- }
-
- private static void convertToUByte(FloatBuffer input, ByteBuffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- input.clear();
- output.clear();
- for (int i = 0; i < input.capacity(); i++){
- output.put( (byte) (input.get() * 255f) );
- }
- output.flip();
- }
-
-
- public static VertexBuffer convertToUByte(VertexBuffer vb){
- FloatBuffer fb = (FloatBuffer) vb.getData();
- ByteBuffer bb = BufferUtils.createByteBuffer(fb.capacity());
- convertToUByte(fb, bb);
-
- VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
- newVb.setupData(vb.getUsage(),
- vb.getNumComponents(),
- Format.UnsignedByte,
- bb);
- newVb.setNormalized(true);
- return newVb;
- }
-
- public static VertexBuffer convertToFixed(VertexBuffer vb){
- if (vb.getFormat() == Format.Int)
- return vb;
-
- FloatBuffer fb = (FloatBuffer) vb.getData();
- IntBuffer ib = BufferUtils.createIntBuffer(fb.capacity());
- convertToFixed(fb, ib);
-
- VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
- newVb.setupData(vb.getUsage(),
- vb.getNumComponents(),
- Format.Int,
- ib);
- return newVb;
- }
-
- public static VertexBuffer convertToFloat(VertexBuffer vb){
- if (vb.getFormat() == Format.Float)
- return vb;
-
- IntBuffer ib = (IntBuffer) vb.getData();
- FloatBuffer fb = BufferUtils.createFloatBuffer(ib.capacity());
- convertToFloat(ib, fb);
-
- VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
- newVb.setupData(vb.getUsage(),
- vb.getNumComponents(),
- Format.Float,
- fb);
- return newVb;
- }
-
- private static void convertNormals(FloatBuffer input, ByteBuffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- input.clear();
- output.clear();
- Vector3f temp = new Vector3f();
- int vertexCount = input.capacity() / 3;
- for (int i = 0; i < vertexCount; i++){
- BufferUtils.populateFromBuffer(temp, input, i);
-
- // offset and scale vector into -128 ... 127
- temp.multLocal(127).addLocal(0.5f, 0.5f, 0.5f);
-
- // quantize
- byte v1 = (byte) temp.getX();
- byte v2 = (byte) temp.getY();
- byte v3 = (byte) temp.getZ();
-
- // store
- output.put(v1).put(v2).put(v3);
- }
- }
-
- private static void convertTexCoords2D(FloatBuffer input, Buffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- input.clear();
- output.clear();
- Vector2f temp = new Vector2f();
- int vertexCount = input.capacity() / 2;
-
- ShortBuffer sb = null;
- IntBuffer ib = null;
-
- if (output instanceof ShortBuffer)
- sb = (ShortBuffer) output;
- else if (output instanceof IntBuffer)
- ib = (IntBuffer) output;
- else
- throw new UnsupportedOperationException();
-
- for (int i = 0; i < vertexCount; i++){
- BufferUtils.populateFromBuffer(temp, input, i);
-
- if (sb != null){
- sb.put( (short) (temp.getX()*Short.MAX_VALUE) );
- sb.put( (short) (temp.getY()*Short.MAX_VALUE) );
- }else{
- int v1 = (int) (temp.getX() * ((float)(1 << 16)));
- int v2 = (int) (temp.getY() * ((float)(1 << 16)));
- ib.put(v1).put(v2);
- }
- }
- }
-
- private static Transform convertPositions(FloatBuffer input, BoundingBox bbox, Buffer output){
- if (output.capacity() < input.capacity())
- throw new RuntimeException("Output must be at least as large as input!");
-
- Vector3f offset = bbox.getCenter().negate();
- Vector3f size = new Vector3f(bbox.getXExtent(), bbox.getYExtent(), bbox.getZExtent());
- size.multLocal(2);
-
- ShortBuffer sb = null;
- ByteBuffer bb = null;
- float dataTypeSize;
- float dataTypeOffset;
- if (output instanceof ShortBuffer){
- sb = (ShortBuffer) output;
- dataTypeOffset = shortOff;
- dataTypeSize = shortSize;
- }else{
- bb = (ByteBuffer) output;
- dataTypeOffset = byteOff;
- dataTypeSize = byteSize;
- }
- Vector3f scale = new Vector3f();
- scale.set(dataTypeSize, dataTypeSize, dataTypeSize).divideLocal(size);
-
- Vector3f invScale = new Vector3f();
- invScale.set(size).divideLocal(dataTypeSize);
-
- offset.multLocal(scale);
- offset.addLocal(dataTypeOffset, dataTypeOffset, dataTypeOffset);
-
- // offset = (-modelOffset * shortSize)/modelSize + shortOff
- // scale = shortSize / modelSize
-
- input.clear();
- output.clear();
- Vector3f temp = new Vector3f();
- int vertexCount = input.capacity() / 3;
- for (int i = 0; i < vertexCount; i++){
- BufferUtils.populateFromBuffer(temp, input, i);
-
- // offset and scale vector into -32768 ... 32767
- // or into -128 ... 127 if using bytes
- temp.multLocal(scale);
- temp.addLocal(offset);
-
- // quantize and store
- if (sb != null){
- short v1 = (short) temp.getX();
- short v2 = (short) temp.getY();
- short v3 = (short) temp.getZ();
- sb.put(v1).put(v2).put(v3);
- }else{
- byte v1 = (byte) temp.getX();
- byte v2 = (byte) temp.getY();
- byte v3 = (byte) temp.getZ();
- bb.put(v1).put(v2).put(v3);
- }
- }
-
- Transform transform = new Transform();
- transform.setTranslation(offset.negate().multLocal(invScale));
- transform.setScale(invScale);
- return transform;
- }
-
-}
diff --git a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
index 5697b713b..f719a04ef 100644
--- a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
+++ b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
@@ -75,10 +75,10 @@ import javax.swing.SwingUtilities;
public class JmeDesktopSystem extends JmeSystemDelegate {
@Override
- public AssetManager newAssetManager(URL configFile) {
- return new DesktopAssetManager(configFile);
+ public String getPlatformAssetConfigPath() {
+ return "com/jme3/asset/Desktop.cfg";
}
-
+
private static BufferedImage verticalFlip(BufferedImage original) {
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
tx.translate(0, -original.getHeight());
@@ -119,17 +119,6 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
}
}
- @Override
- public ImageRaster createImageRaster(Image image, int slice) {
- assert image.getEfficentData() == null;
- return new DefaultImageRaster(image, slice);
- }
-
- @Override
- public AssetManager newAssetManager() {
- return new DesktopAssetManager(null);
- }
-
@Override
public void showErrorDialog(String message) {
final String msg = message;
diff --git a/jme3-ios/src/main/java/com/jme3/asset/IOS.cfg b/jme3-ios/src/main/java/com/jme3/asset/IOS.cfg
new file mode 100644
index 000000000..715eab985
--- /dev/null
+++ b/jme3-ios/src/main/java/com/jme3/asset/IOS.cfg
@@ -0,0 +1,4 @@
+INCLUDE com/jme3/asset/General.cfg
+
+# IOS specific loaders
+LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg
diff --git a/jme3-ios/src/main/java/com/jme3/system/ios/IosAssetManager.java b/jme3-ios/src/main/java/com/jme3/system/ios/IosAssetManager.java
deleted file mode 100644
index 7a8b22067..000000000
--- a/jme3-ios/src/main/java/com/jme3/system/ios/IosAssetManager.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2009-2012 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jme3.system.ios;
-
-import com.jme3.asset.AssetLoader;
-import com.jme3.asset.DesktopAssetManager;
-import com.jme3.asset.TextureKey;
-import com.jme3.asset.plugins.ClasspathLocator;
-import com.jme3.audio.plugins.WAVLoader;
-import com.jme3.texture.Texture;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- * @author normenhansen
- */
-public class IosAssetManager extends DesktopAssetManager {
-
- private static final Logger logger = Logger.getLogger(IosAssetManager.class.getName());
-
- public IosAssetManager() {
- this(null);
- }
-
- @Deprecated
- public IosAssetManager(boolean loadDefaults) {
- //this(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Android.cfg"));
- this(null);
- }
-
- private void registerLoaderSafe(String loaderClass, String ... extensions) {
- try {
- Class extends AssetLoader> loader = (Class extends AssetLoader>) Class.forName(loaderClass);
- registerLoader(loader, extensions);
- } catch (Exception e){
- logger.log(Level.WARNING, "Failed to load AssetLoader", e);
- }
- }
-
- /**
- * AndroidAssetManager constructor
- * If URL == null then a default list of locators and loaders for android is set
- * @param configFile
- */
- public IosAssetManager(URL configFile) {
- System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
-
- // Set Default iOS config
- registerLocator("", ClasspathLocator.class);
-
- registerLoader(IosImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
- //registerLoader(AndroidImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
- //registerLoader(AndroidAudioLoader.class, "ogg", "mp3", "wav");
- registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3m");
- registerLoader(com.jme3.material.plugins.J3MLoader.class, "j3md");
- registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");
- registerLoader(com.jme3.export.binary.BinaryImporter.class, "j3o");
- registerLoader(com.jme3.font.plugins.BitmapFontLoader.class, "fnt");
- registerLoader(WAVLoader.class, "wav");
-
- // Less common loaders (especially on iOS)
- registerLoaderSafe("com.jme3.audio.plugins.OGGLoader", "ogg");
- registerLoaderSafe("com.jme3.texture.plugins.DDSLoader", "dds");
- registerLoaderSafe("com.jme3.texture.plugins.PFMLoader", "pfm");
- registerLoaderSafe("com.jme3.texture.plugins.HDRLoader", "hdr");
- registerLoaderSafe("com.jme3.texture.plugins.TGALoader", "tga");
- registerLoaderSafe("com.jme3.scene.plugins.OBJLoader", "obj");
- registerLoaderSafe("com.jme3.scene.plugins.MTLLoader", "mtl");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.MeshLoader", "mesh.xml");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.SkeletonLoader", "skeleton.xml");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.MaterialLoader", "material");
- registerLoaderSafe("com.jme3.scene.plugins.ogre.SceneLoader", "scene");
-
-
- logger.fine("IosAssetManager created.");
- }
-}
diff --git a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
index b4b7906e1..1ffb097f7 100644
--- a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
+++ b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
@@ -31,17 +31,13 @@
*/
package com.jme3.system.ios;
-import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystemDelegate;
import com.jme3.system.NullContext;
-import com.jme3.texture.Image;
-import com.jme3.texture.image.ImageRaster;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.URL;
import java.nio.ByteBuffer;
import java.util.logging.Logger;
@@ -52,18 +48,13 @@ import java.util.logging.Logger;
public class JmeIosSystem extends JmeSystemDelegate {
@Override
- public void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- @Override
- public AssetManager newAssetManager(URL configFile) {
- return new IosAssetManager(configFile);
+ public String getPlatformAssetConfigPath() {
+ return "com/jme3/asset/IOS.cfg";
}
-
+
@Override
- public AssetManager newAssetManager() {
- return new IosAssetManager();
+ public void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
}
@Override
@@ -106,11 +97,6 @@ public class JmeIosSystem extends JmeSystemDelegate {
// throw new UnsupportedOperationException("Not supported yet.");
}
- @Override
- public ImageRaster createImageRaster(Image image, int slice) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
@Override
public void showSoftKeyboard(boolean show) {
throw new UnsupportedOperationException("Not supported yet.");
diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/file/FBXDump.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/file/FBXDump.java
new file mode 100644
index 000000000..f309a5052
--- /dev/null
+++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/file/FBXDump.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2009-2015 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.scene.plugins.fbx.file;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Array;
+import java.text.DecimalFormat;
+import java.util.HashMap;
+import java.util.Map;
+import static org.omg.IOP.IORHelper.id;
+
+/**
+ * Quick n' dirty dumper of FBX binary files.
+ *
+ * Outputs a format similar to an ASCII FBX file.
+ *
+ * @author Kirill Vainer
+ */
+public final class FBXDump {
+
+ private static final DecimalFormat DECIMAL_FORMAT
+ = new DecimalFormat("0.0000000000");
+
+ private FBXDump() { }
+
+ /**
+ * Creates a map between object UIDs and the objects themselves.
+ *
+ * @param file The file to create the mappings for.
+ * @return The UID to object map.
+ */
+ private static Map\x00\x01
to "::".
+ *
+ * @param string The string to convert
+ * @return
+ */
+ private static String convertFBXString(String string) {
+ return string.replaceAll("\u0000\u0001", "::");
+ }
+
+ protected static void dumpFBXProperty(String id, char propertyType,
+ Object property, PrintStream ps,
+ Map