forked from: Lightwave3Dからアニメーション付きColladaを書き出すよ
Lightwave3Dからアニメーション付きのColladaファイルを書き出すよ
手順はここにメモっておきましたー → http://www.ahiru.org/archives/135
// forked from noenoe's Lightwave3Dからアニメーション付きColladaを書き出すよ
// forked from bma_japan オリジナルキャラを走らせてみる
//Lightwave3Dからアニメーション付きのColladaファイルを書き出すよ
//手順はここにメモっておきましたー → http://www.ahiru.org/archives/135
package {
import flash.events.Event;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.view.BasicView;
import org.papervision3d.core.proto.MaterialObject3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.layer.ViewportLayer;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shaders.CellShader;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.shaders.ShadedMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.materials.BitmapMaterial;
public class Lightwave2Collada extends Sprite
{
public var dae:DAE;
public var target:DisplayObject3D;
public var view:BasicView;
public function Lightwave2Collada()
{
view = new BasicView();
this.addChild(view);
//Lightwaveから変換したCollada形式のオブジェクト
dae = new DAE(true,null,true);
dae.scale = 150;
//dae.load("http://www.ahiru.org/works/pv3d/colladaExport/sampleSwf/export.dae");
dae.load("http://billionmilesaway.com/data/wonderfla/borot_run9.dae");
view.scene.addChild(dae);
//カメラのターゲット
target = new DisplayObject3D();
target.y = 400;
view.scene.addChild(target);
view.camera.y = 600;
view.camera.target = target;
stage.addEventListener(Event.ENTER_FRAME, _enterFrameHandler)
}
private function _enterFrameHandler(e:Event):void {
view.startRendering();
stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, stage_keyUpHandler);
}
//上下左右キーでオブジェクト回転
private function stage_keyDownHandler(event:KeyboardEvent):void {
switch (event.keyCode) {
case Keyboard.LEFT :
dae.rotationY += 4;
break;
case Keyboard.RIGHT :
dae.rotationY-=4;
break;
case Keyboard.UP :
dae.rotationX+=4;
break;
case Keyboard.DOWN :
dae.rotationX-=4;
break;
}
}
private function stage_keyUpHandler(event:KeyboardEvent):void {
dae.rotationY+=0;
dae.rotationX+=0;
}
}
}