Li : Dev Actionscript Development Blog

29Sep/09Off

Voronoi Noise

Click on the image to see the demo, right click view source enabled.

'Morley noise' or 'cell noise' can be produced by laying out a random set of points and then coloring each pixel according to the distance to the CLOSEST of the layed out points. This can involve a pretty serious amount of calculation since for each pixel, distances have to be calculated to all the points in order to use the smallest distance to obtain the color value. To speed things up, the points are usually layed out in cells so that a pixel only needs to be checked against the point in the cell and neighboring cells. This reduces calculations. There's a good explanation of this HERE.

What I've done is an attempt to be even quicker. I'm using Hrito's amazingly fast implemantation of a fortune's algorithm ported from c, that finds the Voronoi edges of a random distribution of points. I altered his code a bit so that it can output triangles also. I defined these triangles as a vorono edge joined to the focus points of its neighboring cells. With this, the experiment sweeps the triangles and fills 'em up. Each pixel already knows what point to calculate its distance to, hence reducing the calculations even further. The code has some graphical glitches and is only for demonstration purposes so I can assure that it can be made way faster and better.

Uses of this? I think a LOT. Besides what has been discussed above, this sort of algorithms could be used to obtain very fast Delaunay Triangulations, which can be used for a milliard of things in 3D; they provide an optimal triangulation method for a given set of points. I'm, eager to experiment in these.

Filed under: General Comments Off
2Sep/09Off

Warping text in Away3D [UPDATED]

[UPDATE] You can find a couple of demos for this in THIS post in the Away3D site.

One of the things I've been wanting for Away3D for a while is the ability to warp a textfield onto a bezier path and animate the text along the path. The proper way of doing this is not just to position and rotate the characters to fit the path, but to actually deform them to adapt to the path. To do this, the x dimension of the text is transformed into an arc-length parameterized value along the path's length and the other 2 dimensions are then recalculated in this new space.

When it comes to a feature like this its usually much harder for me to develop, but this time I must admit it was pretty simple thanks to THIS amazing almost cheat-like resource from Jay Clegg.

Click on the image to see the demo (use the keyboard and mouse to move around). I plan to refine this and upload a full demo/example soon. For now, If you wish to play with it, take a look at the new "AlignToPath.as" class in the geom package of Away3D for fp10.

Filed under: 3D, Tutorials Comments Off