Posts by: Austin
Last week while at Siggraph I attended a talk that mentioned ILM’s BlockParty. This is their internally developed modular rigging system. Modular rigging is an old idea, one I’ve been using for over a decade now, but the difference with BlockParty is how they chose to visualize the modules. They use a node layout similar to Maya’s Node Editor. Each node containing some visual queue as to what it is (usually an icon). This is a clever way to handle presenting and accessing a modular rigs data. Needless to say by the end of the talk I had a couple pages of notes outline how I could create my own version in Maya. On my first Sunday back from Siggraph I spent a few hours throwing together a quick prototype. Below is a short video showing the UI in action followed by the entire source code. Please keep in mind this is a proof of concept. It is buggy and missing a lot of functionality. [crayon-5e87b60b5c96f943158372/]
We’ve covered getting geometry data from an existing object and building a new object from raw data. Now we’ll start looking at non-geometry related elements of a polygon object. Continue using the cube example from the previous parts in this series lets see how to get its UV information. Start by creating a cube called Box. [crayon-5e87b60b5e170258466872/] Now get Box’s shape MObject as shown in Part 1. This will be used to confirm that we’re dealing with a poly mesh object. [crayon-5e87b60b5e178666970903/] The function set MFnMesh is used to retrieve the UV data from the mesh. [crayon-5e87b60b5e17b041976223/] We’ll be using a few member functions from MFnMesh to get the UV information. numUVSets(), use this to get the number of UV sets applied to the object. numUVs(), use this to get the number of UVs the object contains. getUVs(), use this to get each UVs U and V values. The first two are straight forward and don’t warrant a more detailed explanation. However, getUVs() does requires two parameters be passed into the function. These are both MFloatArrays with no elements which getUVs() fills with the U and V data. Elements of a MFloatArray can be accessed the same as a Python list. [crayon-5e87b60b5e17e971051939/] Running this code on our box produces the following print out. I’ve also included a couple images showing the locations of each UV. [crayon-5e87b60b5e181098081163/] Here is the complete code for this post. [crayon-5e87b60b5e183078167110/]
Last time I covered using the API to get component information about a polyShape. This time we’ll use the API to create a new polyShape cube. Start by creating an instance of MFnMesh. This is the class we’ll use to create the cube. Specifically the create() function which has a few parameters we need to provide – the number of vertices, number of polygons, vertex positions, polygon vertex count, polygon connections and the new MObject for the resulting mesh. [crayon-5e87b60b5e979115851589/] In order to make the cube we must define the various components starting with the vertices. Here’s an image showing their build order. Make special note of this order as it’s import later on when connecting each polygon together. We’re making a cube which means 8 vertices. [crayon-5e87b60b5e980822091349/] Next declare a variable containing an instance of MFloatPointArray. This will contain all the vertex positions of our cube and eventually will be passed into MFnMesh.create(). Each vertex position is defined using MFloatPoint and then appended to the MFloatPointArray variable. These positions are XYZ values in UI Units. [crayon-5e87b60b5e982068784525/] Now for the polygons. Here’s an image of the polygon build order. Start by declaring a variable with the number of faces. [crayon-5e87b60b5e985645254515/] Then create an MIntArray() that contains the number of vertices per polygon of our cube. Since it’s a cube each poly will have four verts. In this example I use MScriptUtil to assign the ints to the MIntArray. Alternatively you could use MIntArray.setLength() (this would be the number of polygons) and MIntArray.set() to define that data. [crayon-5e87b60b5e987467367115/] Finally we need to specify how the polygons connect to each vertex. We know the number of polygons (6) and the number of vertices (8). Now we associate the vertices to each polygon. Visually it looks like this: Remember vertexArray? That variable we made earlier? Its indices are what we’ll be using. Create...