views:

383

answers:

2

I have an NSString which is splitted into set of characters.

I need to render these set as a cloud of characters and:

  • characters must be placed in 3D
  • characters must have random rotation and scale
  • different fonts can be used

The proper way is to use OpenGLES framework. Please advice some samples, examples or direction to start.

+1  A: 

Render the characters as textures on quads. Then you can manipulate them in 3D to your heart's desire...

See: This question/answer for some more details.

Ali Parr
Thanks. Can you share some small example how to render one character as textures on quads? As I am novice in this area so your help will be very appreciated.
sashaeve
There are probably other methods of doing this, but the way that has worked for me:Firstly, you need to create a texture atlas (A single large texture), with all the characters in it. http://blogs.agi.com/insight3d/wp-content/uploads/2008/08/textureatlas.pngThen you need to write an algorithm that will generate quads of the right size, and with the right uv coordinates to display those glyphs. You can get this data out of the font using a library like Freetype.It sounds complex but it's really not so bad.
Ali Parr
+1  A: 

You say that OpenGL ES is the "proper way to do this", but I would suggest looking at Core Animation for this kind of a task. You can easily create a series of UILabels, one for each character in your cloud, with random fonts assigned to the labels. You would need to place these UILabels within a subview, and assign them a 3-D location using the position and zPosition properties of the UILabel's layer. A random rotation and / or scaling in 3-D can be applied using CATransform3DRotate() or CATransform3DScale(). An example of the kind of 3-D manipulations you can do to CALayers can be found here.

Using Core Animation for this task will require far less code than pure OpenGL ES, because you won't have to manage the manual text drawing yourself, and Core Animation handles all of the 3-D rendering for you.

Brad Larson