Author Archives: Zevan

drawTriangles() & z-sorting

CLICK HERE TO COPY
Actionscript:

[SWF(width = 500, height=500, backgroundColor = 0x000000)]

x = stage.stageWidth / 2;

y = stage.stageHeight / 2;

 

// standard Vectors for using drawTriangles and projectVectors

var verts:Vector.<Number> = new Vector.<Number>();

var pVerts:Vector.<Number>;

var uvts:Vector.<Number>;

var indices:Vector.<int>;

// needed for z-sorting

var sortedIndices:Vector.<int>;

var faces:Array = [];

 

// we'll use this for transforming points

// and as the transformation matrix for our render

var m:Matrix3D = [...]

Posted in 3D, Graphics, Vector, matrix | Tagged , , , , | 3 Comments

globalToLocal() in 3D

CLICK HERE TO COPY
Actionscript:

[SWF(frameRate=60, backgroundColor=0x000000, width=500, height=500)]

stage.quality = "medium";

var frame:Sprite = Sprite(addChild(new Sprite()));

with (frame.graphics) beginFill(0xCCCCCC), drawRect(-200, -200, 400, 400), endFill();

frame.x = stage.stageWidth / 2;

frame.y = stage.stageHeight / 2;

frame.z = 100;

 

var canvas:Shape = Shape(frame.addChild(new Shape()));

var msk:Shape = Shape(frame.addChild(new Shape()));

with (msk.graphics) beginFill(0x00FF00), drawRect(-200, -200, 400, 400), endFill();

canvas.mask = msk

 

var txt:TextField = TextField(addChild(new TextField()));

txt.defaultTextFormat = new TextFormat("_sans", 12);

txt.x [...]

Posted in 3D, DisplayObject, Graphics, misc, motion | Tagged , , | 3 Comments

3D Key Controls

CLICK HERE TO COPY
Actionscript:

[SWF(backgroundColor=0x000000, width=500, height=500)]

var hsw:Number = stage.stageWidth / 2;

var hsh:Number = stage.stageHeight / 2;

var pointNum:int = 300;

var points3D:Vector.<Number> = new Vector.<Number>();

var points2D:Vector.<Number> = new Vector.<Number>();

var uvts:Vector.<Number> = new Vector.<Number>();

var sorted:Array = [];

var pnt:Point = new Point();

var m:Matrix3D = new Matrix3D();

var v:Vector3D = new Vector3D();

for (var i:int = 0; i<pointNum; i++){

    v.x = [...]

Posted in 3D, Graphics, Vector, keys | Tagged , , | 3 Comments

Simple z-sorting

CLICK HERE TO COPY
Actionscript:

[SWF(backgroundColor=0x444444, width=500, height=500)]

var hsw:Number = stage.stageWidth / 2;

var hsh:Number = stage.stageHeight / 2;

 

var pointNum:int = 200;

var points3D:Vector.<Number> = new Vector.<Number>();

var points2D:Vector.<Number> = new Vector.<Number>();

var uvts:Vector.<Number> = new Vector.<Number>();

var sorted:Array = [];

 

var pnt:Point = new Point();

var m:Matrix3D = new Matrix3D();

var v:Vector3D = new Vector3D();

for (var i:int = 0; i<pointNum; i++){

    v.x = [...]

Posted in 3D, Graphics, Vector, sortOn | Tagged , , | 5 Comments