playing with maya thru mel api
play

Playing with Maya thru MEL/ API Min Gyu Choi Kwangwoon University - PowerPoint PPT Presentation

Playing with Maya thru MEL/ API Min Gyu Choi Kwangwoon University Alias Maya Alias|Wavefront Maya is one of the greatest and most complex computer programs ever made. Alias Maya Alias Maya Maya has many features as default. Maya


  1. Playing with Maya thru MEL/ API Min Gyu Choi Kwangwoon University

  2. Alias Maya � Alias|Wavefront Maya is one of the greatest and most complex computer programs ever made.

  3. Alias Maya

  4. Alias Maya � Maya has many features as default. Maya Unlimited Maya Complete

  5. Alias Maya � However, Maya cannot do everything! � You can “bend” Maya in your direction. � Develop your own features. � Automate and simplify tasks � Advanced macros and your own GUI � Add new features that are not incorporated � New file formats, object types and behaviors � New dynamics and animation components � e.g., Maya Fur, Live, Cloth, Hair, and Fluid Effects

  6. Developing Maya Plug-I ns � Types of Maya plug-ins � MEL (Maya Embedded Language) commands � Nodes/commands, manipulators, contexts, locators � Maya API (Application Programmer Interface) � Gives almost unlimited access to the internal Maya interface � You can also use MEL through Maya API.

  7. Maya API � � OpenMaya for defining nodes/commands OpenMaya � Also for assembling them into a plug-in � � OpenMayaUI for creating new user interface elements OpenMayaUI � Manipulators, contexts, and locators � � OpenMayaAnim for animation OpenMayaAnim � Including deformers and inverse kinematics � � OpenMayaFX for dynamics OpenMayaFX � � OpenMayaRender for performing rendering functions OpenMayaRender

  8. Getting Started � To create a new plug-in 1. Start Visual Studio .NET Invoke File → New → Project and select Visual C++ Projects 2. 3. Select MayaPlugInWizard 4. Enter the solution name and location 5. Fill in the information � Plug-in setup, Plug-in type, Included libraries Refer to Appedix I � By the way, what to develop?

  9. What to Develop? No More “Hello World!”

  10. Elastodynamic Deformation � Elastodynamic equation for FEM 3n x 3n matrix, 3n x 1 vector + + = + + = M u C u K u F M u C u K u F & & & & & & ( ) Time-consuming!!! Linearization Not real-time!!! u : displacement

  11. Modal Analysis [Pentland & Williams ’89] � Elastodynamic equation for FEM 3n x 3n matrix, 3n x 1 vector + + = + + = M u C u K u F M u C u K u F & & & & & & ( ) Time-consuming!!! Linearization Not real-time!!! G. eigenvalue problem Modal basis = = λ u Φ q M Φ K Φ ( t ) ( t ) i i i + + = + + = M q C q K q Q & & & & & & m q c q k q Q q q q i i i i i i i Real-time performance!!! Diagonal matrices There can be linearization artifacts!!!

  12. Modal Warping [I EEE TVCG 2005] � Modal analysis in local coordinate frames + + = + + = M u C u K u F M u C u K u R F & & & & & L & L L T ( ) Linearization G. eigenvalue problem Modal basis = λ = M Φ K Φ u Φ q L ( t ) ( t ) i i i k t ∫ + + = = Φ M q C q K q Q u R q & & & k & ( t ) ( t ) dt q q q 0 Modal warping Real-time performance without linearization artifacts!!!

  13. Modal Warping

  14. The First Plug-I n � How to obtain volume meshes for FEM? � NETGEN converts polygonal meshes into volume meshes. How to obtain polygonal meshes?

  15. Click

  16. What is this? MEL command, ExportMesh Click and then choose “Shelf Editor…”

  17. MEL Script Associated with a Shelf I tem � ExportMesh defined in the File “ExportMesh.mel” global proc string export(string $filename, string $filetype ) { meshExport $filename; // We will develop this command using Maya API. return $filename; } global proc ExportMesh() { fileBrowserDialog -m 1 -fc "export" -an "Export"; }

  18. MEL Script Path � How to locate the script file “ExportMesh.mel”? � Maya searches MAYA_SCRIPT_PATH first.

  19. Command for Polygonal Mesh Export

  20. meshExport.h Command for Polygonal Mesh Export

  21. meshExport.cpp Command for Polygonal Mesh Export DagPath?

  22. Command for Polygonal Mesh Export meshExport.cpp // For all polygons in the mesh // For all vertices in the polygon Press F7 to compile and Link!

  23. Commands for Polygonal Mesh Export MAYA_PLUG_IN_PATH � How to load plug-ins (DLLs or MLLs)

  24. The Second Plug-I n � Integrate the elastodynamic equation through time + + = M u C u K u F & & & ( ) Excitation (external motion) � Displace the vertices u : displacement

  25. Solid Deformer � The dependency graph is the heart of Maya. � DG nodes are used for almost everything in Maya. � e.g., model creation, deformation, animation, simulation, … (Motion) worldMatrix[0] matrix[0] currentFrame outputGeometry[0] output inMesh (DAG node) outTime input Connections time1.outTime → dimeCluster1.CurrentFrame root.worldMatrix[0] → dimeCluster1.matrix[0] dimeCluster1.outputGeometry[0] → dinosaurShape.inMesh Plugs

  26. Registration of the Deformer Node

  27. Deformer Node class DSolidDeformer : public MPxDeformerNode dSolidDeformer.h { public: static MTypeId id; MObject currentFramePlug; MObject matrixPlug; Plugs Mobject rigidityPlug; // ... public: DSolidDeformer(); ~DSolidDeformer(); static void* creator(); static MStatus initialize(); virtual MStatus deform(MDataBlock&, MItGeometry&, const MMatrix&, unsigned); // ... };

  28. Deformer Node � This method is called once after the plug-in is loaded. � Define the inputs and outputs of the node MStatus DSolidDeformer::initialize() { currentFramePlug = nAttr.create(“currentFrame”,“cf”, MFnNumericData::kLong); nAttr.setDefault(0); nAttr.setHidden(true); MStatus status = addAttribute(currentFramePlug); if (!status){ status.perror(“addAttr()”); return status; } // ... attributeAffects(currentFramePlug, outputGeom); // ... }

  29. Deformer Node MStatus DSolidDeformer::deform(MDataBlock& block, MItGeometry&, const MMatrix&, unsigned) { MStatus status; MDataHandle inputData; inputData = block.inputValue(currentFramePlug, &status); int currentFrame = inputData.asLong(); // ... Input // computes displacedVertices ... MArrayDataHandle outputData; outputData = block.outputArrayValue(outputGeom, &status); MDataHandle outMesh = outputData.outputValue(&status); MFnMesh mesh(outMesh.asMesh(), &status); mesh.setPoints(displacedVertices, Mspace::kWord); Output return status; }

  30. Creating Deformer Nodes � Press F7 to compile and link � You have to do many things … � Load the plug-in � Create a deformer node, and then connect the plugs deformer –type dimeCluster; connect time1.outTime dimeCluster1.currentFrame; connect root.worldMatrix[0] dimeCluster1.matrix[0]; � This can be automated by MEL and shelf items!

  31. How to change simulation constants?

  32. Customizing Attribute Editor AEdimeClusterTemplate.mel AEdimeClusterTemplate.mel should be located in MAYA_SCRIPT_PATH.

  33. Additional DAG Nodes for Visualization � To visualize useful information � We need to develop additional DAG nodes. With local axes at the mesh nodes

  34. Additional DAG Nodes for Visualization � Derived node of MPxSurfaceShape � This node gets connection to the deformer node though backward traversal of the connected plug. � (MPxSurfaceShapeUI supports OpenGL for H/W rendering) drawingParamter

  35. Additional DG Nodes for Constraints � To specify the manipulation constraints � We need to develop additional dependency nodes. Position-constrained Position/Orientation Orientation-constrained

  36. Additional DG Nodes for Constraints � Derived node of MPxNode � Simple attributes � Simple connections const[0] output worldMatrix[0] matrix

  37. Additional DG Nodes for Constraints

  38. Additional DG Nodes for Constraints

  39. Thin-Shelled Deformable Characters � Degenerate cases: more difficult problems � Thin shell: 2 dimensional solids, i.e. surfaces � The plug-in is similar to the solid deformer.

  40. Free-Floating Deformable Characters � Modal warping rigid body simulation � Impulse-based collisions and multiple contacts [Baraff ’92, ’94]

  41. Free-Floating Deformable Characters worldMatrix[0] Obstacles worldMatrix[0] obstacle[3] obstacle[2] worldMatrix[0] obstacle[1] obstalce[0] worldMatrix[0]

  42. Free-Floating Deformable Characters � Modal warping rigid body simulation � Impulse-based collisions and multiple contacts [Baraff ’92, ’94]

  43. Motion Planning [ACM TOG 2003] � MPxSurfaceShape for hardware rendering � It can be used for visualization though image composition.

  44. I mage Composition � Obtain images with depth values � Composite images based on depth values

  45. I mage Composition

  46. Motion Planning

  47. Dynamic Strand � Maya can also be used for fast prototyping. � By developing a command that adjusts only transform nodes Movie obtained by playblast

  48. Dynamic Strand � Maya can also be used for fast prototyping. � If successful, develop relatively sophisticated nodes. Movie obtained by playblast

Recommend


More recommend