3D Font

Could be handy using wingdings or other custom fonts.

How expensive the font is, I think, depends on how big you draw it (fontsize I mean here), and the type of font.

  1. Sorry for not watching my own thread. I was really busy, and I did'nt expected so much response just because of a "Konnichiwa"
  2. Thanks galun for hosting the top secret picture
  3. Ogli is right, Landei is German. However I've choosen it not because I'm a country bumpkin, but because "Landei" is "Daniel", just a little bit mixed up…
  4. llama, of course font size matters. However I use a FlattenedPathIterator to get lines instead of Bezier curves, and there you can specify how "close" your approximation should be. I guess these settings have the biggest influence.
  5. I thought about a way to get "closed" letters (with a "lid"), however it would need a lot of calculations. However, triangulation of polygons with holes seems to be a non-trivial problem. Any ideas?

I'm working on a simple, specialized & heuristic triangulator.

I finished these steps:

  • Finding out what is outline and what is a hole (winding rule works fine)
  • Find out which outline a hole belongs to (the holes come directly after their enclosing outline)
  • Connect all holes with their enclosing outline -> creating a closed polygon without holes (this is heuristic and may theoretically fail)

    Now I plan to do this:
  • split all concav polygons into convex ones (that is the hard part)
  • draw all diagonals of one point of a convex polygon -> triangulation of the convex poly (that's easy)

    Any ideas?

If the word you want is fixed - ie "Game Over", maybe worth adding a serializer for it.

Could possibly do cool effects like the phrase "Game Over" looking like a mountain made of rock that cracks and breaks into a pile of rubble

I guess it's no problem to generate static text in some editor, and there you can get a triangulation much better than mine. The main purpose of my class is to create 3d text "on the fly", and if it's not too long, too smooth (flatness parameter) and doesn't use a fancy font, it should work.

I try to optimize it a bit, and probably to include texture coordinates.

And of course I've to find out why I get e.g. an "o" without hole for for some fonts. May be one of you has an idea…

BTW: The Triangulator class can be used "stand alone". It makes triangulation of simple, flat polygons (without holes) in the x-y-plane. It's easy and works quite stable. However don't expect to get a "high quality" triangulation (e.g. like Delauny).

May be it would be a good idea to have a general-purpose-high-quality-triangulation class (maybe plus Stripifier) in JME. Or am I the only one missing it? :?

BTW: Has somebody tried out my font classes?

Hi Landei,

i'm interested in it, but din't found time to test it for now. But i will do.

I'm also interested in Your work Landei and will try it out soon.

The fonts look cool. I tried them out (had to fix them to the new jME 0.10 TriMesh/GeomBatch thing, but they work. I do however have two problems with them.

  1. When loading "Knights Templar" font, I get a nullpointer exception when filling the holes. This I intend on fixing.
  2. When loading a font from a stream (good way to supply your own fonts) Eclipse crashes (I am developing in Eclipse, and run it from Eclipse… this i wierd).

    I am going to implement a class which will be a merge of your class and the class in jME for fonts. The idea is to create a geometry for each letter and then just render the display-list when rendering a string of text. If this is of interest to anyone I will be happy to post it here, once its working.

Well that was not quite enough. There seems to be something wrong with the triangulation-algorithm. You are using Grahams Scan, which works on simple polygons. Most glyphs are not simple, because they have holes. It seems you have tried to somehow work around this, by removing the holes after grahams scan has triangulated the outer polygon. There is no reason to make it that complicated, algorithms for polygons with holes exist. But there seems to be a problem in the fact that you separate the polygons and holes as seperate polygons instead of letting them both be part of the same planar subdivision.

As I see it, the clean solution would be doing the following:

Glyph -> Planar subdivisions: Pirx: Existing code with some modifications.

Planar subdivision -> Monoton polygons: Lee and Preparata - "Location of a Point in a planar subdivision and its applications"

Monotone polygons -> Triangles: Garey et. al. - "Triangulating a simple polygon"

I will see if I can implement the algorithm before nightfall. Should be fairly straight forward.

Mr Oak, are you a developer at Gamalocus? If so, are you using or planning on using jME for your products? just curious

Well, according to the jmonkeyengine.com front page they are :slight_smile:

(OffTopic) We are :), and untill now we have been quite happy about it, jMe is not complete, but its feature-rich and the development of jMe is very much alive(/OffTopic).

llama said:

Well, according to the jmonkeyengine.com front page they are :)

sorry missed that...not very often i read that page :)

nice that you use it, we need more "real" developers...how come Jadestone isn't on that list? ;)

I wasn't aware that Jadestone's use of jME was public knowledge…  Hehe, but I guess it is now if it wasn't.  Adding…

Haha you are right…hmm…if you don't see any more posts by me, it's because i got fired :slight_smile:

Finally, cleared the last bug, completed the normal-calculation-stuff, and made some really boring screenshots. (The link to the source is the same).


Screen (1):


Now, I would like to discuss how this could be even better. Here are a few of the thoughts I have:

  • It would be great if it was more like the existing 2D font of JME. Especially it would be nice if each glyph was a display-list so drawing a lot of text will not require too much trafic pumping the vertex-data to the GPU.

  • It could be great if we could add a threshold to the angle of the normals on the surface. Just like smooth-groups (3DS) or Autosmooth (Blender). That way, we can have smooth normals on the surface where appropriate, and edges where the outline has a sharp angle.

  • Outline, and other effects. We should implement the Font3D and Text3D so that it would be easy to implement different effects, like outlining the fonts and such.

  • Only load the glyphs you want. When using the standard fonts you almost get a full 256 glyphs as it is now, you will most likely not need them all. Also, you might want some of the other glyphs (id > 256) because there lies all the chinese stuff, and Java is multichar anyways so it would be great.

  • Make the triangulation closer to a Delaunay triangulation (That is maximize the smallest angle). This would both make better render-results, and it would "remove" degenerate triangles.

  • Saving/Loading to XML (now with the new and improved save/load interfaces, we should be able to save load text, or maybe fall back to TriMesh-saving).

Please anyone with interrest in this feature, please join the discussion. Also, devs of jME, consider if this would be something for the core of jME. If we could make it easy to use and some nice effects this would be a great feature for the engine.

Thats really looking nice. Good work

Finally, after many days of work, I got the algorithm for triangulation complete. I am telling you, reading the algo is easy, understanding it is easy, but making it work with all the different degenerate cases is a completely and utterly different story !!!

But here it is, it became some more classes.


And here is an example usage:

Font basefont = new Font("Arial", Font.BOLD, 1);
Font3D.loadFont3D("ArialBold", basefont, 0.01);
Text3D mytext = Font3D.createText("ArialBold", "Here we use the 3D Font, its cool !!", 1, true, true, false);

There are still a few unresolved errors. First of all, there are no normals, second there still seems to be a very little bug hidden in the triangulation of the y-monotone polygons, but I will find it before the day is over.