Showing posts with label Maya. Show all posts
Showing posts with label Maya. Show all posts

2008/08/23

import mocap data into Maya

BVH / HRT
裝下面的Maya plugin, 就可以直接import bvh及htr這兩種mocap格式到maya.
Mocap File Importer 0.8.5


AMC
import AMC進入Maya比較麻煩些。
目前沒找到很好的plug-in,需要幾個步驟。
下面連結有程式和簡單的教學。
http://mocap.cs.cmu.edu/asfamcmel/asfamcmel.php

Steps:
1. conver.bat + xxx.asf + yyy.amc ->  import_skeleton-yyy.mel & import_mov-yyy.mel & yyy.mov
2. import import_skeleton-yyy.mel -> generating skeleton( in the shape of "大" )
3. import import_mov-yyy.mel -> pop up a dialog box -> select yyy.mov
4. done!


C3D/TRC
裝下面這個Maya plugin, 就可以直接import c3d及trc這兩種mocap格式到maya.
peelMocapTools 0.1.2
操作方式好像有點麻煩,我沒有實際玩過。

另一個方法是利用MotionBuilder,
MotionBuilder支援前述所有格式的Mocap data(格式簡單說明)
所以可以將它們載入MotionBuilder後 -> 轉存fbx檔 -> 再import 進入maya。


Websites where you can get your free mocap data:
1.CMU Graphics Lab Motion Capture Database (amc/asf)
2.Mocap Xtras.com (bvh, fbx, c3d, bip)
3.cgspeed blog (bvh -- coverted from the CMU database)

.Max的model轉入Maya中

我只知道兩種方法,
首先都是要在3ds Max中先把.Max output 成 .3ds檔.


接著可以選用下面其中一種方法:
1.用FBXconverter將 .3ds轉成 .fbx,再用maya import .fbx檔。

2.在maya裝3dsimport.mll plug-in(至官網下載BonusTool),便可直接import .3ds 至maya.

2007/08/08

Maya API 聖經書:Complete Maya Programming

Maya API 聖經書:



共有兩本:


第一本(上左)寫的非常淺顯易懂,講述Maya主要的內部結構(DAG, DG, Node, DataBlock, FunctionSet.....) ,
並有許多有趣的範例程式可以玩。若跳過第三章MEL Script的部分,拼一點K,一、兩個禮拜應該可以K完。

第二本(上右)較進階,整本都在介紹Maya中數學與幾何的操作方法,最好有電腦圖學的基礎。

2007/08/01

Maya API -- error-checking


MStatus stats;
if ( stats == MS::kSuccess )
MGlobal::displayInfo( MString("success"));
else
MGlobal::displayError( stats.errorString() );

2007/07/31

Mel Script -- 抓polygon的vertex


int $n[] = `polyEvaluate -vertex pSphere1`;
int $num = $n[0];
vector $pos;

for($i=0; $i < $num; $i++)
{
 $pos = `getAttr pSphere1.vrts[$i]`; //local 座標
 //$pos = 'pointPosition -l pSphere1.vtx[$i]`; 與上行等效
 print($pos);
}

/* 與上述for loop 等效 */
//float $coord[] = `getAttr pSphere1.vrts["*"]`;
//print($coord);


for($i=0; $i < $num; $i++)
{
 $pos = `pointPosition -w pSphere1.vtx[$i]`;
 print($pos);
}

2007/07/24

Maya API 小筆記

Node (Class)
Attribute (Field)
Compute (Member Function)

DG:Denpendency Graph
(Horizontal view, input and output connection between different nodes)

DAG:Directed Acyclic Graph
(Vertical view, Hierarchy, ex. transformation -> shape)

DAG is a DG

MDagPath (Hierarchy info of node, you can manipulate geometry in world coordinate space)
MObject (Handle to node, you just can manipulate geometry in object coordinate space)

Push-Pull Approach
Push: forward propogate the message which updating each child node's flag(dirty bit).
Pull: backward propogate the message which updating each parent node's status.
updating: updating, execute each node's compute function, DAG Path from root to child.
(共三趟)

dirty data:通常指資料已被改變(如:在記憶體內的data),但尚未write back(如:在硬碟的檔案系統)。

MPxNode:

xxxCmd.cpp (network view)
virtual MStatus doIt ( const MArgList& );
virtual MStatus undoIt();
virtual MStatus redoIt();
virtual bool isUndoable() const { return true; }

