matArte

2010-09-26 at 17:02 | Posted in Computer path | Leave a comment
Tags: , , , , , , , , , , , , , , , ,

Next Thursday begins matArte exhibit. It is hosted by ‘Cafe de la prensa’ at Seville, c/Betis 8. Features 13 synthetic images obtained through maths and patience. Below is the official poster, also rendered with the Raydiant engine. I’ll be there October the second from 6:00 PM. It’s exciting to have this opportunity to share visual maths though computer power. Perhaps those who know numbers are beautiful will enjoy it and those who still don’t could shift their belief.

How to create 3D True Type text

2010-09-11 at 21:36 | Posted in Computer path | Leave a comment
Tags: , , , , , , , , , , , , , , , ,

I use Raydiant mainly as a procedural builder & renderer so having the ability to write 3D true types makes things more spicy. Allowing for easily (meaning procedurally) introducing all kind of sings and messages. I though it was going to be a piece of cake. Sure I can take a TTF and build a 3D volume accordingly, it will take 2 or 3 days.

As it became clear a week later it was going to be a little more trouble than I previewed, and also a lot more fun!. If you want to also add this functionality to some software this is what I did:

  • First your have to use some kind of API to get the outlines and holes the TTFs are made off. Depending on your SO and your lib of choice your will receive different kinds of data. I will suppose in this example that you can get a list of poly lines (lets call it PL) for any text string you want to draw. These polygons can be convex and also they can mean outlines or holes. As I learned the hard way these polys can also mutually intersect when 2 characters are next to each other and have unusual shapes (like hand writing fonts for example). The text is supposed to be aligned with the front plane at building time. A left-handed reference system will be used (positive Y goes upward, positive X goes to the right and positive Z goes ahead.
  • Create text sides: for each PL poly line segment build a square polygon having that segment as a side and as opposite side the same segment a little further away (increased Z). The Z increment defines the thickness of the final 3D text. Decompose each square into 2 triangles and we have the sides triangle list.
  • Now the thing to do is characterized every PL poly line so you can later build a 3D volume from them. First some definitions:
    • outline:
      • polygon with every vertex outside every other polygon
      • or polygon with every vertex immediately inside a hole polygon (there isn’t any polygon between it and the hole polygon)
      • or the polygon with more vertex not inside any polygon.
    • hole: polygon with every vertex immediately inside an outline.
    • a polygon A is considered to be immediately inside another B if and only if A has every vertex inside B and it does not exist a polygon C that contains A and is contained by B.
  • Assumption: the polygons intersect each other only slightly (actually this is a very bad math definition, but it works for me).
  • Algorithm:
    • 1. Find the mutual inclusion relation between every 2 PL poly lines.
    • 2. For each poly A which is not included by any other:
      • 2.a. Find all PL poly lines B[…] immediately inside A.
      • 2.b. Triangulate A as an outline with holes = B[…], accumulate triangles into front face and back face triangle list. The only difference between these 2 lists is a Z increment equal to the desired text thickness.
      • 2.c. Delete A and B […] from the list of polys and update inclusion of the rest of the polys.
  • How to triangulate a polygon with holes: this a well covered aspect on computational literature. The one that finally did the trick for me is an horizontal decomposition as described by Seidel (1991) extended to handle holes.
  • After all the effort at last you have 3 lists (sides list, front face list and back face list) defining 3D polyhedrons confined by triangles. This should be very easy to draw using any 3D API.

First picture is a example of what you get from a TTF API. Spheres mark the first vertex of each poly line (at the back a disastrous fill attempt shows why is necessary to triangulate). Then some wire-frame front face triangulations made with the described procedure, some 3D wire frames and some HQ renders from Raydiant engine:

Blog at WordPress.com.
Entries and comments feeds.