Trying to build an android app with AndroidSkyFactory and it won’t build due to missing class.
Morris
There is no AndroidSkyFactory anymore, use the normal SkyFactory.
Trying this program
public void simpleInitApp() {
Texture west = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_west.jpg”);
Texture east = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_east.jpg”);
Texture north = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_north.jpg”);
Texture south = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_south.jpg”);
Texture up = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_up.jpg”);
Texture down = assetManager.loadTexture(“Textures/Sky/Lagoon/lagoon_down.jpg”);
Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
rootNode.attachChild(sky);
}
As a mac app it runs as expected. As an android app I get this error:
09-26 08:16:02.769: WARN/dalvikvm(10441): threadid=9: thread exiting with uncaught exception (group=0x4001d570)
09-26 08:16:02.769: ERROR/AndroidHarness(10441): java.lang.NullPointerException
09-26 08:16:02.769: ERROR/AndroidHarness(10441): Exception thrown in Thread[GLThread 11,5,main]: com.jme3.util.SkyFactory.checkImagesForCubeMap(66) com.jme3.util.SkyFactory.createSky(97) com.jme3.util.SkyFactory.createSky(80) com.jme3.util.SkyFactory.createSky(125) mygame.Main.simpleInitApp(34) com.jme3.app.SimpleApplication.initialize(230) com.jme3.system.android.OGLESContext.initInThread(266) com.jme3.system.android.OGLESContext.onSurfaceCreated(217) android.opengl.GLSurfaceView$GLThread.guardedRun(1348) android.opengl.GLSurfaceView$GLThread.run(1118)
Also tried this type of sky creation
SkyFactory.createSky(
assetManager, “Textures/Sky/Bright/BrightSky.dds”, false);
This doesn’t blow up but does not display a skybox.
Morris
It should be fixed now. (in SVN)
Great. How do I use the new stuff from the svn in my copy of sdk?
I tried doing ant run in sdk in svn but it errors thus
[exec] INFO [com.jme3.asset.AssetManager]: DesktopAssetManager created.
[exec] INFO [com.jme3.renderer.Camera]: Camera created (W: 640, H: 480)
[exec] INFO [com.jme3.renderer.Camera]: Camera created (W: 640, H: 480)
[exec] INFO [com.jme3.audio.lwjgl.LwjglAudioRenderer]: AudioRenderer supports 64 channels
[exec] WARNING [com.jme3.audio.lwjgl.LwjglAudioRenderer]: OpenAL EFX not available! Audio effects won’t work.
[exec] INFO [com.jme3.renderer.Camera]: Camera created (W: 120, H: 120)
[exec] INFO [com.jme3.material.MaterialDef]: Loaded material definition: Unshaded
[exec] SEVERE [org.openide.util.Exceptions]
[exec] java.lang.NoSuchMethodError: com.jme3.material.Material.getTextureParam(Ljava/lang/String;)Lcom/jme3/material/Material$MatParamTexture;
[exec] at com.jme3.font.BitmapTextPage.(BitmapTextPage.java:76)
[exec] at com.jme3.font.BitmapText.(BitmapText.java:66)
[exec] at com.jme3.font.BitmapText.(BitmapText.java:60)
[exec] at com.jme3.gde.core.scene.SceneApplication.loadFPSText(SceneApplication.java:144)
[exec] [catch] at com.jme3.gde.core.scene.SceneApplication.initialize(SceneApplication.java:179)
[exec] at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
[exec] at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
[exec] at java.lang.Thread.run(Thread.java:680)
[exec] WARNING [org.openide.util.ImageUtilities]: Initial slashes in Utilities.loadImage deprecated (cf. #20072): /com/jme3/gde/assetpack/icons/assets.gif
Is there another target there to get that to work? or should I copy from svn to sdk?
Morris
I have tried to run this every way that I can think of and nothing works.
Morris
you just need to enable the nightly update center and update :roll:
Please be more specific. I am a bit too new to understand.
Morris
Thats why I made a big fat hint when the SDK first starts… Press F1 and read the section on “updating”…
I have updated the sdk with nightly enabled, twice actually. The sky box app still will not run. How can I verify that I actually have the sky factory updates??
Morris
I got the sdk from the svn to run and then started debugging. In SkyFactory.java is this method that was repaired to fix the SkyFactory problem in android:
private static void checkImagesForCubeMap(Image… images) {
if (images.length == 1) {
return;
}
Format fmt = images[0].getFormat();
int width = images[0].getWidth();
ByteBuffer data = images[0].getData(0);
int size = data != null ? data.capacity() : 0;
checkImage(images[0]);
for (int i = 1; i < images.length; i++) {
Image image = images;
checkImage(images);
if (image.getFormat() != fmt) {
throw new IllegalArgumentException(“Images must have same format”);
}
if (image.getWidth() != width) {
throw new IllegalArgumentException(“Images must have same resolution”);
}
ByteBuffer data2 = image.getData(0);
if (data2.capacity() != size) {
throw new IllegalArgumentException(“Images must have same size”); }
}
}
The calls
ByteBuffer data = images[0].getData(0);
ByteBuffer data2 = image.getData(0);
both return null. The call to data2.capacity() necessarily fails when data2 is a null.
Morris
I am running the following code and it works properly on mac and android:
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();
/*
ByteBuffer data = images[0].getData(0);
int size = data != null ? data.capacity() : 0;
/
checkImage(images[0]);
for (int i = 1; i < images.length; i++) {
Image image = images;
checkImage(images);
if (image.getFormat() != fmt) {
throw new IllegalArgumentException(“Images must have same format”);
}
if (image.getWidth() != width || image.getHeight() != height) {
throw new IllegalArgumentException(“Images must have same resolution”);
}
/
ByteBuffer data2 = image.getData(0);
if (data2.capacity() != size) {
throw new IllegalArgumentException(“Images must have same size”);
}
*/ }
}
Morris
Can you post a diff patch in the contrib forum for this please? In jMP / NetBeans just right-click the file and select Subversion->Diff, then right-click the file again in the list that pops up and select “export diff patch”. You can post it in [patch][/patch] tags then.
I can do that. I assume you want it without the commented out bits.
Morris
I supposed this was a fix, I’d like it so that its fixed and not broken
Well, I would post the diff file if I could figure out where to put it. The new web site makes finding anything impossible.
Morris
The guts of the diff:
Index: engine/src/core/com/jme3/util/SkyFactory.java
===================================================================
— engine/src/core/com/jme3/util/SkyFactory.java (revision 8315)
+++ engine/src/core/com/jme3/util/SkyFactory.java (working copy)
@@ -114,9 +114,7 @@
Format fmt = images[0].getFormat();
int width = images[0].getWidth();
-
ByteBuffer data = images[0].getData(0);<br />
-
int size = data != null ? data.capacity() : 0;<br />
-
- int height = images[0].getHeight();
checkImage(images[0]);
for (int i = 1; i < images.length; i++) {
@@ -125,13 +123,9 @@
if (image.getFormat() != fmt) {
throw new IllegalArgumentException(“Images must have same format”);
}
-
if (image.getWidth() != width) {<br />
-
if (image.getWidth() != width || image.getHeight() != height) {<br />
throw new IllegalArgumentException(“Images must have same resolution”);
}
-
ByteBuffer data2 = image.getData(0);<br />
-
if (data2.capacity() != size) {<br />
-
throw new IllegalArgumentException("Images must have same size");<br />
-
}<br />
}
}
Morris