Black square in the middle of rigidbody / texture

Okay, I’m not entirely sure where this went/what the issue was, so that’s why it’s under general. What’s happening is when I start my game, if start it by attaching the LevelState straight to the stateManager, everything’s fine. But if I attach a MainMenuState first, and then attach LevelState with the “START” button is pressed, a black square appears in every single rigidbody, right at it’s center. Here are pics to understand what’s going on:

Fine:

Squares:

Now, first of all, what do you think is causing this? The texture? Some weird camera angle? I have no clue where to begin looking for this bugging.

Here are the two states (only relevant code pasted)

MainMenuState:

[java]
@Override
public void initialize(final AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);

    this.stateManager = stateManager;
    this.app = (SimpleApplication)app;
    this.rootNode = this.app.getRootNode();
    this.guiNode = this.app.getGuiNode();
    
    
    
    start_button = new ButtonAdapter(screen,"start", new Vector2f(0, 0)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            stateManager.detach(stateManager.getState(MainMenuState.class));
         
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    };
    start_button.setPosition(screen.getWidth()/2f-start_button.getWidth()/2f,screen.getHeight()/2f);
    start_button.setText("Start");
    screen.addElement(start_button);
    
    credits_button = new ButtonAdapter(screen,"credits", new Vector2f(0, 0)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            stateManager.detach(stateManager.getState(MainMenuState.class));
         
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    };
    credits_button.setText("Credits");
    credits_button.setPosition(screen.getWidth()/2f-credits_button.getWidth()/2f,screen.getHeight()/2f + start_button.getHeight()+ 5);

    screen.addElement(credits_button);
    
    app.getInputManager().setCursorVisible(true);
    //TODO: initialize your AppState, e.g. attach spatials to rootNode
    //this is called on the OpenGL thread after the AppState has been attached
}

@Override
public void cleanup() {
    super.cleanup();

    screen.removeElement(credits_button);
    screen.removeElement(start_button);
    LevelState level_state  = new LevelState(screen);
    stateManager.attach(level_state);

    //screen.r
    //guiNode.detachAllChildren();
    //TODO: clean up what you initialized in the initialize method,
    //e.g. remove all spatials from rootNode
    //this is called on the OpenGL thread after the AppState has been detached
}[/java]

LevelState:
[java]@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);

    System.out.println(app);
    this.app = (SimpleApplication)app;
    this.stateManager = stateManager;
    this.assetManager = this.app.getAssetManager();
    this.cam = this.app.getCamera();
    this.rootNode = this.app.getRootNode();
    this.guiNode = this.app.getGuiNode();
    this.bas = this.stateManager.getState(BulletAppState.class);
    
    System.out.println(guiNode.getControl(Screen.class));
    
    generalSetup();
    
    setupPlayer();
    
    //createMappings();
    
    rxf = new ReadXMLFile("assets/Textures/testMap2.tmx",assetManager,bas);
    rxf.parse();
    l = rxf.createLevel(cam);
                       
    rootNode.attachChild(l);
    
    setupCollidables();
    
    createMappings();

    game_timer = new LwjglTimer();

    
    Element time_info_l = new Element(screen, "label",new Vector2f(0,0),new Vector2f(190,0),
            new Vector4f(5,5,5,5),null);
    //Label time_info_l = new Label(screen,"label", new Vector2f(0,0),new Vector2f(190,0));
    time_info_l.setPosition(cam.getWidth()/2f - time_info_l.getWidth()/2f, 10f);
    time_info_l.setText("Seconds since start:");
    time_info_l.setFontColor(ColorRGBA.White);
    
    time_info_l.setFontSize(Math.abs(tlratio) * 15);

    time_l = new Label(screen, "time", new Vector2f(0,0),new Vector2f(70,0));
    time_l.setPosition(time_info_l.getPosition().x + time_info_l.getWidth(),10f);
    time_l.setFontColor(ColorRGBA.White);
    time_l.setFontSize(Math.abs(tlratio) * 15);
    
    Effect effect = new Effect(
        Effect.EffectType.FadeIn, // The type of effect to use
        Effect.EffectEvent.Show, // The event that the effect is associated with
        10f // The duration of time over which the effect executes (2.2 seconds)
    ); 
    
    time_info_l.addEffect(effect);
    time_info_l.hide();

    ///screen.getEffectManager().applyEffect(effect);
    

    screen.addElement(time_l);
    screen.addElement(time_info_l);

    
    
    time_info_l.showWithEffect();
    
    //TODO: initialize your AppState, e.g. attach spatials to rootNode
    //this is called on the OpenGL thread after the AppState has been attached
}[/java]

If you really want the code from the other functions, I’ll post it. I just don’t think they play a role in this. I’ve tried making the MainMenuState immediately switch to the LevelState after being called (and not do any of the GUI stuff) and the issue still occurs.

One way to debug this would be to look at the scene graph hierarchy in the working and non-working case.

Also, it looks like you have physics debugging on. What happens if you turn it off?

Same issue with physics debugging off.

When you say, “look at the scene graph hiearachy”, do you mean I should print out all the Nodes attached to the guiNode and rootNode (and their children) and see if something is overlapping in that space? Or at least, if anything is different between the working and non-working cases?

@machspeeds said: Same issue with physics debugging off.

When you say, “look at the scene graph hiearachy”, do you mean I should print out all the Nodes attached to the guiNode and rootNode (and their children) and see if something is overlapping in that space? Or at least, if anything is different between the working and non-working cases?

Yes. Or look at it in the debugger.

If you go the “print” route then you will want to print out all of the nodes and geometries.

This might help. It helped me months ago finding a weird issue.

http://hub.jmonkeyengine.org/forum/topic/a-simple-node-tree-printer-to-html/

Cool, thanks. That’ll probably come in handy later on too.

However, I figured out my problem (I think). I don’t know why this occurs after the other state, but it seems like the rigidbody (which is attached to the center of the node of those tiles) extends outwards in both directions, and I guess the triangles create some kind of hole in front of the texture for each tile.

Before I close this, a simple question.

Is it not possible to move a quad along the z axis?

It is, why? it will just not change size, as they are ortighraphic in gui.

Yeah, So I have the camera set to orthorgraphic too. It’s just that I have a GhostControl attached to the quad’s position, and I’m trying to move the GhostControl back along the z axis. And what can I say? It’s just not moving…

But not to worry, I found a workaround. So thanks for your insight, everyone. I’ll be back within a couple days though, just you wait :wink: