Page 4 of 12

Posted: Sat May 08, 2010 10:40 pm
by Nalin
zet.dp.ua wrote:One suggestion: it would be better to minimize the additional info in the xml file. <entry id="My string">My string</entry>, <s id="My string">My string</s> could be enough.

Integrating string table with irrlicht's text node can really save a lot of time.
Don't write any possibly localizable text in the code!!! :)
Hmm. I guess I could use both methods. The reason I did it that way was because people may do something like this:

Code: Select all

core::ustring info = st::_T("<Information>");
They would assume that if no translations were loaded, st::_T("<Information>") would return <Information>. They could target their default language and allow people to optionally load/install language packs.

Of course, because they used < and >, it breaks XML. Which is why I support CDATA:

Code: Select all

<entry>
    <id><![CDATA[<Information>]]></id>
    <translation>sdfsdfgjkdfhg</translation>
</entry>
But, I can definitely see your point. I'll make it recognize that "condensed" mode.

---

I've uploaded new changes:
ustring:
  • Fixed operator= that I broke with the previous upload.
  • Fixed an error in UTF-8 and UTF-32 parsing that I introduced in the previous upload.
CStringTable:
  • Support for a more condensed XML style.

Posted: Wed May 12, 2010 8:36 pm
by LosNir
Thanks for sharing this!

The CGUITTFont crashes when I try to load a font. When I call createTTFont it crash on line 251 of CGUITTFont.cpp.

Code: Select all

Driver = Environment->getVideoDriver();
Waiting for your response on how to fix it.

Posted: Thu May 13, 2010 12:34 am
by Nalin
LosNir wrote:Thanks for sharing this!

The CGUITTFont crashes when I try to load a font. When I call createTTFont it crash on line 251 of CGUITTFont.cpp.

Code: Select all

Driver = Environment->getVideoDriver();
Waiting for your response on how to fix it.
The only way that could crash is if you are passing in an invalid pointer to the IGUIEnvironment when calling createTTFont(). You should debug your code to make sure your IrrlichtDevice isn't being mangled or dropped somewhere.

Posted: Thu May 13, 2010 4:51 am
by LosNir
Sweet! Thanks. I dropped a line that sets the IGUIEnvironment on the class, so I passed a NULL pointer. Thanks :)

EDIT:

Now it crashed on line 196 :(

Posted: Thu May 13, 2010 8:55 pm
by Nalin
LosNir wrote:Sweet! Thanks. I dropped a line that sets the IGUIEnvironment on the class, so I passed a NULL pointer. Thanks :)

EDIT:

Now it crashed on line 196 :(
What error does it give?
Possible issues could be:
1. Your font size is 0.
2. You called setMaxPageTextureSize() and set the maximum texture size to 0x0.
3. driver->getMaxTextureSize() is returning 0x0 for some reason.

-----

Anyways, I've updated CGUITTFont, to prevent it from crashing in the previous specified circumstances, and CStringTable, to fix a bug and add a function.

CGUITTFont:
  • If the maximum texture size is calculated as 0x0 pixels, set it to 2048x2048 pixels.
  • Don't attempt to load the font if the filename is empty, the font size is set to 0, or a null pointer was passed to the environment.
  • Fixed a memory leak in some back up code that generally shouldn't run (backup code in case no IFileSystem exists, which generally shouldn't happen.)
CStringTable:
  • The CStringTableUString copy constructor copies the prefix and postfix values properly.
  • New helper function in CStringTableUString named wcs(). It returns a const wchar_t*, to make it easier to pass information to Irrlicht functions.

Posted: Fri May 14, 2010 10:55 am
by LosNir
I used different fonts, with size 14, and never called the functions you mentioned. Anyway after the update it now works.

Thanks!

Posted: Fri Jun 11, 2010 10:03 am
by Nalin
SVN Trunk: CXMLReaderImpl_trunk.patch
SVN Trunk: CFileSystem_trunk.patch

Recently, I noticed that a change to irrXML.h in the SVN trunk, made on revision 3256, broke my unicode XML reading patch. I've added some new .patch files to the OP that you can use against the latest SVN trunk.

Posted: Tue Jun 22, 2010 3:26 pm
by Valodim
Hey dude.

Good work on those libs, works great for displaying text as 2d hud.

