# Creating a 3D text mesh from a 2D glyph

I have thought of three steps for doing this:

1. Acquire the vertex coordinates which will represent the glyph's form
2. Extrude them
3. Render

Can you suggest a better method? Can you give me an insight on how to do the first and the second step?

I use FreeType 2.4.10 for text managment.

-
Look at this answer. – ErikEsTT Sep 7 '12 at 9:36
Thanks, but a third party library would be my last resort. I would like to see how this works under the hood. – Tsvetan Sep 7 '12 at 9:53
In that link is GLTT and FTGL, both using FreeType ( 1 or 2 ) and both open source, so you can see what is under the hood. – ErikEsTT Sep 7 '12 at 10:23

I think, without a library, this would require quite a few steps, but it is certainly possibly.

First convert the letter to a polygon (look at the bitmap to polygon algorithms) and then that polygon to a set of triangles using a technique that supports holes in the polygon, see this wiki page. You now have a flat model built out of triangles.

Now draw the models two times. Once at (0,0,0) and once at (1,0,1) (for an effect with a shear to far away-right).

You should now have something like the picture below, but you're still missing the triangles that connect the two models and make it look 3D.

Vertices A and C are parts of the triangles of the black (front) model. Vertices B and D are parts of triangles of the white (back) model. You now have to draw triangles between them for the 3D effect. Just draw a triangle from A,B,D and from A,C,D. You have now achieved the 3D-shear effect you're looking for.

Optimizations

You are going to draw more triangles then you need. You don't need to draw triangles between vertices which, when connected, would cut the model. You should number/sort vertices on the edge loop and only draw triangles between (M1[x], M1[x+1], M2[y]) and alternate (M2[x],M2[x+1],M1[y]). I don't know of a readily available algorithm to detect and sort these edge loops, but take a look at how you generate vertices when triangulizing your polygon, there might be a hint/implicit sorting there. It would be even better if you can sort some sort of index buffer so that you can use a trianglestrip.

-