As @momoko_fan posted in that almost two-years-old thread z-ordering was implemented, but from that particular post, it is said that we should be able to play with Nifty’s z-order, but either I’m blind or this was never implemented.
In fact, I’ve looked into NiftyJmeDisplay and renderDeviceJme and I couldn’t find the evidence of a guiNode anywhere. the only thing I can see is the rendering of quads directly to the postQueue.
So now I’m wondering how I could properly stack my own GUI objects vs Nifty objects on the screen. Is that possible? Maybe by sending my stuff directly into the same postQueue?
I can’t help with an answer but I was wondering…did you want to put objects behind, in front of, or mixed with Nifty’s objects?
I want to put my GUI stuff behind Nifty’s so that when a panel is opened, whatever is on the screen (in the game world) is behind it.
Can’t you achieve that just by rendering your GUI in the main game loop after the main 3d rendering is done but before the Nifty rendering is done? You don’t need to worry about interacting with nifty - you just need to make sure that all nifty stuff is rendered after all your stuff…
Nifty is in a postQueue and to be rendered before it, I would need to have my own stuff being in the postQueue before Nifty is added there… So technically if I add my own stuff to that postQueue before nifty’s display is should work… I’ll have to look it up and check if that can be done with the SimpleApplication’s guiNode.
Not working. Still rendered on top of nifty’s windows even when rendered from a ScreenController added before nifty’s NiftyJmeDisplay.
This is getting infuriatingly frustrating.
There are a couple of things I want to try, but if that doesn’t work I’ll just have to disable those custom gui items while those windows are opened. I really want to avoid this though.
Did you consider hiding stuff in gui node? I.e. moving all things from gui node to some temporary node, then detaching all things from guiNode and after nifty stuff is complete (nifty gui closed), just reestablish what was on guinode before accessing nifty?
Yes and that’s unacceptable.
sigh
I’ve ran out of ideas.
I’ve set my gui bubble feedback as a postQueue before Nifty. Also after Nifty. The old way, as Pictures with and without using setQueueBucket(Bucket.Gui); and finally using a Billboard with the same result. Nifty is ALWAYS drawn first, thus beneath my info bubble.
Here’s what it looks like. This is unacceptable.
http://www.disenthral.com/files/infobubble.png
There are only 2 ways the end result will be acceptable and it is:
If it’s underneath Nifty’s “windows”. (seems this is not possible unless Nifty’s z-order implementation is done vs the other Gui stuff (as posted in my first post above). Or I’ll have to make the info bubble static in the top-middle of the screen, never ever moving it, but I’ll have to move it off elsewhere on the screen if one of nifty’s “window” overlaps… Not the best solution by far, but that’s all I have left.
You could add your info popup things as nifty panels on a layer under your other gui stuff?
Have you tried changing the z value written by your info popup things? (is there even a z value for gui node elements?)
Maybe look at the code and see where Nifty hooks into things? It’s not something I’ve looked at really.
@zarch said:
You could add your info popup things as nifty panels on a layer under your other gui stuff?
I want to avoid this because of rapidly updating information inside the "popup". Last time I had a nifty window doing this, the GC was going crazy and slowing FPS considerably at more or less the same interval. This was supposed to be my "fix". :/
Have you tried changing the z value written by your info popup things? (is there even a z value for gui node elements?)
Yes there is a z-order value that can be changed and yes I did change it, but to no avail. From -1 up to -100000. I'm sure, even if I didn't try it, that it would work with similarly made GUI elements as as my info popup, but it's simply not working with Nifty's stuff.
Maybe look at the code and see where Nifty hooks into things? It's not something I've looked at really.
Went through that. Nifty's implementation in jME3 is taking nifty's "screens" and render those as quads. There is no node to work with, nothing that I could find. I did, as outlined above, added my info popup similar to the way nifty is and adding that to the same postQueue as nifty is (in the guiNode) but still got the same result.
Maybe these quads jME3 renders for nifty are rendered with depth buffer disabled or something so there can’t be a correct z order because as far as the depth buffer is concerned these quads where never rendered? Maybe I should look into the code myself…
Edit: hmm, in NiftyJmeDisplay in postQueue() line 167 the source code states “// render nifty before anything else” but I don’t know how they achieve this (there)?
How about making a nifty control instead of trying to make it work with other gui elements? Could that work?
@cmur2 said:
Edit: hmm, in NiftyJmeDisplay in postQueue() line 167 the source code states "// render nifty before anything else" but I don't know how they achieve this (there)?
I modified my info bubble and made it a SceneProcessor that rendered in a similar way NiftyJmeDisplay works and added it before the GUI was loaded and unless I fubar'ed the way I did it, there wasn't any change. Now that I'm thinking about it, I must have eff'ed it up because that should've worked. Problem is that all those changes were reverted. :/
@normen said:
How about making a nifty control instead of trying to make it work with other gui elements? Could that work?
Technically and practically it should work without a problem, but with rapidly updating text I'm afraid the GC will have lots of cleaning up to do and hitch the game as it did before. Although there is less updating text and iirc there was some fix about that problem, it might not be as bad as it was. Even then, if my system was hitching bad, I don't want to imagine how a "low-end" computer might cope with that, even with less hitching, this could be a game breaker for a lot of people.
@madjack said:
Technically and practically it should work without a problem, but with rapidly updating text I'm afraid the GC will have lots of cleaning up to do and hitch the game as it did before.
:? Do you use your own font system? Nifty doesn't render fonts much differently than the rest of jme, in fact jme's text rendering is used for nifty too. Not saying anything about your empiric evidence for your usecase but if theres much more to it than the inefficient font rendering I'd like to know.
@normen said:
:? Do you use your own font system?
Nope. The font I use has been made by BMFont and that's pretty much it. I use Segoe_UI_semibold with different sizes, so nothing out of the ordinary.
Nah I meant for rendering…
@normen said:
:? Do you use your own font system? Nifty doesn't render fonts much differently than the rest of jme, in fact jme's text rendering is used for nifty too. Not saying anything about your empiric evidence for your usecase but if theres much more to it than the inefficient font rendering I'd like to know.
But for rapidly changing text, the Nifty->JME layer will create a new BitmapText each frame. Simply reusing a BitmapText is cheaper because I think it tries to reuse what it can from the previous mesh. Even if it doesn't now, it could... but if it doesn't then the code is way more complicated than it needs to be. And reusing it would still be cheaper than creating a new BitmapText every frame.
I know. Just wanted to point out that the only thing out of the ordinary was that I’m not using the default font.
Oh gawd.
I just had an epiphany. Since NiftyJmeDisplay uses postQueue… Then it hit me. I figure, if it’s rendered before everything else, let’s move it AFTER everything else have been rendered. That way it should be on top of everything right?
Yes. It does.
So, instead of having NiftyJmeDisplay draw in postQueue I moved its stuff into postFrame() and it works.
The question is: is that viable?