/*Particle3d是将空间的三维粒子投影到二维平面上,如果场景中的MC是玩具,那当Particle3d就是操纵玩具的摇控器*/
import Vector3d;
class Particle3d {
var position:Vector3d;
var timeline:MovieClip;
var mc:MovieClip;
var scale:Number;
function attachGraphic(mcID:String,depth:Number):MovieClip {
return this.timeline.attachMovie(mcID,"mcID"+"_"+depth,depth);
}
/*刷新屏幕*/
function render(viewDist:Number):Void{
var pers:Number = position.getPerspective(viewDist);
var screenPos:Vector3d =position.persProjectNew (pers);
this.mc._x = screenPos.x;
this.mc._y = -screenPos.y;
this.mc._xscale = this.mc._yscale = scale * pers;
this.mc.swapDepths (100000 - position.z * 100);
}
function Particle3d(x:Number,y:Number,z:Number,timeline:MovieClip,mcID:String,depth:Number,viewDist:Number){
this.position=new Vector3d(x,y,z);
this.timeline=timeline;
this.mc=this.attachGraphic(mcID, depth);
this.scale=100;
this.render(viewDist);
}
}
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。