[ごはんとFlash - ライブコーディング] 暗号解析から3Dビジュアライズ
/**
* Copyright clockmaker ( http://wonderfl.net/user/clockmaker )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/p3xT
*/
package {
import flash.display.*;
import org.papervision3d.objects.*
import org.papervision3d.objects.primitives.*
import org.papervision3d.materials.*;
import org.papervision3d.view.*
import jp.nium.utils.*
import flash.text.*
import org.papervision3d.materials.shadematerials.*
import org.papervision3d.materials.utils.*
import org.papervision3d.cameras.*
import org.papervision3d.objects.special.*
import org.papervision3d.materials.special.*
import org.papervision3d.lights.*
import flash.system.*;
public class Main extends BasicView {
private const code :String = "甶男甸疙疝痼瘂癟癢癧盃盌眧眨眩眮眯眰瞊瞋瞎瞏瞐瞑瞔瞕短矯矴矸矺硓硗硘硜碷磀礜礤禁禇秦秪穋積窮窲笑笒笓笔笕笖笗"
private const cell:int = 16;
private var objs:Array = []
public function Main() {
super(0,0,true,false, CameraType.DEBUG)
stage.quality = "low"
opaqueBackground = 0x0
Security.loadPolicyFile("http://farm4.static.flickr.com/crossdomain.xml");
//
//var vr:Sphere = new Sphere(new BitmapFileMaterial("http://farm4.static.flickr.com/3354/3585586857_9b492fd9c3_b.jpg"), 1000)
var sm:BitmapFileMaterial = new BitmapFileMaterial("http://farm4.static.flickr.com/3354/3585586857_9b492fd9c3_b.jpg")
var vr:Sphere = new Sphere(new WireframeMaterial(), 100)
//scene.addChild(vr)
var light:PointLight3D = new PointLight3D();
var mat:FlatShadeMaterial = new FlatShadeMaterial(light)
var ml:MaterialsList = new MaterialsList({all:new WireframeMaterial(0x0099FF)})
var t:TextField = new TextField();
addChild(t)
// ついでにパーティクルを生成します(彗星)
var particleMat:ParticleMaterial = new ParticleMaterial(0xFFFFFF, 1)
var particles:ParticleField = new ParticleField(particleMat, 500, 4, 2000, 2000, 2000)
scene.addChild( particles );
for(var j:int =0; j<10; j++){
var obj:DisplayObject3D = new DisplayObject3D();
scene.addChild(obj)
var len:int = 1000 * Math.random() + 500
var rot:int = 360 * Math.random()
obj.x = len * Math.sin(rot * Math.PI / 180)
obj.z = len * Math.cos(rot * Math.PI / 180)
obj.y = 2000 * (Math.random() - 0.5)
obj.lookAt(DisplayObject3D.ZERO)
objs.push({
obj:obj,
len:len,
rot:rot,
speed : 10 * Math.random()
})
for(var i:int=0; i<code.length; i++){
var c:String = NumberUtil.digit(code.charCodeAt(i), 5);
var xx:int = int(c.substr(1, 2));
var yy:int = int(c.substr(3, 2))
var cube:Cube = new Cube(ml, 50, 50,50 )
obj.addChild(cube)
cube.x = (xx - cell/2) * 60
cube.y = (yy - cell/2) * 60
//t.text = i.toString();
}
}
startRendering()
addEventListener("enterFrame", function():void{
/*
camera.x = 1000 * Math.sin(mouseX/ stage.stageWidth)
camera.z = 1000 * Math.cos(mouseX/ stage.stageWidth)
*/
for(var k:int=0; k<objs.length; k++){
var o:Object = objs[k]
o.rot += o.speed
o.obj.x = o.len * Math.sin(o.rot * Math.PI / 180)
o.obj.z = o.len * Math.cos(o.rot * Math.PI / 180)
o.obj.lookAt(DisplayObject3D.ZERO)
}
})
}
}
}