So I create a point cloud, in 3d with code like (flash 10.1 CS5):
import flash.display.Bitmap;
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(400, 400, true, 0xFFCCCCCC);
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 < 100000)
{
xn = Math.random() * 600 - 200;
yn = Math.random() * 600 - 200;
zn = Math.random() * 600 - 200;
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 pointGraphicDa开发者_开发问答ta = new BitmapData(1,1,true,color)
var pointGraphic:Bitmap = new Bitmap(pointGraphicData);
pointGraphic.x = xn;
pointGraphic.y = yn;
pointGraphic.z = zn;
addChild(pointGraphic);
}
How to move and rotate camera that looks onto the screen in sphere like path
around created box?
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
You want an Archimedian Spiral. You should be able to find tons of equations via google.
You'll want to:
- Find center point of point cloud
- Set camera facing center point
- Calculate position p of camera at time t on Archimedian spiral
- Set camera position to p
- Render and display frame
- Repeat from 3. until finished
精彩评论