Physics and light prob. with android

Hello Community

I am trying to develop a game with JME3 as part of my bachelor thesis.
Now i got severel issues i could not get to work by my self since 3 weeks.
Iam posting pictures as i think its more easy to see the probs. I get.

I am developing my code with JME3 SDK and port it as soon as it runs to eclipse.
I would prefer to go on with Eclipse, infact I’ve written an application allready in it.
Yes it is possible that i did some mistakes by setting up Eclipse with JME3.

1st Problem:
Is it possible to create some physics in the scene Explorer and run them on droid?
I tested it with JME3 desktop it works well, i tested it with JME3 android, app crashes
It function if i create some stuff and dont add physics in SceneE. but instead as code.
Code:
[java]
terrain = assetManager.loadModel(“Scenes/Terrain.j3o”); //1st try = ok, phyisics added to complete terrain in Code, same Terrain no phyiscs
terrainControl = new RigidBodyControl(0f);
terrain.addControl(terrainControl);
bulletAppState.getPhysicsSpace().add(terrainControl);
rootNode.attachChild(terrain);
[/java]
[java]
terrain = assetManager.loadModel(“Scenes/Terrain_1.j3o”); //2nd. try = crash, physics added in SceneExploerer see pic, same Terrain +Physics
bulletAppState.getPhysicsSpace().addAll(terrain);
rootNode.attachChild(terrain);
[/java]
see picture JMEStructure, JMESceneExplorer


2nd problem:
Terrain of Game is designed in JME3 Terrain Editor, Trees are importet from Bleder as blend and compiled with JME_SDK to .j3o
Game appears quite dark, i read something about alpha problems, but why is the skybox brown instead of blue and why are the trees so dark?

Game_Desktop
Game_Android

I will be thankfull for any kind of help, i trying since 3 weeks now to solve this problems
tell me if u need full code
Greetings Alex :slight_smile:

Hello Community

Does no one have an idea, or are people on vacance?

Has someone read anything about these problems in anythread?

Every idea would be good :slight_smile:

Thanks Alex

Hello people :slight_smile:

i figured it out by my self i think the problem was that eclipse wasnt setup correctly (missing libraries) and the black texture is maybe this discussed material problem in android. So i just changed to textures as discribed in the hello terrain tutorial this works fine now.
HelloTerrainTutorialLink (2014/July/09)

Physics works, I implement it in code now.

If someone gets the same problem by setting up, Eclipse

Eclipse walkthrough:
Desktop:

  1. Install JME3 SDK for developing, cause its easier and faster to test the stuff and run it on desktop
  2. Generate a new JME3 Project in Jme3 SDK “File ->New Project ->JME3->BasicGame”
  3. Try to code something or use the tutorial code
  4. Test ure code by pushing the RunProjectButton or hit F6 “default is desktop”

Next Android:
5. Right click ure project ->set sonfiguration -> Customize => “Project Properties Window opens”
6. Go to Build->Compiling->uncheck copile on Save
7. Go to Application ->Android ->check Enable Android Deployment
8. Choose ure Android Target "I use 4.2.2"¨
9. Close Properties Window
10. Change running platform from <default config> to “Android Device”
11. Test ure code by pushing the RunProjectButton or hit F6, sometimes I got null point exceptions, if u get this, try “clean and build project first” or Shift+F11

Settingup Eclipse:
12. Get the android SDK with Eclipse form Download Android Studio and SDK tools  |  Android Developers (2014.July.07)
direct linkt to android sdk
13. Open Eclipse
14. Generate a new Project File-> New -> Android Project (you will find additional tutorials on youtube)
15. Make a new Class in Source Folder of your project i call it GameActivity.java
16. import this code
[java]
package com.example.game;

import android.os.Bundle;
import android.view.Menu;
import com.example.meshing.R;
import com.jme3.app.AndroidHarness;
import com.jme3.renderer.android.TextureUtil;

public class GameActivity extends AndroidHarness {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

public GameActivity () {
    appClass = com.example.game.Game.class.getName();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    //getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}
[/java]
16. Open your JME3 working directory (with Explorer) where the projects are saved, if u dont know where it is, use Windows Search, search your project name from JME3SDK
17. Create a new Class in Source Folder i call it Game.java
18. Copy your code from JME3 Class to your Eclipse Game.java class
19. Go to JME3 working Folder / mobile, copy assets Folder to Eclipse Project (drag and drop it on same Level your SourceFolder is in Eclipse)
20. Copy the JME3 Libs Folder to Eclipse Project (drag and drop it on same Level your SourceFolder is in Eclipse)
21. Add the libs from Eclipse to build path rightclick Project->build Path -> Configure Build Path
22. Go to Libraries click add JARs add your JARs from the Project
23. Go to Order and Export select all your JARs click OK
Your Project should be setup correctly now

  1. You must give permision to your Activity in AndroidManifest.xml else you will get a Android exception as soon as you start your apk on the device.
  2. Open AndroidManifest (it is in your Project in Eclipse on the same Level Source Folder is)
    26 Click on Application, scroll downto the end, you will see a window Applicatoin Nodes, click on Add, double click on Activity
  3. On the right side appears a new Window click on Browse and search your GameActivity.java (not Game.java)
    Now it should run in Eclipse too :wink:

If you get problems later as i got (Physics exceptions), just compile your JME3 project again, copy and update the libraries from JME3 Mobile to your Eclipse Project.

I hope this walkthrough helps
Have fun :wink:

Edit: there are a lot of tutorials in youtube for Eclipse and Android SDK.
If you havent used Eclipse before u have to setup your SmartPhone and activate developer first.

2 Likes

On the dark terrain from terrain-editor, its a known bug (see @Sploreg explaination here: http://hub.jmonkeyengine.org/forum/topic/black-textures-in-android/page/3/#post-263989 )

There are also more probs (see: http://hub.jmonkeyengine.org/forum/topic/problems-with-graphic-on-some-devices/page/2/ )

Its not the only prob with jme3 on android.
You have to do a lot of testing and workarounds on android.
Also its extra work to develop JME on eclipse, you will have less probs if you use jme3 sdk.