• 粒子效果2


    import flash.geom.*;
    [SWF(width = 465, height = 465, backgroundColor = 0x0, frameRate = 30)]
     var m:Matrix3D,vm:Matrix3D = new Matrix3D(),p:Object,pp:PerspectiveProjection = new PerspectiveProjection(),pm:Matrix3D=pp.toMatrix3D(),vins:Vector.<Number> = new Vector.<Number>(),vouts:Vector.<Number> = new Vector.<Number>(),uvts:Vector.<Number> = new Vector.<Number>(),v2ds:Vector.<Number> = new Vector.<Number>(),particles:Array = [];
    addEventListener("enterFrame", function():void{
    if (Math.random()<0.05) {var c2:int = 400 * Math.random();
    var v2:Vector3D = new Vector3D((Math.random()-0.5)*400,(Math.random()-0.5)*400,(Math.random()-0.5)*400,Math.random()*0xffffff);
    while (c2-- > 0){(m = new Matrix3D(Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0, 0, (Math.random()*.2+0.8) * 5,1]))).appendRotation(360 * Math.random(), Vector3D.X_AXIS);
            m.appendRotation(360 * Math.random(), Vector3D.Y_AXIS);
            var v:Vector3D = m.transformVector(new Vector3D);
            particles.push({tails:[],energy:Math.random() * 5,v:v,position:v2,color:v2.w,deceleration:.95,gravity:.05,length:2});}}
    (vm=new Matrix3D(Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0, 200, -550,1]))).appendRotation(mouseX/10, Vector3D.Y_AXIS,vm.position);
    vm.appendRotation(-mouseY/10, Vector3D.X_AXIS,vm.position);
    vm.invert();
    graphics.clear();
    for (var i:int = particles.length - 1; i >= 0; i--){(p = particles[i]).v.scaleBy(p.deceleration);
            p.v.y += p.gravity;
            p.position= p.position.add(p.v);
            p.energy *= p.deceleration;
            if (p.energy < 0.05) { particles.splice(i, 1);
            } else {p.v2d = Utils3D.projectVector(pm, (p.vposition = vm.transformVector(p.position)));
                    graphics.lineStyle(400 / p.v2d.w, p.color);
                    graphics.moveTo(p.v2d.x, p.v2d.y);
                    for (var j:int = p.tails.length - 1,c:int=0,tc:int=4; j >= 0; j--,c++) {
                            if (c>p.energy*tc) {p.tails.splice(j, 1); continue;}
                            var v2d:Vector3D = Utils3D.projectVector(pm, vm.transformVector(p.tails[j]));
                            graphics.lineStyle(500 / p.v2d.w, p.color,(p.energy*tc-c)/p.energy*tc);
                            graphics.lineTo(v2d.x, v2d.y);}
                    if (p.tails[0]) {if (Math.sqrt((p.tails[p.tails.length - 1].x-p.position.x)*(p.tails[p.tails.length - 1].x-p.position.x)+(p.tails[p.tails.length - 1].y-p.position.y)*(p.tails[p.tails.length - 1].y-p.position.y)+(p.tails[p.tails.length - 1].z-p.position.z)*(p.tails[p.tails.length - 1].z-p.position.z))>p.length) {p.tails.push(p.position.clone());}}else {p.tails.push(p.position.clone());}}}});
    x =y = 228;

  • 相关阅读:
    Systemd 进程管理器
    Fedora 15 LoveLock的新特性
    fedora 15 iso 硬盘安装
    Linux权限360度赤裸裸华丽丽大曝光连载之二:SetUID
    Linux下socket设置为非阻塞方式和fcntl系统调用
    linux 磁盘 空间 不足 符号链接
    U盘成功安装REHL 6.1
    IT公司中最流行的10种编程语言
    C会否像汇编一样退居幕后?
    白宫决策捕杀拉登现场照片公布
  • 原文地址:https://www.cnblogs.com/flashweb/p/2797280.html
Copyright © 2020-2023  润新知