Introduction to the Maya C++ API Brent Haley The Ohio State University

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
Advertisements

Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Compilation and Debugging 101. Compilation in C/C++ hello.c Preprocessor Compiler stdio.h tmpXQ.i (C code) hello.o (object file)
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Object Oriented Programming in Java George Mason University Fall 2011
The Web Warrior Guide to Web Design Technologies
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Trees. Definition of a tree A tree is like a binary tree, except that a node may have any number of children –Depending on the needs of the program, the.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to a Programming Environment
Guide To UNIX Using Linux Third Edition
7/14/2015EECS 584, Fall MapReduce: Simplied Data Processing on Large Clusters Yunxing Dai, Huan Feng.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
Using Ant to build J2EE Applications Kumar
Java versus C# An introduction to C# and Visual Studio.
JavaScript & jQuery the missing manual Chapter 11
Introduction to Maya Dependency Graph Programming
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CSC 338: Compiler design and implementation
ICONICS ActiveX ToolWorX V 6.1.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
CS 450: COMPUTER GRAPHICS INSTALLING GLUT AND GLEW SPRING 2015 DR. MICHAEL J. REALE.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
GEMVC. The Setup Folders Views Value Objects (VOs) Custom Events Service CFCs Controller Model Application Main MXML.
Introduction to C & C++ Lecture 10 – library JJCAO.
SYSTEMSDESIGNANALYSIS 1 OO: Chapter 9 Visual Basic: Building Components Jerry Post Copyright © 1999.
Fall 2004CSI University of Ottawa Introduction to PHP Basic principles and syntax.
C/C++ Programming Environment
111 Introduction to OGRE3D Programming: Main Loop.
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Introduction to Maya Programming Shuen-Huei Guan CML, CSIE, National Taiwan University 2003/10/7.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Introduction to the Maya C++ API Brent Haley The Ohio State University
Copyright © 2015 Curt Hill Java for Minecraft Those things you should know.
Pipeline Introduction Sequential steps of –Plugin calls –Script calls –Cluster jobs Purpose –Codifies the process of creating the data set –Reduces human.
Compiler Directives. The C Preprocessor u The C preprocessor (cpp) changes your source code based on instructions, or preprocessor directives, embedded.
Open project in Microsoft Visual Studio → build program in “Release” mode.
CS777 Project 1 Developing Maya Plug-ins for motion related projects Kyungsuk David Lee.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
Topic 2: Hardware and Software
The build process + misc
& BuildingTcl & BuildingTclViewer Getting Started Guide
University of Central Florida COP 3330 Object Oriented Programming
6.001 SICP Compilation Context: special purpose vs. universal machines
PRU-ICSS Programming with CCS
University of Central Florida COP 3330 Object Oriented Programming
Trees.
CompSci 230 Software Construction
CMPE 152: Compiler Design ANTLR 4 and C++
Java Programming Language
Govt. Polytechnic,Dhangar
Lab 1 Introduction to C++.
Trees.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Preparation for Assignment 2
The Role of Command Line Compiler (csc.exe)
1.3.7 High- and low-level languages and their translators
SPL – PS1 Introduction to C++.
Plug-In Architecture Pattern
Presentation transcript:

Introduction to the Maya C++ API Brent Haley The Ohio State University

Topics Mud Plugin Introduction How to Create a MLL Command Basics Node Basics

Programming for Maya The Book (Complete Maya Programming) MEL Scripts –Can be really easy to test –Can see how Maya does its own with echo –Hard to get complex data structures –Slow, due to interpretation C++ API Plugins –Very confusing at first (and later), hard to find help / concise examples –Fast, due to machine language

Particles in Maya Maya has a built in particle system Can exploit this to build a particle based fluid dynamics system I took a procedural rather than physically based approach

Particle Based Fluid Idea –Use maya particle dynamics to create the fluid –Have a voxelized force field, with a different force in each voxel –Force depends on particles as well as constants

Plugin Realization Needs –Command to create the mud system –Node(s) to do the computations –Visual cues to locate where the field is –Go FAST (so I used the API + split particle system)

Topics Mud Plugin Introduction How to Create a MLL Command Basics Node Basics

Create a Visual C++ Project The project creation wizard is not installed Make a Win32Project Under application settings, choose dll and empty project

Open the Project Properties Note: make sure you apply the settings on the next slide to both the debug and release versions (all configs should work).

