Quick & Easy 3D (lab experiment)

[color=black][font=Arial]Ok say you want to use Flash in 3-D but you don’t know how to begin.<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>[/font][/color]

[color=black][font=Arial]Checklist:[/font][/color]
[color=black][font=Arial]1.) Learn Basic 3-D Programming<o:p></o:p>[/font][/color]
[color=black][font=Arial]2.) Learn to Rotate Your Surfaces<o:p></o:p>[/font][/color]
[color=black][font=Arial]3.) Learn to Texture<o:p></o:p>[/font][/color]

[color=black][font=Arial]<o:p></o:p>[/font][/color]

[color=black][font=Arial]Requirements:<o:p></o:p>[/font][/color]
[color=black][font=Arial]A 1Ghz PC for 3-D animations (600x400 window/full-screen)<o:p></o:p>[/font][/color]

[font=Verdana]1.) [/font]First start with some squares and promote them to graphic objects. Flash calls this ‘Converting into an Object or Creating Objects’: which can be movies, buttons or graphic objects. Create a grid of squares 3 or 4 pixels high that is 8x8 pixels. Each square should be a “Graphic” object, not a Button or a Movie. You can make them all lined up evenly using the align menu. Make this grid into a new graphic object and call it “Boxes: Layer #1”. Now create more grids and scale them to make a 3-D box. Move them around and scale them all so you can ‘see’ under the box, over it and to the side.

<o:p></o:p>
Finally, rotate one of your grids through the motions – as if it were a part of a cube rotating in space. Now rotate the other grids the same way, but Delay them, so they play one after the other until the first grid loops by. Now you have a rotating sphere in 3-D.

<o:p></o:p>
Timeline management is up to you. Everything can be on one layer for now or a movie object. Move and scale this around the window and realize that you have a lot of blocks. If you scale and move them correctly, they look 3-D. Another test animation you can try: Imagine a snake of boxes moving along the screen back and forth. If the boxes get bigger and smaller as the snake moves, it looks like it’s moving in 3-D. You can make ‘holes’ and make the snake disappear and re-appear (scaling larger out from another hole). Try using masks to hide layers behind other layers to preserve clipping.

<o:p></o:p>
With a grid of boxes you can make 3-D boxes, and 3-D terrain, and simple polygon animations.

<o:p></o:p>
[font=Verdana]2.) [/font]You need to know ActionScript so you can really control each graphic object, movie clip or button. Then you can move it along X and Y and scale it along Z. Z is always a trick because it’s not really 3-D, we are scaling the image based on the perspective and distance from the screen. A movie clip that goes from 1 pixel to 600 pixels wide looks like it’s getting closer.

Using Free Transform you can use advanced rotation and create full 3-D worlds. You can import 3-D data into Flash using external text (comma-delimited export data from a 3-D program of a Vase or Lamp), or you can create the object in Flash. Once you know ActionScript and 3-D animation,

<o:p></o:p>
[font=Verdana]3.) [/font]Textures work well in Flash, but usually you get the best results if you trace the bitmap. Textures are nice because you can adjust the alpha level, giving you transparent mip-maps! If the scale is between 0-10%, one traced bitmap is used. At larger and larger scales, more detailed bitmaps can be used.


Bounding boxes in 3-D:
You have your minimum and maximum y (left and right boundaries), and x (top and bottom boundaries). You can “create” a 3-D bounding box by watching the scale of the object. If the object scales too much, say > +40 and < -20(inverted), then you can set scalemaximum and scaleminimum the same way.

Tracking object hits in 3-D:
If the vertex of the square is within range of the minimum and maximum values, you can register a hit. If the object is irregular shaped, you can calculate it different ways instead of using vertices.

Layers in 3-D:
For good 3-D, you need good 3-D clipping. This means you need copies running on different layers, which you can clip and mask depending on what happens in the 3-D world. Once the scale, or the minimum/maximum x/y is hit, you can ‘show’ the layer that obscures the background objects – a copy of the main foreground object. For each object in your 3-D universe, you’ll need to add OnClip events so they are hidden/shown accurately.

I’m setting up a demo of these principles on my portfolio website. When it’s done I’ll post the example here if you want to see the code. The work in progress that passes muster is located at: http://benjaminlindelof.tripod.com/ It’s the game demo. Let me know what you think.

Topics I am still looking into:
Enemy A.I.
Friendly A.I.
Pure Pyramidal Mip-Map ActionScript that supports 10 levels of detail.<!-- / message -->

<o:p></o:p>
JPEGs and vector graphic rules/recommendations apply in Flash like they do anywhere, so it depends on the application.

<o:p></o:p>
Any free 3-D Flash engines out there?

This is my favorite page for checking on the latest 3D Flash updates.
http://www.active-web.cc/html/research/ … if you have a few weeks to read it all!

Posted on kirupa Forums<o:p></o:p>