locked
Programming in Maya RRS feed

  • Question

  • Does anyone here know how to do programming in Maya, and also tutorial about maya ? or reference material, etc etc ?

    Saturday, March 31, 2007 12:42 PM

Answers

  • Sorry Harshil, no idea about that.
    Sunday, April 1, 2007 4:57 PM
  • anyways thanks for the reply m8.
    Sunday, April 1, 2007 5:55 PM
  • Hey Harshil, if you come to anything about that, put it here. Am waiting for your reply.

    Sunday, April 1, 2007 6:11 PM
  • For sure Sanket. Ill put it here as soon as i find anything about it Smile
    Sunday, April 1, 2007 6:14 PM
  • Thanks Harshil. Smile
    Sunday, April 1, 2007 6:23 PM
  • A program that tells Maya to load a file and let you wander through its data structures:
    Code Snippet



    Code Snippet
    // initialize Maya, before any Maya operations are performed.
    // You might do this in main for example:
    void main()
    {
    MStatus stat = MLibrary::initialize ( "myExporter" );
    if ( !stat )
    return false;

    // figure out the file name to open
    char* fileName = getFileNameToLoad();

    // prepare Maya to read a new scene file
    MFileIO::newFile( true );

    // read the scene file
    stat = MFileIO::open( fileName );
    if ( !stat )
    return false;

    // remove any temporary data created by Maya while loading
    // things like the undo list which we won't be using
    stat = MGlobal::executeCommand( "delete -ch" );
    if ( !stat )
    return false;

    // iterate through all the nodes in the DAG, and print out their names
    MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &stat );
    for ( ; !dagIter.isDone(); dagIter.next())
    {
    MDagPath dagPath;
    stat = dagIter.getPath( dagPath );

    cerr << "Found DAG Node: "
    << dagPath.fullPathName().asChar()
    << endl;
    }

    // now shut down Maya, or if you want to process another file,
    // just make another call to MFileIO::newFile(), and MFileIO::open()
    MLibrary::cleanup();
    }




     
    Compile it, and link it with these .DLLs:

    Foundation.lib OpenMaya.lib



    Monday, April 2, 2007 4:39 AM
  • You need to get a Maya software for this rite?? Does anyone knows how to do graphics in C or C++ ?? Either we can have it here or I start a new thread for it??
    Monday, April 2, 2007 4:13 PM

  • Program to extract vertices...  
    void extractVertices()
    {
    // we assume here that Maya has been initialized and the file in
    // question has already been loaded.

    MStatus stat;
    MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &stat );

    for ( ; !dagIter.isDone(); dagIter.next())
    {
    MDagPath dagPath;
    stat = dagIter.getPath( dagPath );

    if ( stat )
    {
    MFnDagNode dagNode( dagPath, &stat );

    // this object cannot be intermediate, and it must be a mesh
    // and it can't be a transform.
    // Intermediate objects are special meshes
    // that are not drawn used for mesh morphs or something.
    if ( dagNode.isIntermediateObject()) continue;
    if ( !dagPath.hasFn( MFn::kMesh )) continue;
    if ( dagPath.hasFn( MFn::kTransform )) continue;

    MFnMesh fnMesh( dagPath );

    // get the vertices that are part of the current mesh
    MPointArray vertexList;
    fnMesh.getPoints( vertexList, MSpace::kWorld );

    // iterate through all the vertices
    for ( u32 i = 0; i < vertexlist.length(); i++ )
    {
    vertexlist[i].cartesianize();
    mpoint point = vertexlist[i];

    // here is your data... now go do whatever you want with
    // it. if you need a unique identifier for this vertex,
    // use it's index in the mesh, and some kind of mesh id.
    // these stay constant while exporting ( so long as the file is
    // not edited )
    processvertex( point.x, point.y, point.z );
    }
    }
    }
    }
    The code is pretty self explanatory. dagIter iterates through all the nodes in the DAG, where your vertices are. Everytime you find a node that supports the MFn::kMesh type, and is not a transform, or an intermediate node, then you use it to make an MFnMesh object, and extract vertices. Notice when go to get the vertices themselves, you request what space you want them represented in. MSpace::kWorld will convert the vertex into world space for you ( by multiplying the vertex by all the transforms from the root of the DAG on down ). You can also ask it to give you the vertices in any number of local spaces if you are extracting skeletal data as well.
    Monday, April 2, 2007 6:05 PM
  • Isn't maya a 3d animation software?
    Sunday, April 15, 2007 2:50 AM
  • Maya is a 3D animation software but it also supports object programming like Flash.
    Sunday, April 15, 2007 8:07 AM
  • Thanks for the support folks, hope you guys post something when you find anything related to maya programming. i am still looking for it.
    Sunday, April 15, 2007 12:39 PM
  • yups, m8

    there are otheres also equivalent to Maya,

    like Arena Multimedia.....

    Thursday, April 26, 2007 9:36 AM
  • I found some Maya Scripting tutorials. Here.
    Thursday, April 26, 2007 12:16 PM