Set the Project Properties C/C++ -> General -> Additional Include Directories: C:\Program Files\AliasWavefront\Maya6.0\include C/C++ -> CommandLine -> Additional Options: /I "C:\Program Files\AliasWavefront\Maya6.0\include“ C/C++ -> Preprocessor -> Preprocessor Definitions: WIN32;NDEBUG;_WINDOWS;NT_PLUGIN Linker -> General -> Output File: change the.dll to.mll Linker -> Input -> Additional Dependencies: opengl32.lib Foundation.lib OpenMaya.lib OpenMayaUI.lib OpenMayaAnim.lib OpenMayaFX.lib OpenMayaRender.lib Linker -> CommandLine -> Additional Options: /LIBPATH:"C:\Program Files\AliasWavefront\Maya6.0\lib" /export:initializePlugin /export:uninitializePlugin

Required Code #include MStatus initializePlugin(MObject obj) { MStatus stat; MFnPlugin plugin(obj, "Brent Haley", "2.2.1", "5.0.1"); return(stat); } MStatus unintializePlugin(MObject obj) { MStatus stat; MFnPlugin plugin(obj); return(stat); } Initialize plugin procedure is an entry point that gets called when you load your plugin in Maya Uninitialize plugin procedure is an entry point that gets called when you unload your plugin from Maya Remember these were specified under the project settings Through these entry points we tell Maya what Nodes and Commands our Plugin has

Topics Mud Plugin Introduction How to Create a MLL Command Basics Node Basics

Example Command Specification class MudBoxCommand : public MPxCommand { public: //creator function static void *creator(); //command execution functions virtual MStatus doIt(const MArgList &args); virtual MStatus redoIt(); virtual MStatus undoIt(); virtual bool isUndoable() const; private: //graph modifier, used to support undo and redo MDagModifier dagMod; }; Implementation (except doIt) void *MudBoxCommand::creator() { return new MudBoxCommand; } MStatus MudBoxCommand::redoIt() { //commit the work set in doIt MStatus stat = dagMod.doIt(); return(stat); } MStatus MudBoxCommand::undoIt() { //erase any work set in doIt MStatus stat = dagMod.undoIt(); return(stat); } bool MudBoxCommand::isUndoable() const {return(true);}

doIt Where the actual work is done Changes made to the graph Get nodes through selection Get data through those nodes “plugs” Be careful not to setup a cyclic graph See examples (mud & joint extractor plugins, note the joint extract is a LOT simpler to script)

(De)Register the Command Register commands in the initializePlugin procedure (from the required bit of code) stat = plugin.registerCommand( "makeMud", MudBoxCommand::creator); if (!stat) MGlobal::displayError("register MudBoxCommand failed"); Deregister commands in the unitializePlugin procedure stat = plugin.deregisterCommand("makeMud"); if (!stat) MGlobal::displayError("deregister MudBoxCommand failed");

Topics Mud Plugin Introduction How to Create a MLL Command Basics Node Basics

Example Node Specification class MudBoxNode : public MPxNode { public: //identifier static MTypeId id; //attributes static MObject boxCenterX; … //creator function static void *creator(); //initializer for the node static MStatus initialize(); //computational function to do the real work virtual MStatus compute (const MPlug &plug, MDataBlock &data); private: … }; Implementation (except for compute) void *MudBoxNode::creator() { return new MudBoxNode; } MStatus MudBoxNode::initialize() { //create the attributes for spacial subdivision MFnNumericAttribute boxAttributes; boxCenterX = boxAttributes.create("boxCenterX", "bcx", MFnNumericData::kDouble, 0.0);... //add the attributes to the node addAttribute(boxCenterX);... //specify attribute relations attributeAffects(boxCenterX, boxData);... //return without error return(MS::kSuccess); }

Compute Where the actual work is done See examples (mud plugin) MStatus MudBoxNode::compute (const MPlug &plug, MDataBlock &data) { MStatus stat; //determine which output plug needs to be computed if (plug == boxData) { //get input data handles MDataHandle boxCenterXData = data.inputValue(boxCenterX);... //turn input handles into data double bcx = boxCenterXData.asDouble();... //get output data handles MDataHandle outputBoxData = data.outputValue(boxData); //turn output handles into data //set the output data and mark the plug outputBoxData.set(ssbDataFn.object()); data.setClean(plug);} else //the plug is for an ancestor, return unknown stat = MS::kUnknownParameter; return(stat);}

(De)Register the Node Register nodes in the initializePlugin procedure stat = plugin.registerNode( "MudBoxNode", MudBoxNode::id, &MudBoxNode::creator, &MudBoxNode::initialize, MPxNode::kDependNode ); if (!stat) MGlobal::displayError("register MudBoxNode failed"); Deregister nodes in the uninitializePlugin procedure stat = plugin.deregisterNode(MudBoxNode::id); if (!stat) MGlobal::displayError("deregister MudBoxNode failed");