13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working in three dim<strong>en</strong>sions (3D)<br />

The UV 0 and 1 locations on a bitmap image<br />

Vectors of a triangle can be giv<strong>en</strong> UV coordinates to associate themselves with the respective locations on an image:<br />

The UV coordinates of a triangular area of a bitmap image<br />

The UV values stay consist<strong>en</strong>t with the points of the triangle:<br />

The vertices of the triangle move and the bitmap distorts to keep the UV values for an individual point the same<br />

As ActionScript 3D transformations are applied to the triangle associated with the bitmap, the bitmap image is applied<br />

to the triangle based on the UV values. So, instead of using matrix calculations, set or adjust the UV values to create a<br />

three-dim<strong>en</strong>sional effect.<br />

The Graphics.drawTriangles() method also accepts an optional piece of information for three-dim<strong>en</strong>sional<br />

transformations: the T value. The T value in uvtData repres<strong>en</strong>ts the 3D perspective, or more specifically, the scale<br />

factor of the associated vertex. UVT mapping adds perspective correction to UV mapping. For example, if an object is<br />

positioned in 3D space away from the viewpoint so that it appears to be 50% its “original” size, the T value of that object<br />

would be 0.5. Since triangles are drawn to repres<strong>en</strong>t objects in 3D space, their locations along the z-axis determine their<br />

T values. The equation that determines the T value is:<br />

T = focalL<strong>en</strong>gth/(focalL<strong>en</strong>gth + z);<br />

In this equation, focalL<strong>en</strong>gth repres<strong>en</strong>ts a focal l<strong>en</strong>gth or calculated "scre<strong>en</strong>" location which dictates the amount of<br />

perspective provided in the view.<br />

Last updated 6/6/2012<br />

365

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!