I gazed toward the dark side (Ardor3D) to check out what Lord Vader (renanse) was up to. :wink:
I noticed that the new version of Ardor3D supports AngelCode’s BitmapFonts. Luckily i needed kerning with Bitmap Fonts in my own project before and already implemented it for jme 2.0 a few months ago. http://www.angelcode.com/products/bmfont/
things like that are possible: http://www.chadvernon.com/blog/tutorials/managed-directx-2/bitmap-fonts/
The bad thing is i am not familiar with the way bitmap fonts are rendered in jme now so i just create a whole lot of Quads which i lock() for performance increase (works fine for me). its just that you have to unlock() and lock() again when you want to change the text.
Question is, should i post the code here or make it a contribution? I guess a post of code here would be best so you guys can make it better (one mesh per text block if thats possible?) and then we could contribute it into jme 2.0?
Waiting for suggestions,
Andy
I say post it here for everyone to play with first.
here we go, patch for 2.0 trunk and two files for the font.
EDIT: i removed the patch.txt since it seemingly cannot be downloaded correctly anyway :| why does it get cut off somewhere in the middle? It sure wasn’t too big a file for the forum constraints.
anyway, here it is on pastebin: http://pastebin.com/f3655f2d
What are the advantages of AngelCode over the default font which jme uses now?
Core-Dump said:
What are the advantages of AngelCode over the default font which jme uses now?
advantages:
1st and foremost: you have kerning http://en.wikipedia.org/wiki/Kerning which improves readability and looks better [attachment]. The current font system just displays characters monospaced.
2nd: the tool lets you select any number of character sets / characters and exports them, in the current font system the character set is fixed i think. You can have chinese and russian characters in you font and even IN one font texture (although it will get big then)
3rd: as you can see in the texture above, no texture space is wasted. current font system wastes most of the textures space.
4th: automatical word wrapping by defining a constricting Rectangle
disadvantages:
1. it is using a Quad per character (this needs to be changed i think)
2. you need a second file for your font (a text file that holds a characters id, its position on the texture and kerning info)
EDIT: the screenshot below is the result of the included testcase
And you forgot to mention that because Ardor3d uses it too… it must be good.
Seriously though, definitely makes a more professional statement over the old ugly jME Text class.
renanse said:
Seriously though, definitely makes a more professional statement over the old ugly jME Text class.
Absolutely!
So, who is up to making the thing a bit more performant? This would basically mean to get rid of the single Quads per character and use one VertexBuffer per StringBlock instead. I will definitely make it when i get to it (one day) but maybe someone is eager to beat me to it? ;)
This implementation of yours only uses that C# tutorial right? You didn't copy any code from Ardor3D?
I am going to implement some GUI elements into "jME3" soon and this kind of font system would be useful. So, I'll probably make it work as a single dynamic mesh object, and then it'll be possible to port it back to jME2 if needed.
Momoko_Fan said:
This implementation of yours only uses that C# tutorial right? You didn't copy any code from Ardor3D?
i only later noticed that the Ardor3D-people had the same bright idea to use AngelCodes BitmapFonts. I used (more or less ported) the C#/DirectX tutorial by Chad Vernon http://www.chadvernon.com/blog/tutorials/managed-directx-2/bitmap-fonts/
It would be great, since i really dont know what a dynamic mesh object is ;). When would you implement it?
changed the link to the patch as seen above.
Just letting you know, the latest jME3 commit already has these fonts implemented. :)
Instead of creating a new quad for each character, it puts all of them into a single mesh.
Momoko_Fan said:
Just letting you know, the latest jME3 commit already has these fonts implemented. :)
I will check it out, port it back to 2.0 and post a new patch here.
well then, it's ported to jme 2.0 and works like a charm.
- removed Texture Pages code (Momoko_Fan loads all but just uses the first anyway)
- removed Color from BitmapText, can be set with text.setDefaultColor(…);
- assemble() renamed to update() (i think it better describes what it does and is more obvious for the user)
- loader method for loading a Font is static method: BitmapFontLoader.load(URL, URL)
- minor changes - just check out the testcase TestBitmapFont will ya? :wink:
EDITED: patch: http://pastebin.com/m5c8b0b5a (its too many characters for direct post)
new link because of a fixed bug (updating a Text with a shorter one will show the old characters after the new ones)
image (put it in the same folder as angelFont.fnt for the testcase to work) as attached
nice work
Is the jme 2.0 port already in the repository? because I can't find it anywhere
its not committed yet