Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Maya Programming Shuen-Huei Guan CML, CSIE, National Taiwan University 2003/10/7.

Similar presentations


Presentation on theme: "Introduction to Maya Programming Shuen-Huei Guan CML, CSIE, National Taiwan University 2003/10/7."— Presentation transcript:

1 Introduction to Maya Programming Shuen-Huei Guan CML, CSIE, National Taiwan University 2003/10/7

2 2 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Overview Introduction Philosophy behind Maya Maya programming Tutorial: exporter Assignment

3 3 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Why? Maya is everywhere, especially in game / film / animation. Maya expert := Artist + Computer Scientist. Uncle Sam needs you.

4 4 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Introduction to Alias Alias Research, 1983. Wavefront Technologies, 1984. Alias|Wavefront under SGI, 1995. Alias ®, 2003.

5 5 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Introduction to Maya Released in 1998. Rumor has it that Implemented by over 200 PhDs. Too big s.t. no one knows it well. Alias ® is going bigger.

6 6 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Let ’ s Use Maya Basic transformation. Selection by object, component. Polygonal modeling. Mirror.

7 7 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Lecture Outline Introduction Philosophy behind Maya Maya programming Tutorial: exporter Assignment

8 8 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Philosophy behind Maya Before being a programmer, be a philosopher first. Truly, It is ugly. But luckily, it is not that ugly as Microsoft things.

9 9 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Philosophy Overview Naming Conversion Data Structure Function Sets

10 10 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Naming Conversion PrefixLogical GroupingExample MMaya classMPoint MPxProxy objectMPxNode MItIterator classMItDag MFnFunction setMFnMesh

11 11 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 3D Rendering Pipeline Static model Shading Texture Animation Rendering

12 12 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 3D Rendering Pipeline Static model Shading Texture Animation Rendering

13 13 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 3D Rendering Pipeline Static model Shading Texture Animation Rendering See test.avi

14 14 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Pipeline: Data Model Textured Model Animated Model … Viewpoint of data

15 15 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Pipeline: Operators Polygon Manipulator Shader Animation Curve … Viewpoint of operators

16 16 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Structure in Maya Node Structure Directed Acyclic Graph Dependency Graph

17 17 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Node Hierarchy

18 18 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Function Sets Objects are hidden as handles (IDs). Use Function sets to access objects.

19 19 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Function Sets in Diagram Data Hierarchy Group GraphicsGrpDSPGrpNetworkGrp Function Set Hierarchy GroupFn GraphicsGrpFnDSPGrpFnNetworkGrpFn

20 20 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Example: Traditional Class CMesh* poMesh = poScene->getMesh(“dove”); poVexArray = poMesh->getVexArray(); iPolyNum = poMesh->getPolyNum(); for (i=0; i<PolyNum; i++) { … }

21 21 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Example: Function Sets MMesh oMesh = oScene.getMesh (“dove”); MFnMesh oMeshFn(oMesh); MArray oArray = oMeshFn.getVexArray (); iPolyNum = oMeshFn.getPolyNum (); for (i=0; i<iPolyNum; i++) { … }

22 22 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Lecture Outline Introduction Philosophy behind Maya Maya programming Tutorial: exporter Assignment

23 23 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Maya Programming 2 choices for Maya programming Maya Embedded Language (MEL) C++ API Not exclusive to each other. Not a set-relationship.

24 24 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Introduction to MEL Familiar C-style grammar. GUI maker. All you do is through MEL. Maya := DLLs + MEL.

25 25 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Lecture Outline Introduction Philosophy behind Maya Maya programming Tutorial: exporter Assignment

26 26 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Tutorial: exporter Exporter: Input: scene file (.mb/.ma) Platform: Maya Output: obj file (.obj)

27 27 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Things you need to know Foundation.lib OpenMaya.lib. Use Maya wizard to ease life. Inherit from MPxFileTranslator. Put plug-in in ~Maya/bin/plug-ins. Sample: lepTranslator.

28 28 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Exporter Traverse all nodes. Pick out mesh nodes. Extract data. Vertices Polygons Materials Animation curves

29 29 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Exporter: Initialization Entries of plug-in (dll / mll). initializePlugin() uninitializePlugin() Pseudo constructor to Maya MPxFileTranslator::creator() Entry for exporter MPxFileTranslator::writer()

30 30 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Exporter: extract vertices 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]; … }

31 31 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Exporter: extract 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()) { … }

32 32 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Exporter: notes Ignore Intermediate nodes. Unload plug-in before you replace it. Use memory as effectively as possible. Maya Developer's Tool Kit.

33 33 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Lecture Outline Introduction Philosophy behind Maya Maya programming Tutorial: exporter Assignment

34 34 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Assignment

35 35 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Reference Maya API White Paper Book: David Gould. Complete Maya Programming, Morgan-Kaufmann Publishers 3D User Magazine Web: http://www.aliaswavefront.com/ http://www.highend3d.com/ http://www.learning-maya.com/

36 36 Shuen-Huei Guan, CMLAB, CSIE, NTU @2003 Appendix Maya Personal Learning Edition for Maya Complete 5 Free downloading coming Oct. 15, 2003. No Maya Dev-kit. Plug-ins does not work.

37 Thanks for your attendance


Download ppt "Introduction to Maya Programming Shuen-Huei Guan CML, CSIE, National Taiwan University 2003/10/7."

Similar presentations


Ads by Google