2010-12-17 2 views
0

Alors je crée un nuage de points en utilisant pas de moteur 3D, mais un four en flash:Comment créer un point 3D avec 2 côtés texturés de la même manière?

import flash.display.Bitmap; 
import flash.display.BitmapData; 

var bmd:BitmapData = new BitmapData(400,400,true,0x00000000); 

var xn:Number; 
var yn:Number; 
var zn:Number; 
var norm:Number; 
var c1:Number; 
var c2:Number; 
var c3:Number; 
var c4:Number; 
var counter:int; 
var color:uint; 
while (counter < 20000) 
{ 
    xn = Math.random() * 400; 
    yn = Math.random() * 400; 
    zn = Math.random() * 400; 
    norm = Math.sqrt(xn * xn + yn * yn + zn * zn); 
    c1 = (1 - norm/200) * 255; 
    c2 = (1 - norm/250) * 255; 
    c3 = Math.abs(xn)/norm * 255; 
    c4 = Math.abs(yn)/norm * 255; 
    color = (c1 << 24 | c2 << 16 | c3 << 8 | c4); 
    counter++; 

    var pointGraphicData = new BitmapData(1,1,true,color); 
    var pointGraphic:Bitmap = new Bitmap(pointGraphicData); 

    pointGraphic.x = xn; 
    pointGraphic.y = yn; 
    pointGraphic.z = zn; 
    addChild(pointGraphic); 
} 
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove); 
this.x = 150; 
this.y = 150; 
this.z = 450; 
function handleMouseMove(event:MouseEvent):void 
{ 
    this.rotationX = 0 - event.localX; 
    this.rotationY = 0 - event.localY; 
    this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY)); 
} 

de sorte que son code simple méfiant. comment faire mes points ont 2 côtés ou être toujours face à wiever?

Répondre

Questions connexes