flash on 2014-10-26
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/53o4
*/
package {
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.display.BitmapData;
import flash.geom.Vector3D;
import flash.geom.Matrix3D;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
backPic = new BitmapData(64,64,false,0x424253);
backPic.fillRect(new Rectangle(0,0,32,32),0x80);
backPic.fillRect(new Rectangle(32,32,32,32),0x80);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}///ctor
public var backPic:BitmapData;
public var gt:int = 0;
public var temp2:Matrix = new Matrix();
public var temp:Matrix3D = new Matrix3D();
public function onEnter(e:Event):void
{
var mx:Number; var my:Number;
mx = stage.mouseX; my = stage.mouseY;
var ax:Number; var ay:Number;
ax = (mx - 230 ) / 460;
ay = (my - 230) / 460;
ax *= 2; ay *= 2;
temp.identity();
temp.appendScale(3, 3, 3);
//temp.appendRotation(gt, Vector3D.X_AXIS);
temp.appendRotation(90, Vector3D.X_AXIS);
temp.appendRotation(180, Vector3D.Y_AXIS);
temp.appendRotation(ax*-45, Vector3D.Y_AXIS);
temp.appendRotation(ay*45, Vector3D.X_AXIS);
temp.appendTranslation(230, 260, 0);
graphics.clear();
temp2.identity();
// temp2.rotate(gt*0.01);
temp2.translate(gt,Math.sin(gt*0.01)*64);
//graphics.beginFill(0,1);
graphics.beginBitmapFill(backPic,temp2,true,false);
graphics.drawRect(0,0,465,465);
graphics.endFill();
graphics.lineStyle();
drawMesh(vecVert, temp.rawData);
gt += 1;
}//onenter
//vec -- 9 number per triangle
public function drawMesh(vec:Vector.<Number>, mat:Vector.<Number>):void
{
var rx:Number; var ry:Number; var rz:Number;
var sx0:Number; var sy0:Number;
var sx1:Number; var sy1:Number;
var sx2:Number; var sy2:Number;
var wind:Number;
var i:int; var num:int;
num = vec.length;
for (i = 0; i < num; i += 9)
{
rx = vec[i]; ry = vec[i+1]; rz = vec[i+2];
sx0 = rx * mat[0] + ry * mat[4] + rz * mat[8] + mat[12];
sy0 = rx * mat[1] + ry * mat[5] + rz * mat[9] + mat[13];
rx = vec[i+3]; ry = vec[i+4]; rz = vec[i+5];
sx1 = rx * mat[0] + ry * mat[4] + rz * mat[8] + mat[12];
sy1 = rx * mat[1] + ry * mat[5] + rz * mat[9] + mat[13];
rx = vec[i+6]; ry = vec[i+7]; rz = vec[i+8];
sx2 = rx * mat[0] + ry * mat[4] + rz * mat[8] + mat[12];
sy2 = rx * mat[1] + ry * mat[5] + rz * mat[9] + mat[13];
//backface cull -> check winding of verts
wind = (sx1 - sx0) * (sy2 - sy0) - (sx2 - sx0) * (sy1 - sy0);
if (wind > 0) { continue; }
graphics.beginFill(i, 0.75);
graphics.moveTo(sx0, sy0);
graphics.lineTo(sx1, sy1);
graphics.lineTo(sx2, sy2);
graphics.endFill();
}//nexti
}//drawmesh
// raw mesh data
public static var vecVert:Vector.<Number> = Vector.<Number>([
22.3,-16.4,-4.8, 26.0,0.0,-4.8, 34.2,2.0,13.8, 34.2,2.0,13.8, 29.3,-21.4,5.4, 22.3,-16.4,-4.8, 22.3,16.3,-4.8, 3.0,23.8,-7.2, 3.0,26.9,1.4, 22.3,16.3,-4.8, 3.0,26.9,1.4, 11.3,26.8,6.3, 22.3,16.3,-4.8, 11.3,26.8,6.3, 29.3,25.4,15.8, 22.3,-18.1,18.5, 3.0,-22.9,19.0, 3.0,-26.3,2.8, 3.0,-26.3,2.8, 29.3,-21.4,5.4, 22.3,-18.1,18.5, 22.3,20.4,19.3, 26.0,0.3,19.4, 34.2,2.0,13.8,
34.2,2.0,13.8, 29.3,25.4,15.8, 22.3,20.4,19.3, 23.5,-17.2,23.2, 3.0,-24.5,22.6, 3.0,-22.9,19.0, 3.0,-22.9,19.0, 22.3,-18.1,18.5, 23.5,-17.2,23.2, 22.3,20.4,19.3, 21.0,18.3,33.1, 26.8,2.1,25.8, 26.8,2.1,25.8, 26.0,0.3,19.4, 22.3,20.4,19.3, 22.3,20.4,19.3, 29.3,25.4,15.8, 11.3,26.8,6.3, 11.3,26.8,6.3, 10.9,25.1,19.3, 22.3,20.4,19.3, 11.3,26.8,6.3, 3.0,26.9,1.4, 3.0,26.8,4.1,
10.9,25.1,19.3, 3.0,25.1,21.4, 3.0,24.4,26.5, 10.9,25.1,19.3, 11.3,26.8,6.3, 11.3,38.3,8.7, 11.3,38.3,8.7, 10.9,36.0,19.0, 10.9,25.1,19.3, 3.0,26.8,4.1, 3.0,39.2,6.4, 11.3,38.3,8.7, 11.3,38.3,8.7, 11.3,26.8,6.3, 3.0,26.8,4.1, 22.3,16.3,-4.8, 29.3,25.4,15.8, 34.2,2.0,13.8, 34.2,2.0,13.8, 26.0,0.0,-4.8, 22.3,16.3,-4.8, 22.3,-18.1,18.5, 29.3,-21.4,5.4, 34.2,2.0,13.8,
34.2,2.0,13.8, 26.0,0.3,19.4, 22.3,-18.1,18.5, 22.6,-16.4,27.9, 23.5,-17.2,23.2, 26.8,2.1,25.8, 26.8,2.1,25.8, 25.5,3.8,32.2, 22.6,-16.4,27.9, 22.3,-16.4,-4.8, 3.0,-21.2,-7.2, 3.0,1.3,-11.2, 3.0,1.3,-11.2, 26.0,0.0,-4.8, 22.3,-16.4,-4.8, 21.5,9.3,40.6, 19.7,16.3,38.0, 3.0,23.8,42.7, 21.5,9.3,40.6, 3.0,23.8,42.7, 3.0,1.5,47.0, 17.1,3.7,43.4, 21.5,9.3,40.6, 3.0,1.5,47.0,
25.5,3.8,32.2, 21.5,9.3,40.6, 17.1,3.7,43.4, 34.3,-25.0,43.6, 37.4,-23.4,36.5, 41.9,-14.5,38.3, 41.9,-14.5,38.3, 38.7,-14.7,45.0, 34.3,-25.0,43.6, 17.1,3.7,43.4, 14.0,-18.0,39.6, 24.7,-22.4,48.6, 24.7,-22.4,48.6, 27.7,-4.0,52.5, 17.1,3.7,43.4, 14.0,-18.0,39.6, 22.6,-16.4,27.9, 25.4,-20.8,42.9, 25.4,-20.8,42.9, 24.7,-22.4,48.6, 14.0,-18.0,39.6, 22.6,-16.4,27.9, 25.5,3.8,32.2, 29.0,-3.9,40.0,
29.0,-3.9,40.0, 25.4,-20.8,42.9, 22.6,-16.4,27.9, 25.5,3.8,32.2, 17.1,3.7,43.4, 27.7,-4.0,52.5, 27.7,-4.0,52.5, 29.0,-3.9,40.0, 25.5,3.8,32.2, 27.7,-4.0,52.5, 24.7,-22.4,48.6, 34.3,-25.0,43.6, 34.3,-25.0,43.6, 38.7,-14.7,45.0, 27.7,-4.0,52.5, 24.7,-22.4,48.6, 25.4,-20.8,42.9, 37.4,-23.4,36.5, 37.4,-23.4,36.5, 34.3,-25.0,43.6, 24.7,-22.4,48.6, 25.4,-20.8,42.9, 29.0,-3.9,40.0, 41.9,-14.5,38.3,
41.9,-14.5,38.3, 37.4,-23.4,36.5, 25.4,-20.8,42.9, 29.0,-3.9,40.0, 27.7,-4.0,52.5, 38.7,-14.7,45.0, 38.7,-14.7,45.0, 41.9,-14.5,38.3, 29.0,-3.9,40.0, 22.3,16.3,-4.8, 26.0,0.0,-4.8, 3.0,1.3,-11.2, 3.0,1.3,-11.2, 3.0,23.8,-7.2, 22.3,16.3,-4.8, 14.0,-18.0,39.6, 17.1,3.7,43.4, 3.0,1.5,47.0, 3.0,1.5,47.0, 3.0,-20.9,40.0, 14.0,-18.0,39.6, 22.3,-16.4,-4.8, 29.3,-21.4,5.4, 3.0,-26.3,2.8,
3.0,-26.3,2.8, 3.0,-21.2,-7.2, 22.3,-16.4,-4.8, 19.7,16.3,38.0, 21.0,18.3,33.1, 3.0,24.1,39.0, 3.0,24.1,39.0, 3.0,23.8,42.7, 19.7,16.3,38.0, 8.9,34.6,17.2, 9.2,36.4,9.8, 4.7,36.7,8.5, 4.7,36.7,8.5, 4.7,35.3,18.3, 8.9,34.6,17.2, 10.9,25.1,19.3, 10.9,36.0,19.0, 3.0,36.9,21.1, 3.0,36.9,21.1, 3.0,25.1,21.4, 10.9,25.1,19.3, -16.3,-16.4,-4.8, -23.3,-21.4,5.4, -28.2,2.0,13.8,
-28.2,2.0,13.8, -20.0,0.0,-4.8, -16.3,-16.4,-4.8, -16.3,16.3,-4.8, -23.3,25.4,15.8, -5.4,26.8,6.3, -16.3,16.3,-4.8, -5.4,26.8,6.3, 3.0,26.9,1.4, -16.3,16.3,-4.8, 3.0,26.9,1.4, 3.0,23.8,-7.2, -16.3,-18.1,18.5, -23.3,-21.4,5.4, 3.0,-26.3,2.8, 3.0,-26.3,2.8, 3.0,-22.9,19.0, -16.3,-18.1,18.5, -16.3,20.4,19.3, -23.3,25.4,15.8, -28.2,2.0,13.8, -28.2,2.0,13.8, -20.0,0.3,19.4, -16.3,20.4,19.3,
3.0,-22.9,19.0, 3.0,-24.5,22.6, -17.2,-17.2,23.2, -17.2,-17.2,23.2, -16.3,-18.1,18.5, 3.0,-22.9,19.0, -16.3,20.4,19.3, -20.0,0.3,19.4, -20.5,2.1,25.8, -20.5,2.1,25.8, -15.0,18.3,33.1, -16.3,20.4,19.3, -16.3,20.4,19.3, -5.0,25.1,19.3, -5.4,26.8,6.3, -5.4,26.8,6.3, -23.3,25.4,15.8, -16.3,20.4,19.3, -5.4,26.8,6.3, 3.0,26.8,4.1, 3.0,26.9,1.4, -5.0,25.1,19.3, 3.0,24.4,26.5, 3.0,25.1,21.4,
-5.0,25.1,19.3, -5.0,36.0,19.0, -5.4,38.3,8.7, -5.4,38.3,8.7, -5.4,26.8,6.3, -5.0,25.1,19.3, 3.0,26.8,4.1, -5.4,26.8,6.3, -5.4,38.3,8.7, -5.4,38.3,8.7, 3.0,39.2,6.4, 3.0,26.8,4.1, -16.3,16.3,-4.8, -20.0,0.0,-4.8, -28.2,2.0,13.8, -28.2,2.0,13.8, -23.3,25.4,15.8, -16.3,16.3,-4.8, -16.3,-18.1,18.5, -20.0,0.3,19.4, -28.2,2.0,13.8, -28.2,2.0,13.8, -23.3,-21.4,5.4, -16.3,-18.1,18.5,
-20.5,2.1,25.8, -17.2,-17.2,23.2, -16.6,-16.4,27.9, -16.6,-16.4,27.9, -19.6,3.8,32.2, -20.5,2.1,25.8, -16.3,-16.4,-4.8, -20.0,0.0,-4.8, 3.0,1.3,-11.2, 3.0,1.3,-11.2, 3.0,-21.2,-7.2, -16.3,-16.4,-4.8, 3.0,23.8,42.7, -13.7,16.3,38.0, -15.6,9.3,40.6, 3.0,1.5,47.0, 3.0,23.8,42.7, -15.6,9.3,40.6, -11.2,3.7,43.4, 3.0,1.5,47.0, -15.6,9.3,40.6, -19.6,3.8,32.2, -11.2,3.7,43.4, -15.6,9.3,40.6,
-28.3,-25.0,43.6, -32.8,-14.7,45.0, -35.9,-14.5,38.3, -35.9,-14.5,38.3, -31.4,-23.4,36.5, -28.3,-25.0,43.6, -11.2,3.7,43.4, -21.8,-4.0,52.5, -18.7,-22.4,48.6, -18.7,-22.4,48.6, -8.1,-18.0,39.6, -11.2,3.7,43.4, -8.1,-18.0,39.6, -18.7,-22.4,48.6, -19.5,-20.8,42.9, -19.5,-20.8,42.9, -16.6,-16.4,27.9, -8.1,-18.0,39.6, -16.6,-16.4,27.9, -19.5,-20.8,42.9, -23.0,-3.9,40.0, -23.0,-3.9,40.0, -19.6,3.8,32.2, -16.6,-16.4,27.9,
-19.6,3.8,32.2, -23.0,-3.9,40.0, -21.8,-4.0,52.5, -21.8,-4.0,52.5, -11.2,3.7,43.4, -19.6,3.8,32.2, -21.8,-4.0,52.5, -32.8,-14.7,45.0, -28.3,-25.0,43.6, -28.3,-25.0,43.6, -18.7,-22.4,48.6, -21.8,-4.0,52.5, -18.7,-22.4,48.6, -28.3,-25.0,43.6, -31.4,-23.4,36.5, -31.4,-23.4,36.5, -19.5,-20.8,42.9, -18.7,-22.4,48.6, -19.5,-20.8,42.9, -31.4,-23.4,36.5, -35.9,-14.5,38.3, -35.9,-14.5,38.3, -23.0,-3.9,40.0, -19.5,-20.8,42.9,
-23.0,-3.9,40.0, -35.9,-14.5,38.3, -32.8,-14.7,45.0, -32.8,-14.7,45.0, -21.8,-4.0,52.5, -23.0,-3.9,40.0, -16.3,16.3,-4.8, 3.0,23.8,-7.2, 3.0,1.3,-11.2, 3.0,1.3,-11.2, -20.0,0.0,-4.8, -16.3,16.3,-4.8, -8.1,-18.0,39.6, 3.0,-20.9,40.0, 3.0,1.5,47.0, 3.0,1.5,47.0, -11.2,3.7,43.4, -8.1,-18.0,39.6, -16.3,-16.4,-4.8, 3.0,-21.2,-7.2, 3.0,-26.3,2.8, 3.0,-26.3,2.8, -23.3,-21.4,5.4, -16.3,-16.4,-4.8,
3.0,24.1,39.0, -15.0,18.3,33.1, -13.7,16.3,38.0, -13.7,16.3,38.0, 3.0,23.8,42.7, 3.0,24.1,39.0, -3.2,34.6,17.4, 1.5,35.3,18.6, 1.5,36.8,8.2, 1.5,36.8,8.2, -3.5,36.4,9.6, -3.2,34.6,17.4, -5.0,25.1,19.3, 3.0,25.1,21.4, 3.0,36.9,21.1, 3.0,36.9,21.1, -5.0,36.0,19.0, -5.0,25.1,19.3, 10.9,36.0,19.0, 11.3,38.3,8.7, 9.4,38.2,10.1, 9.4,38.2,10.1, 9.1,36.5,17.6, 10.9,36.0,19.0,
11.3,38.3,8.7, 3.0,39.2,6.4, 4.9,38.5,8.9, 4.9,38.5,8.9, 9.4,38.2,10.1, 11.3,38.3,8.7, 3.0,39.2,6.4, 3.0,36.9,21.1, 4.9,37.1,18.7, 4.9,37.1,18.7, 4.9,38.5,8.9, 3.0,39.2,6.4, 3.0,36.9,21.1, 10.9,36.0,19.0, 9.1,36.5,17.6, 9.1,36.5,17.6, 4.9,37.1,18.7, 3.0,36.9,21.1, 3.0,36.9,21.1, 3.0,39.2,6.4, 1.3,38.6,8.6, 1.3,38.6,8.6, 1.3,37.1,19.0, 3.0,36.9,21.1,
3.0,39.2,6.4, -5.4,38.3,8.7, -3.7,38.2,9.9, -3.7,38.2,9.9, 1.3,38.6,8.6, 3.0,39.2,6.4, -5.4,38.3,8.7, -5.0,36.0,19.0, -3.4,36.4,17.7, -3.4,36.4,17.7, -3.7,38.2,9.9, -5.4,38.3,8.7, -5.0,36.0,19.0, 3.0,36.9,21.1, 1.3,37.1,19.0, 1.3,37.1,19.0, -3.4,36.4,17.7, -5.0,36.0,19.0, 9.1,36.5,17.6, 9.4,38.2,10.1, 9.2,36.4,9.8, 9.2,36.4,9.8, 8.9,34.6,17.2, 9.1,36.5,17.6,
9.4,38.2,10.1, 4.9,38.5,8.9, 4.7,36.7,8.5, 4.7,36.7,8.5, 9.2,36.4,9.8, 9.4,38.2,10.1, 4.9,38.5,8.9, 4.9,37.1,18.7, 4.7,35.3,18.3, 4.7,35.3,18.3, 4.7,36.7,8.5, 4.9,38.5,8.9, 4.9,37.1,18.7, 9.1,36.5,17.6, 8.9,34.6,17.2, 8.9,34.6,17.2, 4.7,35.3,18.3, 4.9,37.1,18.7, 1.3,37.1,19.0, 1.3,38.6,8.6, 1.5,36.8,8.2, 1.5,36.8,8.2, 1.5,35.3,18.6, 1.3,37.1,19.0,
1.3,38.6,8.6, -3.7,38.2,9.9, -3.5,36.4,9.6, -3.5,36.4,9.6, 1.5,36.8,8.2, 1.3,38.6,8.6, -3.7,38.2,9.9, -3.4,36.4,17.7, -3.2,34.6,17.4, -3.2,34.6,17.4, -3.5,36.4,9.6, -3.7,38.2,9.9, -3.4,36.4,17.7, 1.3,37.1,19.0, 1.5,35.3,18.6, 1.5,35.3,18.6, -3.2,34.6,17.4, -3.4,36.4,17.7, 14.0,-18.0,39.6, 3.0,-20.9,40.0, 3.0,-24.5,22.6, 22.6,-16.4,27.9, 14.0,-18.0,39.6, 3.0,-24.5,22.6,
23.5,-17.2,23.2, 22.6,-16.4,27.9, 3.0,-24.5,22.6, 19.7,16.3,38.0, 21.5,9.3,40.6, 25.5,3.8,32.2, 19.7,16.3,38.0, 25.5,3.8,32.2, 26.8,2.1,25.8, 21.0,18.3,33.1, 19.7,16.3,38.0, 26.8,2.1,25.8, 23.5,-17.2,23.2, 22.3,-18.1,18.5, 26.0,0.3,19.4, 26.0,0.3,19.4, 26.8,2.1,25.8, 23.5,-17.2,23.2, 10.9,25.1,19.3, 3.0,24.4,26.5, 3.0,24.1,39.0, 22.3,20.4,19.3, 10.9,25.1,19.3, 3.0,24.1,39.0,
21.0,18.3,33.1, 22.3,20.4,19.3, 3.0,24.1,39.0, -8.1,-18.0,39.6, -16.6,-16.4,27.9, -17.2,-17.2,23.2, 3.0,-20.9,40.0, -8.1,-18.0,39.6, -17.2,-17.2,23.2, 3.0,-24.5,22.6, 3.0,-20.9,40.0, -17.2,-17.2,23.2, -15.6,9.3,40.6, -13.7,16.3,38.0, -15.0,18.3,33.1, -19.6,3.8,32.2, -15.6,9.3,40.6, -15.0,18.3,33.1, -20.5,2.1,25.8, -19.6,3.8,32.2, -15.0,18.3,33.1, -20.0,0.3,19.4, -16.3,-18.1,18.5, -17.2,-17.2,23.2,
-17.2,-17.2,23.2, -20.5,2.1,25.8, -20.0,0.3,19.4, -5.0,25.1,19.3, -16.3,20.4,19.3, -15.0,18.3,33.1, 3.0,24.4,26.5, -5.0,25.1,19.3, -15.0,18.3,33.1, 3.0,24.1,39.0, 3.0,24.4,26.5, -15.0,18.3,33.1, ]);
}//classend
}