开发者

How to rotate camera around group of objects? (not using 3d engines)

开发者 https://www.devze.com 2023-01-31 16:39 出处:网络
So I create a point cloud, in 3d with code like (flash 10.1 CS5): import flash.display.Bitmap; import flash.display.BitmapData;

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

How to rotate camera around group of objects? (not using 3d engines)

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:

  1. Find center point of point cloud
  2. Set camera facing center point
  3. Calculate position p of camera at time t on Archimedian spiral
  4. Set camera position to p
  5. Render and display frame
  6. Repeat from 3. until finished
0

精彩评论

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