However, I am having problems using it as font to display on a bilboard using addBillboardTextSceneNode(). The type check works and it compiles, but at runtime the content of the CGUITTFont pointer gets garbled right after the addBillboardTextSceneNode() call (which does work using the builtinFont), and the program crashes.

Is this known / intended behavior? I couldn't find any info on using your class on billboards on this forum..

thanks in advance :)

Posted: Wed Jun 23, 2010 3:49 am
by Nalin
Valodim wrote:Is this known / intended behavior? I couldn't find any info on using your class on billboards on this forum..
It is an unknown / unintended behavior.

Basically, I haven't tested my class at all when using billboards. I'll make myself a note to search for and test anything that can take an IGUIFont*.

Posted: Wed Jun 23, 2010 10:46 pm
by Nalin
Okay, I've figured out the issue.
IBillboardTextSceneNode was written to specifically use the normal IGUIFontBitmap class. When it looks at my CGUITTFont class, it detects that it isn't an IGUIFontBitmap, so it writes this to the log and aborts:

Code: Select all

os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION);
This is all fine and dandy, but it then calls:

Code: Select all

setText(text);
setText() doesn't check to see if the font was loaded successfully and immediately tries to gain access to the SMesh that should have been created in the constructor, causing a null pointer exception.

So there you have it. It is a bug with Irrlicht. I suppose I should create my own version of IBillboardTextSceneNode that works with my CGUITTFont class, as the one in Irrlicht only works with Irrlicht's bitmap font format.

EDIT:
I fixed it and submitted a patch. It should be fixed in future versions of Irrlicht.

Posted: Wed Jun 23, 2010 11:53 pm
by CuteAlien
Thanks for the patch. I applied it to the 1.7 svn branch.

Posted: Thu Jun 24, 2010 11:53 am
by Valodim
Wow, that's some quick replies around here.

Thanks for the insight.

Is getting your font class to work with billboards a very difficult endeavor? As in, could a quick dive into the irrlicht source be enough to implement this, or would that require some dedication?

Posted: Thu Jun 24, 2010 10:17 pm
by Nalin
Valodim wrote:Is getting your font class to work with billboards a very difficult endeavor? As in, could a quick dive into the irrlicht source be enough to implement this, or would that require some dedication?
A quick dive into the source wouldn't be enough. I will have to design a billboard class from scratch to work with my font class. My CGUITTFont class and Irrlicht's IGUIFontBitmap class are very different in implementation. It is further complicated by the fact that my CGUITTFont class ends up creating its own textures full of glyphs, and those textures can change when you attempt to draw a glyph that hasn't been cached to a texture first. This will require some changes to CGUITTFont to make everything work well and not crash.

I've been busy lately with some XNA projects, so I won't be able to devote a bunch of time to this, but I'll try to put in some time here and there to get it working.

Until then, you could use normal font bitmaps for billboards until my class is finished. Or, you can use an ITextSceneNode. An ITextSceneNode converts its 3D position into screen coordinates, then draws the text. The text won't scale and rotate like it is part of the world, but it will somewhat simulate a billboard. Kinda. Or, you could try for an RTT solution. Render a string of text to a texture, then use that texture as a normal billboard.

Posted: Thu Jun 24, 2010 10:35 pm
by Valodim
Ah. That's probably more time than I could spend on this matter myself, especially since I have next to no experience with Irrlicht's internals.

I guess I'll just stick to bitmap font billboards for now. Thanks for your time :)

Posted: Wed Sep 22, 2010 2:36 am
by Nalin
Well, it has been a while, has it? I've been busy with my XNA projects so I haven't had time to update things. A while ago, archilife created some really nice patches for CGUITTFont, so I have merged his work into my copy. So, here we go:

New version of CGUITTFont:
  • Lowered memory usage. (archilife)
  • The font texture atlas is now smaller (less fonts per page) to reduce memory usage. (archilife)
  • Added the ability to generate text scene nodes for rendering text in 3D space. (archilife)
I have also added proper license info to the top of irrUString.h, CGUITTFont.h, CGUITTFont.cpp, CStringTable.h, and CStringTable.cpp. It is the zlib license, the same license that Irrlicht uses. I've mentioned that all my work in this thread uses the zlib license somewhere, but I can't remember where, so adding the information directly to the source files will serve to fully clarify any confusion.