Porting to Android app - relocation of spatial

We created an Android app following the tutorials.



When testing our game we found that some 3D effects like glow don’t work as warned. However the relocation of a Spatial using either setLocalTranslation or move, puts the spatial in the correct position but leaves behind a ‘ghost’ of itself, that is the same colour as the background, at its previous position.



We have disabled the glow and particle emitter effects for the Android app. We are using the nightly version of the SDK.



Here are two links that show the effect on the app and the working version on the desktop app.



https://dl.dropbox.com/u/18645175/App.png This shows the ‘ghost’ effect



https://dl.dropbox.com/u/18645175/Desktop.png



Thanks!

ok…are you using RC2 or Nightly?

Did you try to remove the nifty processor and see if the problem persists?

disable all post process on android they are not supported

We have disabled the glow and particle emitter. Are there any other post processes that could cause this effect? The board floor is just an image.

all of them : meaning remove the FilterPostProcessor.



However particle emitters are not post process and work ok on android as long as there are not too much particles.

We added the particle emitter back in and it works. However moving the Spatial still leaves a ‘ghost’ even with all references (and imports) referring to FilterPostProcess removed.

ok do you do something special with the viewports (not clearing depth for example)?

Or do you do something fancy with detphWrite depthTest on some material for some reason?



it looks like a depth test issue.

The only thing done with viewports is changing the background colour and adding the nifty screens. We don’t use depthTest or depthWrite at all.

Thanks for all your help so far.

Any other ideas? Thanks!

Did you try on a real phone?

We’ve tried it on a android tablet and got the same results.

We are using the Nightly version. And we tried removing the nifty processor completely but the problem still remains.

mhhh…could you wrap up a test case so i can look into it?

I’m out of guesses, i need to look into some code :stuck_out_tongue:

When creating the test case we found that adding certain features causes the ‘ghost’ effect to appear. It happens when adding a particle emitter or when adding nfity elements.



If the tablet goes to sleep and the screen is turned back on, the game freezes for a second and then the ‘ghosts’ disappear. Then as you begin moving the ‘ghosts’ start appearing.



Additionally if you move the camera view around, the same ghosting effect occurs but now wilth all the elements in the game such as the board also going grey.



Below is the test case:



[java]

private Spatial sprite1;

private Geometry [] geoms;

private ParticleEmitter playerArrow;



public static void main(String[] args) {



}



@Override

public void simpleInitApp() {

Logger.getLogger("").setLevel(Level.SEVERE);

setDisplayFps(false); // to hide the FPS

setDisplayStatView(false); // to hide the statistics

cam.setLocation(new Vector3f(15f, 20f, 50f));

cam.lookAt(new Vector3f(15f, -40f, -40f), Vector3f.UNIT_Y);

viewPort.setBackgroundColor(ColorRGBA.Gray);

createGrid();

Material mat = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Green);

sprite1 = assetManager.loadModel(“Models/Ninja/Ninja.mesh.xml”);

sprite1.scale(0.02f, 0.02f, 0.02f);

sprite1.rotate(0.0f, -3.0f, 0.0f);

sprite1.setMaterial(mat);

sprite1.setLocalTranslation(1, 0, 29);

rootNode.attachChild(sprite1);

geoms = new Geometry[14];

for(int i = 0; i < geoms.length; i++) {

Sphere sphere = new Sphere(32, 32, 1f);

Geometry sprite2 = new Geometry(“Sphere”, sphere);

sprite2.scale(1.0f, 1.0f, 1.0f);

Material mat2 = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”);

mat2.setColor(“Color”, ColorRGBA.Yellow);

sprite2.setMaterial(mat2);

sprite2.setLocalTranslation(2i + 3, 1, 29);

rootNode.attachChild(sprite2);

geoms = sprite2;

}

createArrow();

new ClientMonitor().start();

}



public void createArrow() {

playerArrow = new ParticleEmitter(“Player turn”,

ParticleMesh.Type.Triangle, 30);



Material mat = new Material(assetManager,

“Common/MatDefs/Misc/Particle.j3md”);

mat.setTexture(“Texture”,

assetManager.loadTexture(“Effects/Explosion/flash.png”));

playerArrow.setMaterial(mat);

playerArrow.setImagesX(2);

playerArrow.setImagesY(2);

playerArrow.setLowLife(1f);

playerArrow.setHighLife(2f);

playerArrow.setSelectRandomImage(true);

playerArrow.setLocalTranslation(1, 5, 29);

rootNode.attachChild(playerArrow);

}



public void createGrid() {

Material mat = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);



Geometry grid;



for (int i = 0; i < 15; i++) {

for (int j = 0; j < 15; j++) {

Box b = new Box(1, 0, 1);

grid = new Geometry(“Grid”, b);

grid.setMaterial(mat);

grid.move(new Vector3f(i * 2 + 1, 0f, j * 2 + 1));

rootNode.attachChild(grid);

}

}

}



private void updateBoard() {

enqueue(new Callable<Spatial>() {



@Override

public Spatial call() throws Exception {

sprite1.setLocalTranslation(3, 0, 29);

geoms[0].setLocalTranslation(5, 1, 29);

for(int i = 1; i < geoms.length; i++) {

geoms.setLocalTranslation(2
i + 3, 1, 27);

}

return null;

}



});

}



public void moveArrow(final int x, final int y) {

enqueue(new Callable<Spatial>() {



@Override

public Spatial call() throws Exception {

playerArrow.setLocalTranslation(x, 5, y);

return null;

}



});

}



private class ClientMonitor extends Thread {



public ClientMonitor() {

super(“ClientMonitor”);

}



public void run() {

try {

sleep(10000);

} catch (InterruptedException ex) {

Logger.getLogger(MyGame.class.getName()).log(Level.SEVERE, null, ex);

}

updateBoard();

moveArrow(3, 29);

}



}

[/java]

I noticed your using ninja.mesh.xml, that should be converted to a j3o and its probably a too high detailed animation for android anyways (if it even works),

We tried removing the ninja but the shadows still appear on the board for the other objects. Is there any way to force the screen to refresh as when it sleeps and then wakes up again, the existing shadows disappear.

How can you have shadows when you removed all post processors?

By shadow I meant the ‘ghost’ effect.