All replies

  • Sorry Harshil, no idea about that.
    Sunday, April 1, 2007 4:57 PM
  • anyways thanks for the reply m8.
    Sunday, April 1, 2007 5:55 PM
  • Hey Harshil, if you come to anything about that, put it here. Am waiting for your reply.

    Sunday, April 1, 2007 6:11 PM
  • For sure Sanket. Ill put it here as soon as i find anything about it Smile
    Sunday, April 1, 2007 6:14 PM
  • Thanks Harshil. Smile
    Sunday, April 1, 2007 6:23 PM
  • A program that tells Maya to load a file and let you wander through its data structures:
    Code Snippet



    Code Snippet
    // initialize Maya, before any Maya operations are performed.
    // You might do this in main for example:
    void main()
    {
    MStatus stat = MLibrary::initialize ( "myExporter" );
    if ( !stat )
    return false;

    // figure out the file name to open
    char* fileName = getFileNameToLoad();

    // prepare Maya to read a new scene file
    MFileIO::newFile( true );

    // read the scene file
    stat = MFileIO::open( fileName );
    if ( !stat )
    return false;

    // remove any temporary data created by Maya while loading
    // things like the undo list which we won't be using
    stat = MGlobal::executeCommand( "delete -ch" );
    if ( !stat )
    return false;

    // iterate through all the nodes in the DAG, and print out their names
    MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &stat );
    for ( ; !dagIter.isDone(); dagIter.next())
    {
    MDagPath dagPath;
    stat = dagIter.getPath( dagPath );

    cerr << "Found DAG Node: "
    << dagPath.fullPathName().asChar()
    << endl;
    }

    // now shut down Maya, or if you want to process another file,
    // just make another call to MFileIO::newFile(), and MFileIO::open()
    MLibrary::cleanup();
    }




     
    Compile it, and link it with these .DLLs:

    Foundation.lib OpenMaya.lib



    Monday, April 2, 2007 4:39 AM
  • You need to get a Maya software for this rite?? Does anyone knows how to do graphics in C or C++ ?? Either we can have it here or I start a new thread for it??
    Monday, April 2, 2007 4:13 PM

  • Program to extract vertices...  
    void extractVertices()
    {
    // we assume here that Maya has been initialized and the file in
    // question has already been loaded.

    MStatus stat;
    MItDag dagIter( MItDag::kBreadthFirst, MFn::kInvalid, &stat );

    for ( ; !dagIter.isDone(); dagIter.next())
    {
    MDagPath dagPath;
    stat = dagIter.getPath( dagPath );

    if ( stat )
    {
    MFnDagNode dagNode( dagPath, &stat );

    // this object cannot be intermediate, and it must be a mesh
    // and it can't be a transform.
    // Intermediate objects are special meshes
    // that are not drawn used for mesh morphs or something.
    if ( dagNode.isIntermediateObject()) continue;
    if ( !dagPath.hasFn( MFn::kMesh )) continue;
    if ( dagPath.hasFn( MFn::kTransform )) continue;

    MFnMesh fnMesh( dagPath );

    // get the vertices that are part of the current mesh
    MPointArray vertexList;
    fnMesh.getPoints( vertexList, MSpace::kWorld );

    // iterate through all the vertices
    for ( u32 i = 0; i < vertexlist.length(); i++ )
    {
    vertexlist[i].cartesianize();
    mpoint point = vertexlist[i];

    // here is your data... now go do whatever you want with
    // it. if you need a unique identifier for this vertex,
    // use it's index in the mesh, and some kind of mesh id.
    // these stay constant while exporting ( so long as the file is
    // not edited )
    processvertex( point.x, point.y, point.z );
    }
    }
    }
    }
    The code is pretty self explanatory. dagIter iterates through all the nodes in the DAG, where your vertices are. Everytime you find a node that supports the MFn::kMesh type, and is not a transform, or an intermediate node, then you use it to make an MFnMesh object, and extract vertices. Notice when go to get the vertices themselves, you request what space you want them represented in. MSpace::kWorld will convert the vertex into world space for you ( by multiplying the vertex by all the transforms from the root of the DAG on down ). You can also ask it to give you the vertices in any number of local spaces if you are extracting skeletal data as well.
    Monday, April 2, 2007 6:05 PM
  • Isn't maya a 3d animation software?
    Sunday, April 15, 2007 2:50 AM
  • Maya is a 3D animation software but it also supports object programming like Flash.
    Sunday, April 15, 2007 8:07 AM
  • Thanks for the support folks, hope you guys post something when you find anything related to maya programming. i am still looking for it.
    Sunday, April 15, 2007 12:39 PM
  • yups, m8

    there are otheres also equivalent to Maya,

    like Arena Multimedia.....

    Thursday, April 26, 2007 9:36 AM
  • I found some Maya Scripting tutorials. Here.
    Thursday, April 26, 2007 12:16 PM
  • Thank you Rakshit.
    Friday, April 27, 2007 12:42 PM