Hello,I am trying to load spatial on Android Studio.Firstly i am using the codes on https://github.com/iwgeric/jME3-Android-Examples/tree/master/g-Jaime_Demo.
It is working well but textures are not showing.
I am just editing the code on SceneLoadTask.java → *.
Here is my code.
public class SceneLoadTask implements LoadTask{
private SceneLoadData loadData = null;
private static final Logger logger = Logger.getLogger(SceneLoadTask.class.getName());
private final String road=“Scenes/road/road.j3o”;
public SceneLoadData getLoadData() {
return loadData;
}
@Override
public Object load(Application app) {
if (loadData != null) {
throw new IllegalStateException("Scene is already loaded!");
}
SceneLoadData loadData = new SceneLoadData();
BulletAppState bulletAppState = app.getStateManager().getState(BulletAppState.class);
PhysicsSpace physicsSpace = (bulletAppState != null)? bulletAppState.getPhysicsSpace(): null;
if (physicsSpace == null) {
throw new IllegalArgumentException("PhysicsSpace could not be found!");
}
loadData.world = (Node)app.getAssetManager().loadModel(road);
if (loadData.world == null) {
throw new IllegalArgumentException("worldFileName[" + road + "] did not load.");
}
loadData.road = (Spatial) loadData.world.getChild("road");
if (loadData.road== null) {
throw new IllegalArgumentException("worldFileName[" + road + "] did not load.");
}
loadData.road.setLocalTranslation(-3,-3,0);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
loadData.road.addLight(sun);
return loadData;
}
@Override
public void onDoneLoading(Application app, Object object) {
SceneLoadData loadData = (SceneLoadData)object;
BulletAppState bulletAppState = app.getStateManager().getState(BulletAppState.class);
PhysicsSpace physicsSpace = (bulletAppState != null)? bulletAppState.getPhysicsSpace(): null;
if (physicsSpace == null) {
throw new IllegalArgumentException("PhysicsSpace could not be found!");
}
if (loadData.world != null) {
physicsSpace.addAll(loadData.world);
}
app.getRenderManager().preloadScene(loadData.getWorld());
this.loadData = loadData;
}
@Override
public boolean isLoaded() {
return (loadData != null);
}
public class SceneLoadData {
private Node world;
private Spatial road;
public Node getWorld() { return world; }
public Spatial getroad() { return road; }
}
}