Plz help – Problem spatial name: Root Node

hi, I’ve got an AbstractAppState in which i create



[java]playerCamState = new GameLevelPlayerCam();

this.app.getStateManager().attach(playerCamState);[/java]



which looks like this:



[java]public class GameLevelPlayerCam extends AbstractAppState implements ActionListener {



public void initialize(AppStateManager stateManager, Application app) {

super.initialize(stateManager, app);

this.app = (SimpleApplication) app;



bulletAppState = new BulletAppState();

this.app.getStateManager().attach(bulletAppState);



Node map = new Node(“Map”);

map = (Node) this.app.getAssetManager().loadModel(“Models/Tiles/weed.j3o”);

map.setLocalScale(10f);

this.app.getRootNode().attachChild(map); //<— !![/java]



and im getting this error:



[java]Problem spatial name: Root Node

at com.jme3.scene.Spatial.checkCulling(Spatial.java:242)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:775)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1116)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1167)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:263)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:722)[/java]



Somebody now what i am doing wrong?

I usually get that when I’m extending Thread.

But as you dont, then I think the problem is that you try to get the rootnode of your abstract state NOT from the actual rootnode if you know what im trying to say…

@Addez said:
I usually get that when I'm extending Thread.
But as you dont, then I think the problem is that you try to get the rootnode of your abstract state NOT from the actual rootnode if you know what im trying to say..

yes i also thought that so i passed it directly

[java]playerCamState = new GameLevelPlayerCam(app); // app does have the correct root node at this point
this.app.getStateManager().attach(playerCamState);

public class GameLevelPlayerCam extends AbstractAppState implements ActionListener{
...
private SimpleApplication app;

public GameLevelPlayerCam(SimpleApplication app){
this.app = app;
}
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);


bulletAppState = new BulletAppState();
this.app.getStateManager().attach(bulletAppState);
//bulletAppState.getPhysicsSpace().enableDebug(assetManager);

setUpKeys();

System.out.println(this.app.getRootNode());

Node map = new Node("Map");
map = (Node) this.app.getAssetManager().loadModel("Models/Tiles/weed.j3o");
map.setLocalScale(10f);
this.app.getRootNode().attachChild(map);[/java]

But i get the same error.

ok im getting the root node everywhere but not in the initialize method:



[java]private SimpleApplication app;



public GameLevelPlayerCam(SimpleApplication app){



this.app = (SimpleApplication) app;

this.app // works



}

public void initialize(AppStateManager stateManager, Application app) {

super.initialize(stateManager, app);

this.app // does not work

…[/java]



the fuck?

What version of JME are you using?



Older AppStateManager was really messed up with where it decided to run initialize() and could run it in bad places. Make sure you have updated to the latest stable updates after beta 3.

1 Like

omg @pspeed that solved the problem.Thanks so much.