forked from: FLARToolKit SimpleCube sample
from flartoolkit SimpleCube example
print this marker: http://saqoosha.net/lab/FLARToolKit/flarlogo-marker.pdf
ポリシーファイル云々でgdって不貞腐れたので寝ます。orz
/**
* Copyright emanon ( http://wonderfl.net/user/emanon )
* GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
* Downloaded from: http://wonderfl.net/c/ue9C
*/
// forked from mash's FLARToolKit SimpleCube sample
// from flartoolkit SimpleCube example
// print this marker: http://saqoosha.net/lab/FLARToolKit/flarlogo-marker.pdf
//ポリシーファイル云々でgdって不貞腐れたので寝ます。orz
package {
import flash.events.Event;
import flash.events.MouseEvent;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.materials.VideoStreamMaterial;
import org.libspark.flartoolkit.example.PV3DARApp;
[SWF(width=640, height=480, backgroundColor=0x808080, frameRate=30)]
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.system.Security;
public class SimpleCube extends PV3DARApp {
private var _plane:Plane;
private var _flv:Plane;
public function SimpleCube() {
Wonderfl.capture_delay( 5 );
// Initalize application with the path of camera calibration file and patter definition file.
// カメラ補正ファイルとパターン定義ファイルのファイル名を渡して初期化。
addEventListener(Event.INIT, _onInit);
init('http://assets.wonderfl.net/static/flar/camera_para.dat', 'http://assets.wonderfl.net/static/flar/flarlogo.pat');
}
private function _onInit(e:Event):void {
// Create Plane with same size of the marker.
// マーカーと同じサイズを Plane を作ってみる。
var wmat:WireframeMaterial = new WireframeMaterial(0xff0000, 1, 2); // with wireframe. / ワイヤーフレームで。
_plane = new Plane(wmat, 80, 80); // 80mm x 80mm。
_plane.rotationX = 180;
_markerNode.addChild(_plane); // attach to _markerNode to follow the marker. / _markerNode に addChild するとマーカーに追従する。
// Place the light at upper front.
// ライトの設定。手前、上のほう。
var light:PointLight3D = new PointLight3D();
light.x = 0;
light.y = 1000;
light.z = -1000;
//FLV読み込み
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var video:Video = new Video();
video.attachNetStream(ns);
ns.client = { };
ns.play("robo.flv");
//マテリアル生成
var material:VideoStreamMaterial = new VideoStreamMaterial(video,ns);
//平面にマテリアルを適用
_flv = new Plane( material, 100, 100);
_flv.rotationX = 180;
_flv.y = -50;
_flv.z = 50;
_markerNode.addChild(_flv);
stage.addEventListener(MouseEvent.CLICK, _onClick);
}
private function _onClick(e:MouseEvent):void {
mirror = !mirror;
}
}
}