Midnight Brainfuck
package {
import alternativ5.engine3d.core.*;
import alternativ5.engine3d.display.View;
import alternativ5.engine3d.materials.FillMaterial;
import alternativ5.engine3d.primitives.Box;
import flash.events.Event;
[SWF(width=465,height=465,backgroundColor=0x3f7fff)]
public class MidnightBrainFuck extends View {
public var box:Box;
public var box_t:Number;
public var scene:Scene3D;
public var thing:Trapezoid;
public function MidnightBrainFuck () {
width = 465; height = 465;
scene = new Scene3D; scene.root = new Object3D;
camera = new Camera3D; camera.z = -15; scene.root.addChild (camera);
thing = new Trapezoid; scene.root.addChild (thing);
box = new Box (13, 1, 1); scene.root.addChild (box);
box.cloneMaterialToAllSurfaces (new FillMaterial (0x123456, 1, "normal", box_t = 0));
addEventListener (Event.ENTER_FRAME, loop);
stage.quality = "best";
}
public function loop (e:Event):void {
box_t += 0.03; if (box_t > 2 * Math.PI) box_t -= 2 * Math.PI;
box.rotationX = 1 * box_t;
box.rotationY = 2 * box_t;
box.rotationZ = 3 * box_t;
thing.rotationY *= 0.9;
thing.rotationY += 0.1 * (Math.PI + 0.7 * (1 - mouseX / 232.5));
scene.calculate ();
}
}
}
import alternativ5.engine3d.core.*;
import alternativ5.engine3d.materials.FillMaterial;
class Trapezoid extends Mesh {
private function f2(v1:Number,v2:Number,v3:Number):Face {
return createFace([v1, v2, v3]);
}
private function f24(v1:Number,v2:Number,v3:Number,v4:Number):Face {
return createFace([v1, v2, v3, v4]);
}
private function v(vx:Number,vy:Number,vz:Number):void {
createVertex(vx,vy,vz);
}
public function Trapezoid ( p_Name:String=null ) {
super( p_Name );
v(6.000000,2.828019,-1.415029);
v(6.000000,-1.413399,2.828835);
v(-6.000000,-2.827902,-1.415262);
v(-6.000000,1.413164,2.828951);
v(-5.000000,0.823339,1.930534);
v(5.000000,2.121116,-0.707718);
v(5.000000,-0.884864,1.917024);
v(-5.000000,-2.121058,-0.707893);
v(6.000000,2.120709,-2.121932);
v(6.000000,-2.120709,2.121932);
v(-6.000000,-2.120533,-2.122107);
v(-6.000000,2.120533,2.122107);
v(-5.000000,1.519654,1.263632);
v(-5.000000,-1.413689,-1.414738);
v(5.000000,1.413806,-1.414621);
v(5.000000,-1.560632,1.235125);
f2(0,3,5);
f2(1,6,7);
f24(1,0,5,6);
f24(4,3,2,7);
f24(12,4,7,13);
f24(15,6,5,14);
f24(10,2,3,11);
f24(8,0,1,9);
f2(3,0,11);
f2(13,7,6);
f2(14,5,3);
f2(9,1,7);
f2(3,4,14);
f2(2,9,7);
createSurface ([0, 1, 2, 8, 9], "black");
setMaterialToSurface (new FillMaterial (0), "black");
createSurface ([4, 5, 6, 7], "grey");
setMaterialToSurface (new FillMaterial (0x444444), "grey");
createSurface ([3, 10, 11, 12, 13], "silver");
setMaterialToSurface (new FillMaterial (0xaaaaaa), "silver");
rotationY = Math.PI;
}
}