papervision logo

8:27 pm Flash, Programming, ade's stuff

made a new flash thing today… it’s made with Flash CS3, Papervision3d in Actionscript 3.

concept: make a logo in flash with the 3d library papervision… the idea was to take a small image with the text “ade.se” and make every pixel into a cube in a 3d scene, where the cubes or pixels would come flying into the view, and eventually form the textual image in a nice perspective.

i started with the basics (haven’t made anything other than a few easy tutorials in flash/papervision/actionscript 3 before) and created the scene with a placeholder rectangle (to show the final position of the cubes). then I made a class to handle the cubes, which has a few important functions, setPos, setTargetPos, and moveCloser(speed). the thought is to have the first frame in the movie set up the cubes at random positions and then invoke moveCloser at every rendered frame which causes the cubes to move one step closer to their target position.

the first problem was to make the cubes move in a nice manner toward their goal.

you need to make them move at different speeds in every dimension, as they will be at a different distance in X, Y and Z from their target. here’s a cube moving to pixel position 0, 0 with the reference rectangle visible: movement.htm


also, I needed to make sure that i could actually handle having so many cubes rendered at one time… I created a image in photoshop to act as the target, each (colored) pixel representing a cube and its final position. I settled for a image size of 80×19. selecting the colored pixels with the wand and quick look at the histogram window reveals that there will be 790 cubes needed:

target image

remember that every cube has 6 faces, and 2 triangles for each face. that means 9480 triangles to render in total. this would be a laugh for every computer today in a normal 3d-accelerated environment, but working with it here in a high level unaccelerated state is a bit different. i created a basic benchmark to see how it ran. as you can see, the FPS is acceptable but not very good… benchmark.htm

as creating 790 objects by hand and giving them the right properties would take a long time and be immensely boring, I made a small app in visual basic 6 to read the image and spit out a finished script.

here’s the result! (click it to randomize cube positions)

One Response

  1. Nat Says:

    Hi Ade

    great stuff… really great…

    I am planing to do something similar… so my question: would you share your code? and the app. to get the right properties for all the cubes? This would really help a lot…

    Thanks, Nat

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Posting more than 2 links in your comment will put the comment in the moderation queue.