开发者

How to create a 3d point with 2 same way textured sides?

开发者 https://www.devze.com 2023-01-31 16:58 出处:网络
So I create a points cloud using no 3d engines but one baked into flash: import flash.display.Bitmap; import flash.display.BitmapData;

So I create a points cloud using no 3d engines but one baked into flash:

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开发者_如何学JAVA.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 ));
}

so its a wary simple code. how to make my points have 2 sides or be always face to wiever?


There's a javascript example of how to create a spiral on a sphere surface at this link:

http://lines-about-to-be-generated.blogspot.com/2009/06/image-spiral-sphere.html

0

精彩评论

暂无评论...
验证码 换一张
取 消