topical media & game development
#graphic-flex-image-effects-06-Flex-FieldOfViewTest.ax
#graphic-flex-image-effects-06-Flex-FieldOfViewTest.ax
[swf]
[flash]
flex
package {
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.PerspectiveProjection;
import flash.geom.Point;
[SWF(width=600, height=400, backgroundColor=0x000000)]
Demonstrates how different fields of view can affect shapes drawn in 3D.
public class @ax-graphic-flex-image-effects-06-Flex-FieldOfViewTest extends Sprite {
Constructor. Creates new PerspectiveProjection for this sprite,
then draws 3 planes in 3D space.
public function @ax-graphic-flex-image-effects-06-Flex-FieldOfViewTest() {
var projection:PerspectiveProjection = new PerspectiveProjection();
projection.projectionCenter = new Point(stage.stageWidth/2, stage.stageHeight/2);
// alter field of view to see effects
projection.fieldOfView = 150;
transform.perspectiveProjection = projection;
createPlane(0xFF0000, 100, 200, 100, -45);
createPlane(0xFF0000, 300, 200, 180, 0);
createPlane(0xFF0000, 500, 200, 100, 45);
}
Creates a plane of the specified color at the specified position and rotation.
parameter: color The color of the plane.
parameter: x The x position of the plane.
parameter: y The y position of the plane.
parameter: z The z position of the plane.
parameter: rotationY The rotation of the plane on the y axis.
private function createPlane(
color:uint,
x:Number,
y:Number,
z:Number,
rotationY:Number
):void {
var plane:Shape = new Shape();
plane.graphics.beginFill(color);
plane.graphics.drawRect(-100, -100, 200, 200);
plane.graphics.endFill();
plane.x = x;
plane.y = y;
plane.z = z;
plane.rotationY = rotationY;
addChild(plane);
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.