AndroidHarness
wraps a jme application object and runs it on Android
* @author Kirill
* @author larynx
*/
-public class AndroidHarness extends Activity implements TouchListener, DialogInterface.OnClickListener
-{
+public class AndroidHarness extends Activity implements TouchListener, DialogInterface.OnClickListener {
+
protected final static Logger logger = Logger.getLogger(AndroidHarness.class.getName());
-
/**
* The application class to start
*/
protected String appClass = "jme3test.android.Test";
-
/**
* The jme3 application object
*/
protected Application app = null;
-
/**
* ConfigType.FASTEST is RGB565, GLSurfaceView default
* ConfigType.BEST is RGBA8888 or better if supported by the hardware
*/
protected ConfigType eglConfigType = ConfigType.FASTEST;
-
/**
* If true all valid and not valid egl configs are logged
*/
protected boolean eglConfigVerboseLogging = false;
-
/**
* If true MouseEvents are generated from TouchEvents
*/
- protected boolean mouseEventsEnabled = true;
+ protected boolean mouseEventsEnabled = true;
/**
* Flip X axis
*/
@@ -71,7 +66,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
* Flip Y axis
*/
protected boolean mouseEventsInvertY = true;
-
/**
* Title of the exit dialog, default is "Do you want to exit?"
*/
@@ -80,7 +74,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
* Message of the exit dialog, default is "Use your home key to bring this app into the background or exit to terminate it."
*/
protected String exitDialogMessage = "Use your home key to bring this app into the background or exit to terminate it.";
-
/**
* Set the screen orientation, default is SENSOR
* ActivityInfo.SCREEN_ORIENTATION_* constants
@@ -95,31 +88,27 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
* SCREEN_ORIENTATION_NOSENSOR
*/
protected int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
-
protected OGLESContext ctx;
protected GLSurfaceView view = null;
protected boolean isGLThreadPaused = true;
- final private String ESCAPE_EVENT = "TouchEscape";
+ final private String ESCAPE_EVENT = "TouchEscape";
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+
Logger log = logger;
boolean bIsLogFormatSet = false;
- do
- {
- if (log.getHandlers().length == 0)
- {
+ do {
+ if (log.getHandlers().length == 0) {
log = logger.getParent();
- if (log != null)
- for (Handler h : log.getHandlers())
- {
+ if (log != null) {
+ for (Handler h : log.getHandlers()) {
//h.setFormatter(new SimpleFormatter());
h.setFormatter(new JmeFormatter());
bIsLogFormatSet = true;
}
+ }
}
} while (log != null && !bIsLogFormatSet);
@@ -128,201 +117,172 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
setRequestedOrientation(screenOrientation);
-
+
// Create Settings
AppSettings settings = new AppSettings(true);
-
+
// Create the input class
- AndroidInput input = new AndroidInput(this);
+ AndroidInput input = new AndroidInput(this);
input.setMouseEventsInvertX(mouseEventsInvertX);
input.setMouseEventsInvertY(mouseEventsInvertY);
input.setMouseEventsEnabled(mouseEventsEnabled);
-
+
// Create application instance
- try
- {
- if (app == null)
- {
+ try {
+ if (app == null) {
@SuppressWarnings("unchecked")
Class extends Application> clazz = (Class extends Application>) Class.forName(appClass);
app = clazz.newInstance();
}
-
+
app.setSettings(settings);
- app.start();
+ app.start();
ctx = (OGLESContext) app.getContext();
view = ctx.createView(input, eglConfigType, eglConfigVerboseLogging);
- setContentView(view);
-
+ setContentView(view);
+
// Set the screen reolution
WindowManager wind = this.getWindowManager();
Display disp = wind.getDefaultDisplay();
ctx.getSettings().setResolution(disp.getWidth(), disp.getHeight());
-
- AppSettings s = ctx.getSettings();
- logger.info("Settings: Width " + s.getWidth() + " Height " + s.getHeight());
-
-
- }
- catch (Exception ex)
- {
+
+ AppSettings s = ctx.getSettings();
+ logger.log(Level.INFO, "Settings: Width {0} Height {1}", new Object[]{s.getWidth(), s.getHeight()});
+ } catch (Exception ex) {
handleError("Class " + appClass + " init failed", ex);
setContentView(new TextView(this));
}
-
}
-
@Override
- protected void onRestart()
- {
- super.onRestart();
- if (app != null)
+ protected void onRestart() {
+ super.onRestart();
+ if (app != null) {
app.restart();
+ }
logger.info("onRestart");
}
-
@Override
- protected void onStart()
- {
+ protected void onStart() {
super.onStart();
logger.info("onStart");
}
-
+
@Override
- protected void onResume()
- {
+ protected void onResume() {
super.onResume();
- if (view != null)
+ if (view != null) {
view.onResume();
+ }
isGLThreadPaused = false;
logger.info("onResume");
}
@Override
- protected void onPause()
- {
+ protected void onPause() {
super.onPause();
- if (view != null)
+ if (view != null) {
view.onPause();
+ }
isGLThreadPaused = true;
logger.info("onPause");
}
-
+
@Override
- protected void onStop()
- {
+ protected void onStop() {
super.onStop();
logger.info("onStop");
}
@Override
- protected void onDestroy()
- {
- if (app != null)
- app.stop(! isGLThreadPaused);
- super.onDestroy();
+ protected void onDestroy() {
+ if (app != null) {
+ app.stop(!isGLThreadPaused);
+ }
+ super.onDestroy();
logger.info("onDestroy");
}
- public Application getJmeApplication()
- {
+ public Application getJmeApplication() {
return app;
}
-
+
/**
* Called when an error has occured. This is typically
- * invoked when an uncought exception is thrown in the render thread.
+ * invoked when an uncaught exception is thrown in the render thread.
* @param errorMsg The error message, if any, or null.
* @param t Throwable object, or null.
*/
- public void handleError(final String errorMsg, final Throwable t)
- {
-
- String s = "";
- if (t != null && t.getStackTrace() != null)
- {
- for (StackTraceElement ste: t.getStackTrace())
- {
- s += ste.getClassName() + "." + ste.getMethodName() + "(" + + ste.getLineNumber() + ") ";
+ public void handleError(final String errorMsg, final Throwable t) {
+ String sTrace = "";
+ if (t != null && t.getStackTrace() != null) {
+ for (StackTraceElement ste : t.getStackTrace()) {
+ sTrace += "\tat " + ste.getClassName() + "." + ste.getMethodName() + "(";
+ if (ste.isNativeMethod()){
+ sTrace += "Native";
+ }else{
+ sTrace += ste.getLineNumber();
+ }
+ sTrace += ")\n";
}
- }
-
- final String sTrace = s;
-
- logger.severe(t != null ? t.toString() : "OpenGL Exception");
- logger.severe((errorMsg != null ? errorMsg + ": " : "") + sTrace);
-
+ }
+
+ final String stackTrace = sTrace;
+
+ logger.log(Level.SEVERE, t != null ? t.toString() : "OpenGL Exception");
+ logger.log(Level.SEVERE, "{0}{1}", new Object[]{errorMsg != null ? errorMsg + ": " : "", stackTrace});
+
this.runOnUiThread(new Runnable() {
@Override
- public void run()
- {
- AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this)
- // .setIcon(R.drawable.alert_dialog_icon)
- .setTitle(t != null ? (t.getMessage() != null ? (t.getMessage() + ": " + t.getClass().getName()) : t.getClass().getName()) : "OpenGL Exception")
- .setPositiveButton("Kill", AndroidHarness.this)
- .setMessage((errorMsg != null ? errorMsg + ": " : "") + sTrace)
- .create();
- dialog.show();
+ public void run() {
+ AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
+ .setTitle(t != null ? (t.getMessage() != null ? (t.getMessage() + ": " + t.getClass().getName()) : t.getClass().getName()) : "OpenGL Exception").setPositiveButton("Kill", AndroidHarness.this).setMessage((errorMsg != null ? errorMsg + ": " : "") + stackTrace).create();
+ dialog.show();
}
});
-
+
}
-
+
/**
* Called by the android alert dialog, terminate the activity and OpenGL rendering
* @param dialog
* @param whichButton
*/
- public void onClick(DialogInterface dialog, int whichButton)
- {
- if (whichButton != -2)
- {
- if (app != null)
+ public void onClick(DialogInterface dialog, int whichButton) {
+ if (whichButton != -2) {
+ if (app != null) {
app.stop(true);
+ }
this.finish();
}
}
-
+
/**
* Gets called by the InputManager on all touch/drag/scale events
- */
- @Override
- public void onTouch(String name, TouchEvent evt, float tpf)
- {
- if (name.equals(ESCAPE_EVENT))
- {
- switch(evt.getType())
- {
+ */
+ @Override
+ public void onTouch(String name, TouchEvent evt, float tpf) {
+ if (name.equals(ESCAPE_EVENT)) {
+ switch (evt.getType()) {
case KEY_UP:
- this.runOnUiThread(new Runnable()
- {
+ this.runOnUiThread(new Runnable() {
@Override
- public void run()
- {
- AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this)
- // .setIcon(R.drawable.alert_dialog_icon)
- .setTitle(exitDialogTitle)
- .setPositiveButton("Yes", AndroidHarness.this)
- .setNegativeButton("No", AndroidHarness.this)
- .setMessage(exitDialogMessage)
- .create();
- dialog.show();
+ public void run() {
+ AlertDialog dialog = new AlertDialog.Builder(AndroidHarness.this) // .setIcon(R.drawable.alert_dialog_icon)
+ .setTitle(exitDialogTitle).setPositiveButton("Yes", AndroidHarness.this).setNegativeButton("No", AndroidHarness.this).setMessage(exitDialogMessage).create();
+ dialog.show();
}
});
-
-
+
+ break;
+ default:
break;
-
- default:
- break;
}
}
-
- }
-
+
+ }
}
diff --git a/engine/src/android/com/jme3/asset/AndroidAssetManager.java b/engine/src/android/com/jme3/asset/AndroidAssetManager.java
index 57b7d3516..de70b24a5 100644
--- a/engine/src/android/com/jme3/asset/AndroidAssetManager.java
+++ b/engine/src/android/com/jme3/asset/AndroidAssetManager.java
@@ -29,7 +29,6 @@
* 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.texture.Texture;
@@ -50,14 +49,14 @@ public class AndroidAssetManager extends DesktopAssetManager {
private static final Logger logger = Logger.getLogger(AndroidAssetManager.class.getName());
- public AndroidAssetManager(){
+ public AndroidAssetManager() {
this(null);
}
@Deprecated
- public AndroidAssetManager(boolean loadDefaults){
+ public AndroidAssetManager(boolean loadDefaults) {
//this(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Android.cfg"));
- this(null);
+ this(null);
}
/**
@@ -65,14 +64,13 @@ public class AndroidAssetManager extends DesktopAssetManager {
* 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
- this.registerLocator("", AndroidLocator.class);
+ public AndroidAssetManager(URL configFile) {
+
+ System.setProperty("org.xml.sax.driver", "org.xmlpull.v1.sax2.Driver");
+
+
+ // Set Default Android config
+ this.registerLocator("", AndroidLocator.class);
this.registerLocator("", ClasspathLocator.class);
this.registerLoader(AndroidImageLoader.class, "jpg", "bmp", "gif", "png", "jpeg");
this.registerLoader(AndroidAudioLoader.class, "ogg", "mp3");
@@ -91,8 +89,8 @@ public class AndroidAssetManager extends DesktopAssetManager {
this.registerLoader(com.jme3.scene.plugins.ogre.MaterialLoader.class, "material");
this.registerLoader(com.jme3.scene.plugins.ogre.SceneLoader.class, "scene");
this.registerLoader(com.jme3.shader.plugins.GLSLLoader.class, "vert", "frag", "glsl", "glsllib");
-
-
+
+
logger.info("AndroidAssetManager created.");
}
@@ -102,18 +100,17 @@ public class AndroidAssetManager extends DesktopAssetManager {
* @return
*/
@Override
- public Texture loadTexture(TextureKey key){
- Texture tex = (Texture) loadAsset(key);
-
- // Needed for Android
+ public Texture loadTexture(TextureKey key) {
+ Texture tex = (Texture) loadAsset(key);
+
+ // Needed for Android
tex.setMagFilter(Texture.MagFilter.Nearest);
tex.setAnisotropicFilter(0);
- if (tex.getMinFilter().usesMipMapLevels()){
+ if (tex.getMinFilter().usesMipMapLevels()) {
tex.setMinFilter(Texture.MinFilter.NearestNearestMipMap);
- }else{
+ } else {
tex.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
}
- return tex;
+ return tex;
}
-
}
diff --git a/engine/src/android/com/jme3/system/JmeSystem.java b/engine/src/android/com/jme3/system/JmeSystem.java
index a7481e975..a173e5437 100644
--- a/engine/src/android/com/jme3/system/JmeSystem.java
+++ b/engine/src/android/com/jme3/system/JmeSystem.java
@@ -1,6 +1,5 @@
package com.jme3.system;
-
import android.app.Activity;
import android.content.res.Resources;
import com.jme3.util.AndroidLogHandler;
@@ -24,172 +23,96 @@ import java.util.logging.Logger;
import java.net.URL;
-
-
-public class JmeSystem
-{
-
- public static enum Platform {
-
- /**
- * Microsoft Windows 32 bit
- */
- Windows32,
-
- /**
- * Microsoft Windows 64 bit
- */
- Windows64,
-
- /**
- * Linux 32 bit
- */
- Linux32,
-
-
- /**
- * Linux 64 bit
- */
- Linux64,
-
- /**
- * Apple Mac OS X 32 bit
- */
- MacOSX32,
-
- /**
- * Apple Mac OS X 64 bit
- */
- MacOSX64,
-
- /**
- * Apple Mac OS X 32 bit PowerPC
- */
- MacOSX_PPC32,
-
- /**
- * Apple Mac OS X 64 bit PowerPC
- */
- MacOSX_PPC64,
-
- /**
- * Android 2.2
- */
- Android_Froyo,
-
- /**
- * Android 2.3
- */
- Android_Gingerbread,
-
- /**
- * Android 3.0
- */
- Android_Honeycomb,
-
-
- }
+public class JmeSystem {
private static final Logger logger = Logger.getLogger(JmeSystem.class.getName());
-
private static boolean initialized = false;
private static boolean lowPermissions = false;
private static Resources res;
private static Activity activity;
- public static void initialize(AppSettings settings)
- {
-
- if (initialized)
+ public static void initialize(AppSettings settings) {
+ if (initialized) {
return;
+ }
initialized = true;
- try
- {
+ try {
JmeFormatter formatter = new JmeFormatter();
Handler consoleHandler = new AndroidLogHandler();
consoleHandler.setFormatter(formatter);
- }
- catch (SecurityException ex)
- {
+ } catch (SecurityException ex) {
logger.log(Level.SEVERE, "Security error in creating log file", ex);
}
- logger.info("Running on "+getFullName());
+ logger.log(Level.INFO, "Running on {0}", getFullName());
}
- public static String getFullName()
- {
- return "jMonkey Engine 3 ALPHA 0.7 Android";
+ public static String getFullName() {
+ return "jMonkeyEngine 3.0.0 Beta (Android)";
}
-
- public static void setLowPermissions(boolean lowPerm)
- {
+
+ public static void setLowPermissions(boolean lowPerm) {
lowPermissions = lowPerm;
}
- public static boolean isLowPermissions()
- {
+ public static boolean isLowPermissions() {
return lowPermissions;
}
-
- public static JmeContext newContext(AppSettings settings, Type contextType)
- {
+
+ public static JmeContext newContext(AppSettings settings, Type contextType) {
initialize(settings);
return new OGLESContext();
}
- public static AudioRenderer newAudioRenderer(AppSettings settings)
- {
- return new AndroidAudioRenderer(activity);
+ public static AudioRenderer newAudioRenderer(AppSettings settings) {
+ return new AndroidAudioRenderer(activity);
}
- public static void setResources(Resources res)
- {
+ public static void setResources(Resources res) {
JmeSystem.res = res;
}
- public static Resources getResources()
- {
+ public static Resources getResources() {
return res;
}
- public static void setActivity(Activity activity)
- {
+ public static void setActivity(Activity activity) {
JmeSystem.activity = activity;
}
- public static Activity getActivity()
- {
+ public static Activity getActivity() {
return activity;
- }
-
+ }
- public static AssetManager newAssetManager()
- {
- logger.info("newAssetManager()");
+ public static AssetManager newAssetManager() {
+ logger.log(Level.INFO, "newAssetManager()");
return new AndroidAssetManager(null);
}
- public static AssetManager newAssetManager(URL url)
- {
- logger.info("newAssetManager(" + url + ")");
+ public static AssetManager newAssetManager(URL url) {
+ logger.log(Level.INFO, "newAssetManager({0})", url);
return new AndroidAssetManager(url);
}
- public static boolean showSettingsDialog(AppSettings settings, boolean loadSettings)
- {
+ public static boolean showSettingsDialog(AppSettings settings, boolean loadSettings) {
return true;
}
-
- public static Platform getPlatform()
- {
- String os = System.getProperty("os.name").toLowerCase();
- String arch = System.getProperty("os.arch").toLowerCase();
- return Platform.Android_Froyo;
- // throw new UnsupportedOperationException("The specified platform: "+os+" is not supported.");
-
+ public static Platform getPlatform() {
+ String arch = System.getProperty("os.arch").toLowerCase();
+ if (arch.contains("arm")){
+ if (arch.contains("v5")){
+ return Platform.Android_ARM5;
+ }else if (arch.contains("v6")){
+ return Platform.Android_ARM6;
+ }else if (arch.contains("v7")){
+ return Platform.Android_ARM7;
+ }else{
+ return Platform.Android_ARM5; // unknown ARM
+ }
+ }else{
+ throw new UnsupportedOperationException("Unsupported Android Platform");
+ }
}
-
}
diff --git a/engine/src/android/com/jme3/texture/plugins/AndroidImageLoader.java b/engine/src/android/com/jme3/texture/plugins/AndroidImageLoader.java
index 1e7c8b518..3718ad989 100644
--- a/engine/src/android/com/jme3/texture/plugins/AndroidImageLoader.java
+++ b/engine/src/android/com/jme3/texture/plugins/AndroidImageLoader.java
@@ -14,37 +14,35 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
-public class AndroidImageLoader implements AssetLoader
-{
+public class AndroidImageLoader implements AssetLoader {
- public Object load2(AssetInfo info) throws IOException
- {
+ public Object load2(AssetInfo info) throws IOException {
ByteBuffer bb = BufferUtils.createByteBuffer(1 * 1 * 2);
- bb.put( (byte) 0xff ).put( (byte) 0xff );
+ bb.put((byte) 0xff).put((byte) 0xff);
bb.clear();
return new Image(Format.RGB5A1, 1, 1, bb);
}
- public Object load(AssetInfo info) throws IOException
- {
+ public Object load(AssetInfo info) throws IOException {
InputStream in = null;
Bitmap bitmap = null;
try {
in = info.openStream();
bitmap = BitmapFactory.decodeStream(in);
- if (bitmap == null){
- throw new IOException("Failed to load image: "+info.getKey().getName());
+ if (bitmap == null) {
+ throw new IOException("Failed to load image: " + info.getKey().getName());
}
} finally {
- if (in != null)
+ if (in != null) {
in.close();
+ }
}
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Format fmt;
- switch (bitmap.getConfig()){
+ switch (bitmap.getConfig()) {
case ALPHA_8:
fmt = Format.Alpha8;
break;
@@ -54,15 +52,14 @@ public class AndroidImageLoader implements AssetLoader
case ARGB_8888:
fmt = Format.RGBA8;
break;
- case RGB_565:
+ case RGB_565:
fmt = Format.RGB565;
break;
default:
return null;
}
- if ( ((TextureKey)info.getKey()).isFlipY() )
- {
+ if (((TextureKey) info.getKey()).isFlipY()) {
Bitmap newBitmap = null;
Matrix flipMat = new Matrix();
flipMat.preScale(1.0f, -1.0f);
@@ -70,14 +67,13 @@ public class AndroidImageLoader implements AssetLoader
bitmap.recycle();
bitmap = newBitmap;
- if (bitmap == null){
- throw new IOException("Failed to flip image: "+info.getKey().getName());
+ if (bitmap == null) {
+ throw new IOException("Failed to flip image: " + info.getKey().getName());
}
}
Image image = new Image(fmt, width, height, null);
- image.setEfficentData(bitmap);
+ image.setEfficentData(bitmap);
return image;
}
-
}
diff --git a/engine/src/android/com/jme3/util/RingBuffer.java b/engine/src/android/com/jme3/util/RingBuffer.java
index cd6393cc8..786417b04 100644
--- a/engine/src/android/com/jme3/util/RingBuffer.java
+++ b/engine/src/android/com/jme3/util/RingBuffer.java
@@ -8,33 +8,39 @@ import java.util.NoSuchElementException;
*/
// suppress unchecked warnings in Java 1.5.0_6 and later
@SuppressWarnings("unchecked")
-public class RingBufferAndroidSkyFactory
creates a sky box spatial
* @author larynx, derived from SkyFactory and adapted for android
- *
+ * @deprecated Use {@link SkyFactory} instead
*/
-public class AndroidSkyFactory
-{
- private static final Sphere sphereMesh = new Sphere(10, 10, 101f, false, true);
-
- public static Spatial createSky(AssetManager assetManager, Texture texture, Vector3f normalScale, boolean sphereMap)
- {
- Geometry sky = new Geometry("Sky", sphereMesh);
- sky.setQueueBucket(Bucket.Sky);
- sky.setCullHint(Spatial.CullHint.Never);
-
- Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
- skyMat.setVector3("NormalScale", normalScale);
- if (sphereMap)
- {
- skyMat.setBoolean("SphereMap", sphereMap);
- }
- else if (!(texture instanceof TextureCubeMap))
- {
- // make sure its a cubemap
- Image img = texture.getImage();
- texture = new TextureCubeMap();
- texture.setImage(img);
- }
- skyMat.setTexture("Texture", texture);
- sky.setMaterial(skyMat);
-
- return sky;
- }
-
- private static void checkImage(Image image)
- {
- if (image.getWidth() != image.getHeight())
- throw new IllegalArgumentException("Image width and height must be the same");
-
- if (image.getMultiSamples() != 1)
- throw new IllegalArgumentException("Multisample textures not allowed");
- }
-
- private static void checkImagesForCubeMap(Image ... images)
- {
- if (images.length == 1) return;
-
- Format fmt = images[0].getFormat();
- int width = images[0].getWidth();
- int height = images[0].getHeight();
+@Deprecated
+public class AndroidSkyFactory {
- checkImage(images[0]);
-
- for (int i = 1; i < images.length; i++)
- {
- Image image = images[i];
- checkImage(images[i]);
- if (image.getFormat() != fmt) throw new IllegalArgumentException("Images must have same format");
- if (image.getWidth() != width) throw new IllegalArgumentException("Images must have same width");
- if (image.getHeight() != height) throw new IllegalArgumentException("Images must have same height");
- }
+ public static Spatial createSky(AssetManager assetManager, Texture texture, Vector3f normalScale, boolean sphereMap) {
+ return SkyFactory.createSky(assetManager, texture, normalScale, sphereMap);
}
- public static Spatial createSky(AssetManager assetManager, Texture west, Texture east, Texture north, Texture south,
- Texture up, Texture down, Vector3f normalScale)
- {
- Geometry sky = new Geometry("Sky", sphereMesh);
- sky.setQueueBucket(Bucket.Sky);
- sky.setCullHint(Spatial.CullHint.Never);
-
- Image westImg = west.getImage();
- Image eastImg = east.getImage();
- Image northImg = north.getImage();
- Image southImg = south.getImage();
- Image upImg = up.getImage();
- Image downImg = down.getImage();
-
- checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);
-
- Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null);
-
- ArrayList
- * Note: if either QUARTER_CIRCLE or TABLE_SHIFT is changed this value
- * will need recalculating (put the above formular into a calculator set
- * radians, then shift the result by TABLE_SHIFT
).
- */
- private static final int SIN_PRECALC = 26350943;
-
- /**
- * Equivalent to: cos((2 * PI) / (QUARTER_CIRCLE * 4)) * 2
- *
- * Note: if either QUARTER_CIRCLE or TABLE_SHIFT is changed this value
- * will need recalculating ((put the above formular into a calculator set
- * radians, then shift the result by TABLE_SHIFT
).
- */
- private static final int COS_PRECALC = 2146836866;
-
- /**
- * One quarter sine wave as fixed point values.
- */
- private static final int[] SINE_TABLE = new int[QUARTER_CIRCLE + 1];
-
- /**
- * Scale value for indexing ATAN_TABLE[].
- */
- private static final int ATAN_SHIFT;
-
- /**
- * Reverse atan lookup table.
- */
- private static final byte[] ATAN_TABLE;
-
- /**
- * ATAN_TABLE.length
- */
- private static final int ATAN_TABLE_LEN;
-
- /*
- * Generates the tables and fills in any remaining static ints.
- */
- static {
- // Generate the sine table using recursive synthesis.
- SINE_TABLE[0] = 0;
- SINE_TABLE[1] = SIN_PRECALC;
- for (int n = 2; n < QUARTER_CIRCLE + 1; n++) {
- SINE_TABLE[n] = (int) (((long) SINE_TABLE[n - 1] * COS_PRECALC) >> TABLE_SHIFT) - SINE_TABLE[n - 2];
- }
- // Scale the values to the fixed point format used.
- for (int n = 0; n < QUARTER_CIRCLE + 1; n++) {
- SINE_TABLE[n] = SINE_TABLE[n] + (1 << (TABLE_SHIFT - FIXED_POINT - 1)) >> TABLE_SHIFT - FIXED_POINT;
- }
-
- // Calculate a shift used to scale atan lookups
- int rotl = 0;
- int tan0 = tan(0);
- int tan1 = tan(1);
- while (rotl < 32) {
- if ((tan1 >>= 1) > (tan0 >>= 1)) {
- rotl++;
- } else {
- break;
- }
- }
- ATAN_SHIFT = rotl;
- // Create the a table of tan values
- int[] lut = new int[QUARTER_CIRCLE];
- for (int n = 0; n < QUARTER_CIRCLE; n++) {
- lut[n] = tan(n) >> rotl;
- }
- ATAN_TABLE_LEN = lut[QUARTER_CIRCLE - 1];
- // Then from the tan values create a reverse lookup
- ATAN_TABLE = new byte[ATAN_TABLE_LEN];
- for (byte n = 0; n < QUARTER_CIRCLE - 1; n++) {
- int min = lut[n ];
- int max = lut[n + 1];
- for (int i = min; i < max; i++) {
- ATAN_TABLE[i] = n;
- }
- }
- }
-
- /**
- * How many decimal places to use when converting a fixed point value to
- * a decimal string.
- *
- * @see #toString
- */
- private static final int STRING_DECIMAL_PLACES = 2;
-
- /**
- * Value to add in order to round down a fixed point number when
- * converting to a string.
- */
- private static final int STRING_DECIMAL_PLACES_ROUND;
- static {
- int i = 10;
- for (int n = 1; n < STRING_DECIMAL_PLACES; n++) {
- i *= i;
- }
- if (STRING_DECIMAL_PLACES == 0) {
- STRING_DECIMAL_PLACES_ROUND = ONE / 2;
- } else {
- STRING_DECIMAL_PLACES_ROUND = ONE / (2 * i);
- }
- }
+ /**
+ * Number of bits used for 'fraction'.
+ */
+ public static final int FIXED_POINT = 16;
+ /**
+ * Decimal one as represented by the Fixed class.
+ */
+ public static final int ONE = 1 << FIXED_POINT;
+ /**
+ * Half in fixed point.
+ */
+ public static final int HALF = ONE >> 1;
+ /**
+ * Quarter circle resolution for trig functions (should be a power of
+ * two). This is the number of discrete steps in 90 degrees.
+ */
+ public static final int QUARTER_CIRCLE = 64;
+ /**
+ * Mask used to limit angles to one revolution. If a quarter circle is 64
+ * (i.e. 90 degrees is broken into 64 steps) then the mask is 255.
+ */
+ public static final int FULL_CIRCLE_MASK = QUARTER_CIRCLE * 4 - 1;
+ /**
+ * The trig table is generated at a higher precision than the typical
+ * 16.16 format used for the rest of the fixed point maths. The table
+ * values are then shifted to match the actual fixed point used.
+ */
+ private static final int TABLE_SHIFT = 30;
+ /**
+ * Equivalent to: sin((2 * PI) / (QUARTER_CIRCLE * 4))
+ *
+ * Note: if either QUARTER_CIRCLE or TABLE_SHIFT is changed this value
+ * will need recalculating (put the above formular into a calculator set
+ * radians, then shift the result by TABLE_SHIFT
).
+ */
+ private static final int SIN_PRECALC = 26350943;
+ /**
+ * Equivalent to: cos((2 * PI) / (QUARTER_CIRCLE * 4)) * 2
+ *
+ * Note: if either QUARTER_CIRCLE or TABLE_SHIFT is changed this value
+ * will need recalculating ((put the above formular into a calculator set
+ * radians, then shift the result by TABLE_SHIFT
).
+ */
+ private static final int COS_PRECALC = 2146836866;
+ /**
+ * One quarter sine wave as fixed point values.
+ */
+ private static final int[] SINE_TABLE = new int[QUARTER_CIRCLE + 1];
+ /**
+ * Scale value for indexing ATAN_TABLE[].
+ */
+ private static final int ATAN_SHIFT;
+ /**
+ * Reverse atan lookup table.
+ */
+ private static final byte[] ATAN_TABLE;
+ /**
+ * ATAN_TABLE.length
+ */
+ private static final int ATAN_TABLE_LEN;
- /**
- * Random number generator. The standard java.utll.Random
is
- * used since it is available to both J2ME and J2SE. If a guaranteed
- * sequence is required this would not be adequate.
- */
- private static Random rng = null;
+ /*
+ * Generates the tables and fills in any remaining static ints.
+ */
+ static {
+ // Generate the sine table using recursive synthesis.
+ SINE_TABLE[0] = 0;
+ SINE_TABLE[1] = SIN_PRECALC;
+ for (int n = 2; n < QUARTER_CIRCLE + 1; n++) {
+ SINE_TABLE[n] = (int) (((long) SINE_TABLE[n - 1] * COS_PRECALC) >> TABLE_SHIFT) - SINE_TABLE[n - 2];
+ }
+ // Scale the values to the fixed point format used.
+ for (int n = 0; n < QUARTER_CIRCLE + 1; n++) {
+ SINE_TABLE[n] = SINE_TABLE[n] + (1 << (TABLE_SHIFT - FIXED_POINT - 1)) >> TABLE_SHIFT - FIXED_POINT;
+ }
+
+ // Calculate a shift used to scale atan lookups
+ int rotl = 0;
+ int tan0 = tan(0);
+ int tan1 = tan(1);
+ while (rotl < 32) {
+ if ((tan1 >>= 1) > (tan0 >>= 1)) {
+ rotl++;
+ } else {
+ break;
+ }
+ }
+ ATAN_SHIFT = rotl;
+ // Create the a table of tan values
+ int[] lut = new int[QUARTER_CIRCLE];
+ for (int n = 0; n < QUARTER_CIRCLE; n++) {
+ lut[n] = tan(n) >> rotl;
+ }
+ ATAN_TABLE_LEN = lut[QUARTER_CIRCLE - 1];
+ // Then from the tan values create a reverse lookup
+ ATAN_TABLE = new byte[ATAN_TABLE_LEN];
+ for (byte n = 0; n < QUARTER_CIRCLE - 1; n++) {
+ int min = lut[n];
+ int max = lut[n + 1];
+ for (int i = min; i < max; i++) {
+ ATAN_TABLE[i] = n;
+ }
+ }
+ }
+ /**
+ * How many decimal places to use when converting a fixed point value to
+ * a decimal string.
+ *
+ * @see #toString
+ */
+ private static final int STRING_DECIMAL_PLACES = 2;
+ /**
+ * Value to add in order to round down a fixed point number when
+ * converting to a string.
+ */
+ private static final int STRING_DECIMAL_PLACES_ROUND;
+
+ static {
+ int i = 10;
+ for (int n = 1; n < STRING_DECIMAL_PLACES; n++) {
+ i *= i;
+ }
+ if (STRING_DECIMAL_PLACES == 0) {
+ STRING_DECIMAL_PLACES_ROUND = ONE / 2;
+ } else {
+ STRING_DECIMAL_PLACES_ROUND = ONE / (2 * i);
+ }
+ }
+ /**
+ * Random number generator. The standard java.utll.Random
is
+ * used since it is available to both J2ME and J2SE. If a guaranteed
+ * sequence is required this would not be adequate.
+ */
+ private static Random rng = null;
- /**
- * Fixed can't be instantiated.
- */
- private Fixed() {}
+ /**
+ * Fixed can't be instantiated.
+ */
+ private Fixed() {
+ }
- /**
- * Returns an integer as a fixed point value.
- */
- public static int intToFixed(int n) {
- return n << FIXED_POINT;
- }
+ /**
+ * Returns an integer as a fixed point value.
+ */
+ public static int intToFixed(int n) {
+ return n << FIXED_POINT;
+ }
/**
* Returns a fixed point value as a float.
*/
public static float fixedToFloat(int i) {
float fp = i;
- fp = fp / ((float)ONE);
+ fp = fp / ((float) ONE);
return fp;
}
/**
* Returns a float as a fixed point value.
*/
- public static int floatToFixed(float fp){
+ public static int floatToFixed(float fp) {
return (int) (fp * ((float) ONE));
}
- /**
- * Converts a fixed point value into a decimal string.
- */
- public static String toString(int n) {
- StringBuffer sb = new StringBuffer(16);
- sb.append((n += STRING_DECIMAL_PLACES_ROUND) >> FIXED_POINT);
- sb.append('.');
- n &= ONE - 1;
- for (int i = 0; i < STRING_DECIMAL_PLACES; i++) {
- n *= 10;
- sb.append((n / ONE) % 10);
- }
- return sb.toString();
- }
+ /**
+ * Converts a fixed point value into a decimal string.
+ */
+ public static String toString(int n) {
+ StringBuffer sb = new StringBuffer(16);
+ sb.append((n += STRING_DECIMAL_PLACES_ROUND) >> FIXED_POINT);
+ sb.append('.');
+ n &= ONE - 1;
+ for (int i = 0; i < STRING_DECIMAL_PLACES; i++) {
+ n *= 10;
+ sb.append((n / ONE) % 10);
+ }
+ return sb.toString();
+ }
- /**
- * Multiplies two fixed point values and returns the result.
- */
- public static int mul(int a, int b) {
- return (int) ((long) a * (long) b >> FIXED_POINT);
- }
+ /**
+ * Multiplies two fixed point values and returns the result.
+ */
+ public static int mul(int a, int b) {
+ return (int) ((long) a * (long) b >> FIXED_POINT);
+ }
- /**
- * Divides two fixed point values and returns the result.
- */
- public static int div(int a, int b) {
- return (int) (((long) a << FIXED_POINT * 2) / (long) b >> FIXED_POINT);
- }
+ /**
+ * Divides two fixed point values and returns the result.
+ */
+ public static int div(int a, int b) {
+ return (int) (((long) a << FIXED_POINT * 2) / (long) b >> FIXED_POINT);
+ }
- /**
- * Sine of an angle.
- *
- * @see #QUARTER_CIRCLE
- */
- public static int sin(int n) {
- n &= FULL_CIRCLE_MASK;
- if (n < QUARTER_CIRCLE * 2) {
- if (n < QUARTER_CIRCLE) {
- return SINE_TABLE[n];
- } else {
- return SINE_TABLE[QUARTER_CIRCLE * 2 - n];
- }
- } else {
- if (n < QUARTER_CIRCLE * 3) {
- return -SINE_TABLE[n - QUARTER_CIRCLE * 2];
- } else {
- return -SINE_TABLE[QUARTER_CIRCLE * 4 - n];
- }
- }
- }
+ /**
+ * Sine of an angle.
+ *
+ * @see #QUARTER_CIRCLE
+ */
+ public static int sin(int n) {
+ n &= FULL_CIRCLE_MASK;
+ if (n < QUARTER_CIRCLE * 2) {
+ if (n < QUARTER_CIRCLE) {
+ return SINE_TABLE[n];
+ } else {
+ return SINE_TABLE[QUARTER_CIRCLE * 2 - n];
+ }
+ } else {
+ if (n < QUARTER_CIRCLE * 3) {
+ return -SINE_TABLE[n - QUARTER_CIRCLE * 2];
+ } else {
+ return -SINE_TABLE[QUARTER_CIRCLE * 4 - n];
+ }
+ }
+ }
- /**
- * Cosine of an angle.
- *
- * @see #QUARTER_CIRCLE
- */
- public static int cos(int n) {
- n &= FULL_CIRCLE_MASK;
- if (n < QUARTER_CIRCLE * 2) {
- if (n < QUARTER_CIRCLE) {
- return SINE_TABLE[QUARTER_CIRCLE - n];
- } else {
- return -SINE_TABLE[n - QUARTER_CIRCLE];
- }
- } else {
- if (n < QUARTER_CIRCLE * 3) {
- return -SINE_TABLE[QUARTER_CIRCLE * 3 - n];
- } else {
- return SINE_TABLE[n - QUARTER_CIRCLE * 3];
- }
- }
- }
+ /**
+ * Cosine of an angle.
+ *
+ * @see #QUARTER_CIRCLE
+ */
+ public static int cos(int n) {
+ n &= FULL_CIRCLE_MASK;
+ if (n < QUARTER_CIRCLE * 2) {
+ if (n < QUARTER_CIRCLE) {
+ return SINE_TABLE[QUARTER_CIRCLE - n];
+ } else {
+ return -SINE_TABLE[n - QUARTER_CIRCLE];
+ }
+ } else {
+ if (n < QUARTER_CIRCLE * 3) {
+ return -SINE_TABLE[QUARTER_CIRCLE * 3 - n];
+ } else {
+ return SINE_TABLE[n - QUARTER_CIRCLE * 3];
+ }
+ }
+ }
- /**
- * Tangent of an angle.
- *
- * @see #QUARTER_CIRCLE
- */
- public static int tan(int n) {
- return div(sin(n), cos(n));
- }
+ /**
+ * Tangent of an angle.
+ *
+ * @see #QUARTER_CIRCLE
+ */
+ public static int tan(int n) {
+ return div(sin(n), cos(n));
+ }
- /**
- * Returns the arc tangent of an angle.
- */
- public static int atan(int n) {
- n = n + (1 << (ATAN_SHIFT - 1)) >> ATAN_SHIFT;
- if (n < 0) {
- if (n <= -ATAN_TABLE_LEN) {
- return -(QUARTER_CIRCLE - 1);
- }
- return -ATAN_TABLE[-n];
- } else {
- if (n >= ATAN_TABLE_LEN) {
- return QUARTER_CIRCLE - 1;
- }
- return ATAN_TABLE[n];
- }
- }
+ /**
+ * Returns the arc tangent of an angle.
+ */
+ public static int atan(int n) {
+ n = n + (1 << (ATAN_SHIFT - 1)) >> ATAN_SHIFT;
+ if (n < 0) {
+ if (n <= -ATAN_TABLE_LEN) {
+ return -(QUARTER_CIRCLE - 1);
+ }
+ return -ATAN_TABLE[-n];
+ } else {
+ if (n >= ATAN_TABLE_LEN) {
+ return QUARTER_CIRCLE - 1;
+ }
+ return ATAN_TABLE[n];
+ }
+ }
- /**
- * Returns the polar angle of a rectangular coordinate.
- */
- public static int atan(int x, int y) {
- int n = atan(div(x, abs(y) + 1)); // kludge to prevent ArithmeticException
- if (y > 0) {
- return n;
- }
- if (y < 0) {
- if (x < 0) {
- return -QUARTER_CIRCLE * 2 - n;
- }
- if (x > 0) {
- return QUARTER_CIRCLE * 2 - n;
- }
- return QUARTER_CIRCLE * 2;
- }
- if (x > 0) {
- return QUARTER_CIRCLE;
- }
- return -QUARTER_CIRCLE;
- }
+ /**
+ * Returns the polar angle of a rectangular coordinate.
+ */
+ public static int atan(int x, int y) {
+ int n = atan(div(x, abs(y) + 1)); // kludge to prevent ArithmeticException
+ if (y > 0) {
+ return n;
+ }
+ if (y < 0) {
+ if (x < 0) {
+ return -QUARTER_CIRCLE * 2 - n;
+ }
+ if (x > 0) {
+ return QUARTER_CIRCLE * 2 - n;
+ }
+ return QUARTER_CIRCLE * 2;
+ }
+ if (x > 0) {
+ return QUARTER_CIRCLE;
+ }
+ return -QUARTER_CIRCLE;
+ }
- /**
- * Rough calculation of the hypotenuse. Whilst not accurate it is very fast.
- *
- * Derived from a piece in Graphics Gems. - */ - public static int hyp(int x1, int y1, int x2, int y2) { - if ((x2 -= x1) < 0) { - x2 = -x2; - } - if ((y2 -= y1) < 0) { - y2 = -y2; - } - return x2 + y2 - (((x2 > y2) ? y2 : x2) >> 1); - } + /** + * Rough calculation of the hypotenuse. Whilst not accurate it is very fast. + *
+ * Derived from a piece in Graphics Gems. + */ + public static int hyp(int x1, int y1, int x2, int y2) { + if ((x2 -= x1) < 0) { + x2 = -x2; + } + if ((y2 -= y1) < 0) { + y2 = -y2; + } + return x2 + y2 - (((x2 > y2) ? y2 : x2) >> 1); + } - /** - * Fixed point square root. - *
- * Derived from a 1993 Usenet algorithm posted by Christophe Meessen. - */ - public static int sqrt(int n) { - if (n <= 0) { - return 0; - } - long sum = 0; - int bit = 0x40000000; - while (bit >= 0x100) { // lower values give more accurate results - long tmp = sum | bit; - if (n >= tmp) { - n -= tmp; - sum = tmp + bit; - } - bit >>= 1; - n <<= 1; - } - return (int) (sum >> 16 - (FIXED_POINT / 2)); - } + /** + * Fixed point square root. + *
+ * Derived from a 1993 Usenet algorithm posted by Christophe Meessen.
+ */
+ public static int sqrt(int n) {
+ if (n <= 0) {
+ return 0;
+ }
+ long sum = 0;
+ int bit = 0x40000000;
+ while (bit >= 0x100) { // lower values give more accurate results
+ long tmp = sum | bit;
+ if (n >= tmp) {
+ n -= tmp;
+ sum = tmp + bit;
+ }
+ bit >>= 1;
+ n <<= 1;
+ }
+ return (int) (sum >> 16 - (FIXED_POINT / 2));
+ }
- /**
- * Returns the absolute value.
- */
- public static int abs(int n) {
- return (n < 0) ? -n : n;
- }
+ /**
+ * Returns the absolute value.
+ */
+ public static int abs(int n) {
+ return (n < 0) ? -n : n;
+ }
- /**
- * Returns the sign of a value, -1 for negative numbers, otherwise 1.
- */
- public static int sgn(int n) {
- return (n < 0) ? -1 : 1;
- }
+ /**
+ * Returns the sign of a value, -1 for negative numbers, otherwise 1.
+ */
+ public static int sgn(int n) {
+ return (n < 0) ? -1 : 1;
+ }
- /**
- * Returns the minimum of two values.
- */
- public static int min(int a, int b) {
- return (a < b) ? a : b;
- }
+ /**
+ * Returns the minimum of two values.
+ */
+ public static int min(int a, int b) {
+ return (a < b) ? a : b;
+ }
- /**
- * Returns the maximum of two values.
- */
- public static int max(int a, int b) {
- return (a > b) ? a : b;
- }
+ /**
+ * Returns the maximum of two values.
+ */
+ public static int max(int a, int b) {
+ return (a > b) ? a : b;
+ }
- /**
- * Clamps the value n between min and max.
- */
- public static int clamp(int n, int min, int max) {
- return (n < min) ? min : (n > max) ? max : n;
- }
+ /**
+ * Clamps the value n between min and max.
+ */
+ public static int clamp(int n, int min, int max) {
+ return (n < min) ? min : (n > max) ? max : n;
+ }
- /**
- * Wraps the value n between 0 and the required limit.
- */
- public static int wrap(int n, int limit) {
- return ((n %= limit) < 0) ? limit + n : n;
- }
+ /**
+ * Wraps the value n between 0 and the required limit.
+ */
+ public static int wrap(int n, int limit) {
+ return ((n %= limit) < 0) ? limit + n : n;
+ }
- /**
- * Returns the nearest int to a fixed point value. Equivalent to
- * Math.round()
in the standard library.
- */
- public static int round(int n) {
- return n + HALF >> FIXED_POINT;
- }
+ /**
+ * Returns the nearest int to a fixed point value. Equivalent to
+ * Math.round()
in the standard library.
+ */
+ public static int round(int n) {
+ return n + HALF >> FIXED_POINT;
+ }
- /**
- * Returns the nearest int rounded down from a fixed point value.
- * Equivalent to Math.floor()
in the standard library.
- */
- public static int floor(int n) {
- return n >> FIXED_POINT;
- }
+ /**
+ * Returns the nearest int rounded down from a fixed point value.
+ * Equivalent to Math.floor()
in the standard library.
+ */
+ public static int floor(int n) {
+ return n >> FIXED_POINT;
+ }
- /**
- * Returns the nearest int rounded up from a fixed point value.
- * Equivalent to Math.ceil()
in the standard library.
- */
- public static int ceil(int n) {
- return n + (ONE - 1) >> FIXED_POINT;
- }
+ /**
+ * Returns the nearest int rounded up from a fixed point value.
+ * Equivalent to Math.ceil()
in the standard library.
+ */
+ public static int ceil(int n) {
+ return n + (ONE - 1) >> FIXED_POINT;
+ }
- /**
- * Returns a fixed point value greater than or equal to decimal 0.0 and
- * less than 1.0 (in 16.16 format this would be 0 to 65535 inclusive).
- */
- public static int rand() {
- if (rng == null) {
- rng = new Random();
- }
- return rng.nextInt() >>> (32 - FIXED_POINT);
- }
+ /**
+ * Returns a fixed point value greater than or equal to decimal 0.0 and
+ * less than 1.0 (in 16.16 format this would be 0 to 65535 inclusive).
+ */
+ public static int rand() {
+ if (rng == null) {
+ rng = new Random();
+ }
+ return rng.nextInt() >>> (32 - FIXED_POINT);
+ }
- /**
- * Returns a random number between 0 and n
(exclusive).
- */
- public static int rand(int n) {
- return (rand() * n) >> FIXED_POINT;
- }
+ /**
+ * Returns a random number between 0 and n
(exclusive).
+ */
+ public static int rand(int n) {
+ return (rand() * n) >> FIXED_POINT;
+ }
}
\ No newline at end of file
diff --git a/engine/src/android/res/layout/about.xml b/engine/src/android/res/layout/about.xml
index d95af3722..1d8c2b0a3 100644
--- a/engine/src/android/res/layout/about.xml
+++ b/engine/src/android/res/layout/about.xml
@@ -7,25 +7,25 @@
android:layout_height="fill_parent"
>
-
SkyFactory
is used to create jME {@link Spatial}s that can
+ * be attached to the scene to display a sky image in the background.
+ *
+ * @author Kirill Vainer
+ */
public class SkyFactory {
-
- public static Spatial createSky(AssetManager assetManager, Texture texture, Vector3f normalScale, boolean sphereMap){
- return createSky(assetManager, texture, normalScale, sphereMap, 10);
- }
- public static Spatial createSky(AssetManager assetManager, Texture texture, Vector3f normalScale, boolean sphereMap, int sphereRadius){
- if (texture == null)
+ /**
+ * Creates a sky using the given texture (cubemap or spheremap).
+ *
+ * @param assetManager The asset manager to use to load materials
+ * @param texture Texture to use for the sky
+ * @param normalScale The normal scale is multiplied by the 3D normal
+ * to get a texture coordinate. Use Vector3f.UNIT_XYZ to not apply
+ * and transformation to the normal.
+ * @param sphereMap The way the texture is used
+ * depends on this value: