[Away3D] Collada Animation
Away3D2.1.5の新機能、Colladaのアニメーション・ボーン制御について整理。
いずれもBlender2.46にてColladaファイルを作成。
まずはアニメーションの制御。
walkMotion.swf(要:FlashPlayer9)
var loader:Object3DLoader;
loader = Collada.load('hoge.dae');
loader.addOnSuccess(loadComplete);
scene.addChild(loader);
- 中略 -
private function loadComplete(e:LoaderEvent):void
{
model = (e.loader.handle as ObjectContainer3D);
skinAnimation = (model.animationLibrary["default"] as AnimationData).animation as SkinAnimation;
}
モーション無しのColladaと同じ要領で読み込んだデータの animationLibrary プロパティから SkinAnimation オブジェクトを生成しておいてから、レンダーループ内とかで、
skinAnimation.update(getTimer()/1500);
と、updateメソッドを呼んでやればとりあえず動く。
引数は時間っぽい。SkinAnimationのloopプロパティがtrue(デフォルト値)なら、引数をひたすら増加させてやるだけで延々とアニメーションする。モーションを工夫して、いくつかの異なる動作を時間で区切れば多彩なアクションも可能かも。
これに関連した事柄で、ColladaにはAnimationChannelとかいう要素があって、複数のモーションデータを持たせることが仕様に含まれてるみたいなんだけど、その辺にも対応してるのかは不明。
正しくデータが作られてればColladaのモーション再生自体はエラく簡単。
問題なのはやっぱりBlenderからのColladaエクスポート。
今一つ確実に上手くいく方法が掴めないので、とッ散らかったメモを残しておく。
- Y軸が上方向となるようにモデリング〜ボーン設定を行う
- 書き出されたColladaファイルの
要素を「Y_UP」にする - ルートボーンは1つにする
- メッシュとペアレントした後自動設定されるモディファイアのArmatureをRealizeする
- メッシュの各頂点が、必ずいずれかのVertexGroupに含まれるようにする
- ボーンの名称に「.(ピリオド)」が含まれないようにする
特に座標系の違いが要注意部分。ColladaエクスポーターとAway3DのCollada.asでこの部分の連携が上手くいってない気がする。ガテン系ボーカロイドの腕が大変な動きをしてたのは、Z軸を上にして作ってたからだった。
次に直接ボーンを制御する場合。
boneControl(要:FlashPlayer9)
※画面左のつまみ系UIで腕と足の各軸の回転角度をイジれる。超使いにくい(えー)
読み込んだColladaがボーンを含んでいる場合、
var bone:Bone = model.getBoneByName("arm01_L");
//ボーンを各軸毎に回転
bone.jointRotationX(15);
bone.jointRotationY(5);
bone.jointRotationZ(10);
//ボーンを各軸毎に拡大縮小
bone.jointScaleX(0.5);
bone.jointScaleY(1.5);
bone.jointScaleZ(2);
って感じでアクセスできる。回転とスケールのみ制御可能。
普通にObject3Dを回転させたりするのと同じ要領ですな。IKとか設定したらどうなるのかは未調査。今度調べてみよう。
全体的にPV3D + Blenderより全然まともに動く印象(最近のPV3Dがどうかはわかんないけど)Colladaのパースもやたら早いし。なかなかイイ感じなんじゃないでしょーか。
関連する投稿
Trackback URL : http://blog.r3c7.net/wp-trackback.php?p=216


nice done rect!, btw, watch out “null” in loop appear when model not loaded yet
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main/loop3D()
i love it,btw
Thx katopz!
I tried to fix it, How does it look?
Looks great! You can do scale and translate also, not just rotate, but the demo is great! You beat us to it
best
-Pete
Thread(そうめん)× Away3D × Blenderで作成(僕がそうめんを使う理由的な)
デモ表示 Away3DのColladaアニメーションと、先日参加した「そうめん…
I want to ask do you use Blender 2.46 to export the model in Collada format?? I do the same and try to load it on Papervision3D 2.0 but the animation doesn’t look right.
So Away3D can correctly play animations on collada file generated by Blender? I see there are bullet points up there, but I don’t understand japanese.. so is there anything I need to modify to make animation work in Away3D?
thx!
-ronald
ronald,
Sorry… I’m not schooled in that subjects.
As long as I tried, it will move, if Away3D used.
thx
thx for replying!
I am able to make it work in Away3D also. Next thing I will try is to see how I can have different sets of animations (walk,jump,kick, punch, etc), and run them depending on user’s input.
ronald
Hi rect,
I am using Blender to export Collada file, but the rotation is not correct after running it in away3d. In your blog, you mention something about “Y_UP”. The Collada file I export has “Z_UP”, so how do you export that with Y_UP? What settings in Blender should I set?
thx.
ronald
ronald,
>how do you export that with Y_UP? What settings in Blender should I set?
It is rewriting by the text editor.
rect,
thx.. I think I try to set it with text editor, but doesn’t seem to work.. anyway.
do you know in Away3D, is it possible to play only part of the animation? I am putting all the different animations (walk,wave,jump..etc) on the same timeline in Blender, and I want just play part of the timeline to show the animation I want. Is it possible? I try to set SkinAnimation’s start/length and loop and I can’t make it to work.
thx.
ronald
ronald,
No one knows.
It can’t answer only by your comment.
Please check the following.
* Armature modifier to change at “Realize”.
* “.”(dot) must not be contained in a armature name.
[Blender][Away3D][Collada]Blender 2.48aにおけるColladaのエクスポート(アニメーションあり編)※試行錯誤中
note.x | [Away3D] Collada Animationに記載されてることは2.46での話なので2.48aでいろいろやったメモ(重複あり)。 すべてのボーン名にそれぞれ対応する頂点グループがないと、実行時エラ…
Great work for bone that is something I’m looking for but I still can not do it even you show your code.
I think the problem is Collada file format.
(I also use Blender)