forked from: sea
...
@author sliz http://game-develop.net/blog
/**
* Copyright mitien ( http://wonderfl.net/user/mitien )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ywzS
*/
// forked from sliz's sea
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.geom.Point;
import org.papervision3d.core.geom.renderables.Vertex3D;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
import org.papervision3d.view.stats.StatsView;
/**
* ...
* @author sliz http://game-develop.net/blog
*/
[SWF(backgroundColor=0)]
public class V extends BasicView {
private var p:Plane;
private var m:WireframeMaterial = new WireframeMaterial(0x456eb1);
private var bmd:BitmapData = new BitmapData(21, 21, false);
private var p2:Point = new Point();
private var addp:Point = new Point(0, 1);
private var rseed:int = int(300 * Math.random());
public function V(){
p = new Plane(m, 3000, 3000, 20, 20);
scene.addChild(p);
startRendering();
addEventListener(Event.ENTER_FRAME, update);
camera.y -= 2000;
var view:StatsView = new StatsView(renderer);
addChild(view);
view.x = 600;
addChild(new Bitmap(bmd));
}
private function update(e:Event):void {
p2 = p2.add(addp);
bmd.perlinNoise(10, 10, 2, rseed, true, true, 7, false, [p2]);
var vs:Array = p.geometry.vertices;
var cs:Array = [];
for (var i:int = 0; i < bmd.width; i++){
for (var j:int = 0; j < bmd.height; j++){
cs.push(bmd.getPixel(i, j));
}
}
for (i = 0; i < vs.length; i++){
var v:Vertex3D = vs[i];
v.z = 900 * cs[i] / 0xffffff - 450;
}
}
}
}