8/7/2019 Introduction to Maya Programming
1/37
Introduction toMaya Programming
Shuen-Huei GuanCML, CSIE, National Taiwan University2003/10/7
8/7/2019 Introduction to Maya Programming
2/37
2Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
Ove r v iew
IntroductionPhilosophy b e hind MayaMaya programmingT utorial: ex port e r Assignm e nt
8/7/2019 Introduction to Maya Programming
3/37
3Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
W hy?
Maya is eve ry w h e r e, e sp e ciallyin gam e / film / animation.
Maya ex p e rt := A rtist + Comput e r Sci e ntist.
U ncl e Sam n ee ds you.
8/7/2019 Introduction to Maya Programming
4/37
4 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Introduction to A lias
A lias R e s e arch , 1983.W a ve front Te chnologi e s , 1984.A lias| W a ve front und e r SGI , 1995.A lias , 2003.
8/7/2019 Introduction to Maya Programming
5/37
5 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Introduction to Maya
R e le as e d in 1998.
Rumor has it thatImpl e m e nt e d by o ve r 200 PhDs.T oo big s.t. no on e kno w s it we ll.
A lias is going bigg e r.
8/7/2019 Introduction to Maya Programming
6/37
6 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
L e t s U s e Maya
B asic transformation.S e le ction by obj e ct , compon e nt.Polygonal mod e ling.Mirror.
8/7/2019 Introduction to Maya Programming
7/37
7 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
L e ctur e O utlin e
IntroductionPhilosophy b e hind MayaMaya programmingT utorial: ex port e r Assignm e nt
8/7/2019 Introduction to Maya Programming
8/37
8 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Philosophy b e hind Maya
Be for e b e ing a programm e r , b e aphilosoph e r first.
T ruly , It is ugly. B ut luckily , it isnot that ugly as Microsoft things.
8/7/2019 Introduction to Maya Programming
9/37
9 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Philosophy Ove r v iew
N aming Con ve rsion
Data Structur e
F unction S e ts
8/7/2019 Introduction to Maya Programming
10/37
10 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
N aming Con ve rsion
Pr e fi x L ogical Grouping E x ampl e
M Maya class MPoint
MPx Proxy object MPxNode
MIt Iterator class MItDag
MFn Function set MFnMesh
8/7/2019 Introduction to Maya Programming
11/37
11 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
3D R e nd e ring Pip e lin e
Static mod e lShading
Tex tur eAnimationR e nd e ring
8/7/2019 Introduction to Maya Programming
12/37
12 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
3D R e nd e ring Pip e lin e
Static mod e lShading
Tex tur eAnimationR e nd e ring
8/7/2019 Introduction to Maya Programming
13/37
13 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
3D R e nd e ring Pip e lin e
Static mod e lShading
Tex tur eAnimationR e nd e ring
See test.avi
8/7/2019 Introduction to Maya Programming
14/37
14 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Pip e lin e : Data
Mod e l
Tex tur e d Mod e l
Animat e d Mod e l
Vi ew point of data
8/7/2019 Introduction to Maya Programming
15/37
15 Shuen-Huei Guan, CMLAB, CSIE,NTU @2003
Pip e lin e : O p e rators
Polygon Manipulator
Shad e r
Animation Cur ve
Vi ew point of op e rators
8/7/2019 Introduction to Maya Programming
16/37
16 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
Structur e in Maya
N od e Structur e
Dir e ct e d Acyclic Graph
De p e nd e ncy Graph
8/7/2019 Introduction to Maya Programming
17/37
17 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
N od e Hi e rarchy
8/7/2019 Introduction to Maya Programming
18/37
18 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
F unction S e ts
O bj e cts ar e hidd e n as handl e s(IDs).
U s e F unction s e ts to acc e ssobj e cts.
8/7/2019 Introduction to Maya Programming
19/37
19 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
F unction S e ts in DiagramData Hi e rarchy
Group
GraphicsGrp DSPGrp Ne t w orkGrp
F unction S e t Hi e rarchy
Group F n
GraphicsGrp F n DSPGrp F n Ne t w orkGrp F n
8/7/2019 Introduction to Maya Programming
20/37
20 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x ampl e : T raditional Class
CMesh* poMesh = poScene->getMesh(dove);
poVexArray = poMesh->getVexArray();
iPolyNum = poMesh->getPolyNum();
for (i=0; i
8/7/2019 Introduction to Maya Programming
21/37
21 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x ampl e : F unction S e ts
MMesh oMesh = oScene.getMesh (dove);MFnMesh oMeshFn(oMesh);
MArray oArray = oMeshFn.getVexArray ();iPolyNum = oMeshFn.getPolyNum ();
for (i=0; i
8/7/2019 Introduction to Maya Programming
22/37
22 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
L e ctur e O utlin e
IntroductionPhilosophy b e hind Maya
Maya programmingT utorial: ex port e r Assignm e nt
8/7/2019 Introduction to Maya Programming
23/37
23 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
Maya Programming
2 choic e s for Maya programmingMaya Emb e dd e d L anguag e (ME L )
C++ API
N ot ex clusi ve to e ach oth e r.
N ot a s e t-r e lationship.
8/7/2019 Introduction to Maya Programming
24/37
24 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
Introduction to ME L
F amiliar C-styl e grammar.G U I mak e r.
A ll you do is through ME L .
Maya := D LL s + ME L .
8/7/2019 Introduction to Maya Programming
25/37
25 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
L e ctur e O utlin e
IntroductionPhilosophy b e hind Maya
Maya programmingT utorial: ex port e r Assignm e nt
8/7/2019 Introduction to Maya Programming
26/37
26 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
T utorial: ex port e r
E x port e r:Input: sc e n e fil e (.mb/.ma)
Platform: MayaO utput: obj fil e (.obj)
8/7/2019 Introduction to Maya Programming
27/37
27 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
T hings you n ee d to kno w
F oundation.lib O p e nMaya.lib.U s e Maya w izard to e as e lif e .
Inh e rit from MP xF il eT ranslator.Put plug-in in ~Maya/bin/plug-ins.
Sampl e : l e p T ranslator.
8/7/2019 Introduction to Maya Programming
28/37
28 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x port e r
T ra ve rs e all nod e s.Pick out m e sh nod e s.
E x tract data.Ve rtic e sPolygons
Mat e rialsAnimation cur ve s
8/7/2019 Introduction to Maya Programming
29/37
29 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x port e r: Initialization
Entri e s of plug-in (dll / mll).initializ e Plugin()
uninitializ e Plugin()Ps e udo constructor to Maya
MP xF il eT ranslator::cr e ator()
Entry for ex port e r MP xF il eT ranslator:: w rit e r()
8/7/2019 Introduction to Maya Programming
30/37
30 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x port e r: ex tract ve rtic e s
MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &status);for ( ; !dagIter.isDone(); dagIter.next()) {
MObject obj = dagIter.item ();MFnMesh (obj, &status);
MPointArray vertexList;fnMesh.getPoints (vertexList, MSpace::kWorld );
for (i=0; i< vertexList.length(); i++) {vertexList[i].cartesianize ();MPoint point = vertexList[i];
}}
8/7/2019 Introduction to Maya Programming
31/37
31 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x port e r: ex tract polygons
MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &status);for ( ; !dagIter.isDone(); dagIter.next()) {
MObject obj = dagIter.item ();MFnMesh (obj, &status);
MPointArray vertexList;fnMesh.getPoints (vertexList, MSpace::kWorld );
MItMeshPolygon piter (obj, &status);for (; !piter.isDone(); piter.next()) {
}
}
8/7/2019 Introduction to Maya Programming
32/37
32 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
E x port e r: not e s
Ignor e Int e rm e diat e nod e s.U nload plug-in b e for e you
r e plac e it.U s e m e mory as e ff e cti ve ly aspossibl e .
Maya D eve lop e r's T ool Kit.
8/7/2019 Introduction to Maya Programming
33/37
33 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
L e ctur e O utlin e
IntroductionPhilosophy b e hind Maya
Maya programmingT utorial: ex port e r Assignm e nt
8/7/2019 Introduction to Maya Programming
34/37
34 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
Assignm e nt
8/7/2019 Introduction to Maya Programming
35/37
35 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
R e f e r e nc e
Maya API W hit e Pap e r B ook:
Da v id Gould. Compl e t e MayaProgramming , Morgan-KaufmannPublish e rs3D U s e r Magazin e
W e b:
http:// www .alias w a ve front.com/http:// www .high e nd3d.com/http:// www .l e arning-maya.com/
8/7/2019 Introduction to Maya Programming
36/37
36 Shuen-Huei Guan, CMLAB, CSIE,
NTU @2003
App e ndi x
Maya P e rsonal L e arning Editionfor Maya Compl e t e 5
F r ee do w nloading coming O ct. 15 , 2003.N o Maya D ev -kit.Plug-ins do e s not w ork.
8/7/2019 Introduction to Maya Programming
37/37
T hanks for your att e ndanc e