static void *creator() { return new MeltCmd; }

  特別是在doIt()利用MPlug來存取場景中所有node的attribute, 並建立node與node之間的連結.
  (MPlug xxPlug = xxxFn.findPlug("xxx");
  (利用MDagModifier或MDgModifier 的connect(), disconnect(),createNode())

  ex:
   MFnDependencyNode nodeFn(obj);
   MPlug xPlg = nodeFn.findPlug("translateX");
   double tx;
   xPlg.getValue(tx); //get an attribute at current time.
   MTime t(1.5, MTime::kSeconds);
   MDGContext ctx(t);
   transxPlug.getValue(tx, ctx); //get an attribute at specific time.

xxxNode.cpp (node view)
  virtual MStatus compute(MPlug &plug, MDataBlock &data ){
    利用MDataHandle來存取data, (data.inputVaule(), data.outputValue()),
    並計算output attribute的值.
  }

  static MStatus initialize(){
    利用MFnXXAttribue 來初始attribute,
    addAttribute();
    attributeAffects(); //建立node中attribute的互動關係.
  }

  static void *creator();
  static const MTypeId id;


MPxLocatorNode:


virtual void draw( M3dView &; view, const MDagPath &path,
        M3dView::DisplayStyle style, M3dView::DisplayStatus status );
virtual bool isBounded() const;
virtual MBoundingBox boundingBox() const;
static void *creator();
static MStatus initialize();


MPxCommand:


virtual MStatus doIt ( const MArgList&);
virtual MStatus undoIt();
virtual MStatus redoIt();
virtual bool isUndoable() const { return true; }
static void *creator() { return new MeltCmd; }

2007/07/23

在VS2003下安裝Maya 7.0 API

C:\Program Files\Alias\Maya7.0\devkit\pluginwizard 目錄下
找到MayaPluginWizard2.0.zip

解壓縮後,將下列檔案
MayaPlugInWizard.vsdir

MayaPlugInWizard.vsz
MayaPlugInWizard.ico
copy to  C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\vcprojects

再將MayaPlugInWizard目錄
copy to C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\VCWizards


打開VS 2003 ,Open new Project
選Visual C++ Project 並在右邊選單選MayaPluginWizard

2007/07/22

Mel Script的相關設定檔

1.Maya Mel Script的預設存放處, 意指存在此處的Script會在Maya打開時, 自動載入.
C:\Documents and Settings\用戶名\My Documents\maya\版本號\scripts\

若同時安裝有Maya 8.5則下列位置中的Mel Script, 也會在Maya打開時自動載入.
C:\Documents and Settings\用戶名\My Documents\maya\scripts\

以上只是載入而已, 要執行仍需在指令列打function name (而不是xxx.mel唷!)

此外下面這行Mel Script的指令可以查user script directory.
internalVar -userScriptDir;

2.Maya Environment Variables, 供使用者設定Sript or Plug-in Path.

(1)設定系統變數

(2)C:\Documents and Settings\用戶名\My Documents\maya\版本號\Maya.env
預設是空的檔案。
在Maya.env中加入下面這行, 就可指定Maya打開時自動載入mel script的位置.
MAYA_SCRIPT_PATH = [your own Mel script path]
MAYA_PLUG_IN_PATH = [your own Plug-in path]

(3)設定Maya啟動時的初始動作。
 C:\Documents and Settings\用戶名\My Documents\maya\版本號\scripts\userSetup.mel
預設此mel檔是不存在的。
你可以自行在上述目錄中create 一個userSetup.mel
並鍵入下面的mel script指令。
confirmDialog
-title "welcome!"
-message "Hello World!"
-button "OK"
;
重新打開Maya看看會發生什麼有趣的事...

2007/06/27

Motion Builder支援的MoCap檔案格式

Acclaim (*.asf, *.amc)
此格式是一種雙重檔案格式,.asf檔案包含了骨架的定義,.amc檔則包含骨架運動的資料。
一個.asf檔可以搭配多個.amc檔。
故匯入Acclaim檔案格式時,須選擇一個.asf檔,或零個以上的.amc檔。
如果你選擇零個.amc檔,則只import骨架,而無動作。
Biovision (*.bvh)
此格式是階層式骨架的資料。



Motion Analysis (*.htr)
全名是Hierachical Transformation Rotation,
是用MotCap Analysis hardware抓取的階層式骨架資料。



Motion Analysis (*.trc)
光學補捉系統產生的資料格式。



Vicon (*.c3d)
Vicon hardware產生的資料格式。

2007/06/12

電腦動畫-期末project

我的人群終於以3d姿態登場...

2007/06/09

Maya instancer(Replacement)小筆記

1.製造particles (使用particle tool or Emitter皆可)

2.Create->Locator

3.選擇particles及locator,再選擇Particles->Goal

4.使用instCopy Mel將animation的每個frame獨立出來成為多個model,
供instancer參考,便可製造particle的local motion

5.選取Model(選肉不是選骨架)再選particles,
按Particles->Instancer(Replacement),便可將particle以local motion取代

6.將Model隱藏(visible =false)

2007/06/07

Crowd / Flocking in Maya

找到一篇跟Fake3D學長教我的一樣,果然是英雄所見略同....
不過不管哪一種,對我這個Maya新手而言,實作起來都不容易...

以下轉錄自http://bbs.cgblog.com.cn/thread-19155-1-1.html

maya particle instance 動畫

maya中做particle instance的動畫主要有兩種方式,

一種是直接instance帶Animation curve的物體,
這種方式的優點在於可以對particle instance物體做motion blur.
但對物體的動畫控制能力很弱.當物體要實現多種多樣的動畫時,就非常麻煩了,
可能會用到用expression控制trax.
我一般只用在大群昆蟲飛舞,動畫單一,要渲motion blur時使用.

第二種方法是把動畫物體的第一幀都bake出來.如物體有30幀動畫,那麼就bake成30個物體.
用object index來控制物體的動畫.這樣還可以根據條件讓物體做出不同的反應.
非常方便,這種方式是最常用的.
缺點就是因為前一幀和後一幀都是顯示的不同物體,所以不能做motion blur. 只能在後期中加...
但這種方式是最常用的.

其實還有一種用得較少的方式,用sprite方式,,製作很複雜,只適合particle數量巨大的群體動畫

先對物體的每個動畫做立體360度的渲染(如果有一個24幀的動畫,
那最後要渲出24x360x360幀畫面.=_= 很多啊.
當然也可以不用這麼精細,比如相隔5度渲一張就是24x120x120 也不少啊.)
然後用sprite的方式,根據每個sprite的世界坐標和camera的世界坐標相計算,
得出sprite相對於攝像機的角度,然後再求出對應的那幀圖片.
超級麻煩..而且會因為camera的遠近在透視上會發生點小問題
(數量多時也看不出來,近景的,可以instace幾個實體模型.最後合成上去).
不過這是數量巨大的群體動畫的惟一解決辦法.

2007/05/26

電腦動畫作業

作業1:用VRML做的Model



作業2:用Maya做的Model



作業3:用VRML做的小動畫



作業4:用Poser6, Endorphin, Maya做的小動畫(上傳後會delay,真奇怪!)

2007/05/15

Mel 小筆記

help -doc [command name]

setAttr:設定object屬性。

whatIs [command name or Mel script name]:判別該命令是不是Mel Script


字串處理相關命令:
substring
tokenize
size
clear
match
substitute


ls -sl; 取得所有被選取物件的名字串列
filterExpand -sm [Mask number] 只取得特定型別的物件(如Polygon, Nurbs, Particle..)

使用"source"命令可以執行mel文件。例如:
source "c:/crowd.mel";



Mel Studio Pro:
Ctrl+Shift +left click 將Mel Studio加入shelf
Ctrl+Space 語法提示 (跟輸入法切換衝, 不知道怎麼修改hot key)
Ctrl+Shift +del 清除歷史記錄

2007/04/09

Maya 7.0 小筆記

q: Select

w: Translate

e: Rotate

r: Scale

f: 將視點移至物件身上

space: 切換視野

F8: 子,母物件切換

D: 等距copy

ctrl+d: copy

ctrl+a:  切換屬性視窗

[: 上一個鏡頭

]: 下一個鏡頭

+, - : 調整x,y,z單範正交軸長度

Ctrl+g: 群組

g: 重覆使用上一個指令

z: undo

s: 存key frame

shift+z: redo

1,2,3: 調整顯示polygon數

4: 線圖

5: 實體圖

6: 材質

7: 燈光

alt+左,中,右鍵:  camera的轉動,xy平面移動,z軸移動

Edit->Select Edge Ring Tool: 雙擊較易選Edge Ring Tool

Edit->Paint Selection Tool: 較易選子物件

Modify->Center Pivot: 切換Global,Local座標系統

Polygon->Boolean: Union, Difference, Intersection

Polygon->Smooth

Edit Polygon->Extrude



Window-> Outliner

Window-> Settings/Preference -> Preferences 選左手邊Setting:
可改世界座標定位、顯示單位長

Window-> Settings/Preference -> Plug-in Manager

Window-> General Editors-> Visor:有很棒的筆刷~可以迅速產生物件

選擇物件僅受哪些光源影響
Window-> Relationship Editors -> Light Linking-> Object Centric

將camera's view獨立出來的方法:
1.選擇camera
2.Panels->Perspective->camera
3.Panels->Tear off copy


複製local motion,但僅copy model transform而不copy骨架的方法..
Edit-> Duplicate Special 方格 (Geometry type 選 instance)
(參Maya Mel Reference
This is accomplished by creation of a new transform node that points to an exisiting object. Changes to the transform are independent but changes to the "instanced" object affect all instances since the node is shared.)


製造連動的方法:(可以利用以下方法,一個驅動一個,形成連鎖反應唷!)
Animate->Set Driven Key:可以製作兩物件連動的效果
Skeleton->IK,FK
Constrain->......


Character Binding
1.選肉,選骨
2.按p or
Skin->Bind Skin->Rigid Bind
Skin->Bind Skin-> Smooth Bind


View(Top View panel)-> Camera Attribute Editor // Image name (browse) : 貼底圖



ctrl+t: 顯示Bounding Box,可使用Bounding Box移動、旋轉物件