Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
ActionScript
package { import flash.display.*; import flash.geom.*; import flash.events.*; [SWF(width = 500, height=500, backgroundColor = 0x000000)] public class QuadLights extends MovieClip { private var quadNum:int; private var verts:Vector.
; private var pVerts:Vector.
; private var uvts:Vector.
; private var indices:Vector.
; private var sortedIndices:Vector.
; private var faces:Array; private var m:Matrix3D; private var quad:Vector.
; private var transQuad:Vector.
; private var i:int; private var inc:int; private var tex:BitmapData; private var grad:Shape; private var mat:Matrix; private var render:Shape; private var persp:PerspectiveProjection; private var proj:Matrix3D; private var dx:Number; private var dy:Number; public function QuadLights(){ init(); } private function init():void{ // init x = stage.stageWidth / 2; y = stage.stageHeight / 2; quadNum = 2200; // standard Vectors for using drawTriangles verts = new Vector.
(); pVerts; uvts = new Vector.
(); indices = new Vector.
(); // needed for z-sorting sortedIndices; faces = []; // we'll use this for tranforming points // and as the transformation matrix for our render m = new Matrix3D(); // plot a quad quad; quad = Vector.
([-10, -10, 0, 10, -10, 0, -10, 10, 0, 10, 10, 0]); // temp vect for any transformed quads transQuad = new Vector.
(); i; inc = 0; for (i = 0; i
(indices.length, true); // create texture tex = new BitmapData(400,400,false, 0x000000); grad = new Shape(); mat = new Matrix(); mat.createGradientBox(400,400,0,0,0); with (grad.graphics){ beginGradientFill(GradientType.LINEAR, [0xFFFFFF,0x002244], [1, 1], [100, 255], mat); drawRect(0,0,400,400); } tex.draw(grad); // create background mat.createGradientBox(1600,1200,0,-550, 0); with (grad.graphics){ beginGradientFill(GradientType.RADIAL, [0x000000, 0x001133], [1, 1], [0, 255], mat); drawRect(0,0,500,500); } grad.x = -stage.stageWidth/2 grad.y = -stage.stageHeight/2; addChild(grad); // triangles will be drawn to this render = Shape(addChild(new Shape())); // fix all vector lengths verts.fixed = true, uvts.fixed = true, indices.fixed = true pVerts = new Vector.
(verts.length/3 * 2, true); // we need these if we want perspective persp = new PerspectiveProjection(); persp.fieldOfView = 45; // projection matrix proj = persp.toMatrix3D(); dx = 0, dy = 0; addEventListener(Event.ENTER_FRAME, onLoop); } // private methods private function onLoop(evt:Event):void { dx += (mouseX - dx) / 4; dy += (mouseY - dy) / 4; m.identity(); m.appendRotation(dy, Vector3D.X_AXIS); m.appendRotation(dx, Vector3D.Y_AXIS); m.appendTranslation(0,0,800); m.append(proj); Utils3D.projectVectors(m, verts, pVerts, uvts); var face:Vector3D; inc = 0; for (var i:int = 0; i
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email