Showing posts with label maya. Show all posts
Showing posts with label maya. Show all posts

Saturday, August 1, 2015

Custom MPxCommand

Wow this API stuff is really cool. As I'm picking it up it is like learning a language. I'm getting more fluent and understanding the power of it more and more. So I have written a few dependencyNodes now, so I thought I'd make a custom MPxCommand.

I built a command that searches the dependencyGraph for a given node type. You specify the node type to search for and the direction to search in. YOu then call it just as though it is another maya command. So rad as this can now be built into my code as if it were just part of maya.


So my command is: findConnectedNodeType. You call it like:

node = cmds.findConnectedNodeType('blendColors','up')

The return value is either False or the found node name. The command looks through the upstream dependencyGraph until the first instance of that node is found. It then stops the iteration and returns the node name.

Cool stuff I learnt.

To return from a MPxCommand you must use the public function of MPxCommand setResult.

self.setResult(return value goes here)

This comes at the end of the doIt() function.

Enumerators are also making a bit more sense now that I am using them more. For example I had to use MItDependencyGraph. You can specify the direction to search, up or down stream. The help docs show this for the direction.

MItDependencyGraph     (     MObject &      rootNode,
        MPlug &      rootPlug,
        MIteratorType &      infoObject,
        Direction      direction = kDownstream,
        Traversal      traversal = kDepthFirst,
        Level      level = kNodeLevel,
        MStatus *      ReturnStatus = NULL
    )

and this:

enum Direction
Direction within the DG relative to root Node or Plug.
Enumerator:
kDownstream  From source to destination.
kUpstream  From destination to source.
A bit cryptic at first if you arent familiar with how to read this. So To insert this correctly into the MItDependencyGraph class call you need to do this.

OpenMaya.MItDependencyGraph(OpenMaya.MItDependencyGraph.kDownstream)

So because this enumerator is a child of the class MItDependencyGraph , it must be specified in context of this class hierarchy. (OpenMaya.MItDependencyGraph). You can then set any number of the enum options that the help displays, in this case kDownstream or kUpstream and the class call will know to look for that enum if you set it (you don't have to specify anything and maya will use the default)

Ok. Hope that is a bit clearer than mud. Till next time.

  

Thursday, July 30, 2015

Stretch Node Maya API Plugin Comparisons

As mentioned in a previous post I had some woes querying the matrix data in my plugin. I did some simplified tests and have no implemented these tests into the node. The video below demonstrates a comparison between the matrix plug node and the transform plug node.

Stretch Node Python API Plugin demo from Tim Forbes on Vimeo.

Test stretch node plugin using matrix connections rather than channel connections. This video compares two test plugins briefly. One plugin using Matrix connections, the other using Transform channel connections. This is a test purely to look at different types of data handling and how I can use Mayas API to simplify node graphs for common rigging techniques.

Wednesday, July 29, 2015

Maya API Matrix Research

So after my last post I have delved into Maya to test out some Matrix data queries to determine where my node was going wrong. The test I set up in Maya was simple.
Build a locator. Move it somewhere other than the origin (origin is fine but the data would just read 0.0,0.0,0.0. I wanted something in there as it makes it easier to verify that the data is returning correctly.

I then started writing some API code that would:
#get the active selection
#loop through selected nodes and for each node
     #find the plug for the matrix attribute
     #get that plug as matrix data
     #extract the transformation data
     #print the x,y and z coordinates.

I chose this test as that is exactly what is going on in my stretch node. In the node the .matrix attr is connected into the node, and from that plug I try to retrieve the x,y and z position. However it is returning incorrectly.

So the code in my Maya test scene is working, so the error must be in the creation of the node attribute, or the way in which I extract the data from the data block. Anyways, here is the code I used to the the t.x,t.y and t.z of a selected object from the matrix plug. I hope you find it useful.

import maya.OpenMaya as OpenMaya
dagPathFn = OpenMaya.MDagPath()
#get active selection
mSelList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(mSelList)
selItr = OpenMaya.MItSelectionList(mSelList)
#iterate through selection and get the world space positon from the matrix plug
while not selItr.isDone():
     selItr.getDagPath(dagPathFn)
     nObj = dagPathFn.node()
     #we got the node from the dagPathFn#now we get the dependency node
     objDepNodeFn = OpenMaya.MFnDependencyNode(nObj)
     #find the .matrix plug
     mxPlug = objDepNodeFn.findPlug('matrix')
     print mxPlug.name()
     print objDepNodeFn.name()
     #get plug as MObject which we will attach MFnMatrixData to.
     mxObj = mxPlug.asMObject()
     mxDataFn = OpenMaya.MFnMatrixData(mxObj)
     #query the transformation, returns MTransformationMatrix
     trfnMX = mxDataFn.transformation()
     #get the translate in world space
     v = trfnMX.getTranslation(OpenMaya.MSpace.kWorld)
     #print it out!
     print v.x,v.y,v.z
     selItr.next()

Positon From Matrix

I am currently switching my stretchNode over to work on a matrix input rather than a vector input. I was having issues when querying the dataBlock of the MPxNode to return the matrix data. Pretty much I wasn't getting the correct information. The way this connection was made was the ".worldMatrix" attribute was connected to the '.inMatrix' attribute on my stretchNode. I accesed this with:

startMXDataH = block.inputValue(stretchNodeMX.aStartMX).asMatrix()

Now this was not playing nce with me. As I went further down the track I was not getting the correct information returned.

So here's what I have..I'll delve deeper tomorrow...

def compute(self,plug,block):
#method 1
#get matrix and translate from finding the dependency node and working from there
#returns the correct t.x,t.y and t.z
#-12.0540640814 5.6978884254 7.7806477623

sNode = self.thisMObject()
plugArray = OpenMaya.MPlugArray()
depNodeFn = OpenMaya.MFnDependencyNode(sNode)
startPlug = depNodeFn.findPlug(stretchNodeMX.aStartMX)
startPlug.connectedTo(plugArray,True,False)
stObjMx = OpenMaya.MMatrix()
if plugArray.length()>0:
for i in range(0,plugArray.length()):
stObj = plugArray[i].node()
stDagNodeFn = OpenMaya.MFnDagNode(stObj)
stObjMx = stDagNodeFn.transformationMatrix()
stP = OpenMaya.MTransformationMatrix(stObjMx)
vec = stP.getTranslation(OpenMaya.MSpace.kWorld)
print vec.x,vec.y,vec.z

#method 2
#get the matrix data from the input plug and work from there
#returns the incorrrect t.x,t.y and t.z
#5.26354424712e-315 0.0 0.0078125

startMXDataH = block.inputValue(stretchNodeMX.aStartMX)
startMX = startMXDataH.asMatrix()
#just print the "translate" parts of the matrix - does not return what I'd expect.
print startMX(0,0),startMX(0,1),startMX(0,2)

#method 3
#returns the incorrrect t.x,t.y and t.z
#0.0 5.26354424712e-315 0.0

#get the transformation matrix to query the translation from there. Once again it returns the incorrect imformation
mxData = OpenMaya.MFnMatrixData()
mxData.create(startMX)
stPTransformationMatrix = mxData.transformation()
stPTranslation = stPTransformationMatrix.getTranslation(OpenMaya.MSpace.kWorld)
print stPTranslation.x,stPTranslation.y,stPTranslation.z

block.setClean(plug)

Obviously something's going screwy with my coding here, and my use of the API. But anyways, it's all about digging through it and working out whats wrong...to be continued tomorrow. Something's going wrong with either my creation of the matrix attribute and the kind of data there..but I'm pretty sure thats good. So it must be in the way I am querying the data from the dataBlock...hmmm.

TBC...

Wednesday, November 5, 2014

Chappie

I can finally share the first trailer of chappie. It was amazing working at Image Engine and producing the rNd and rigging for Chappie. I'm so stoked to have been involved in what looks like is going to turn out to be an amazing film. Image Engine is killing it again!

Sunday, December 1, 2013

Shot Management Tool Development

I have got around to continuing some work on my asset management tool. I am breaking it down into modular pieces of code so that I can work on one part at a time. It makes the task a lot easier to manage and makes it seem like a smaller task than it really is. Also it makes it very easy to adapt, as in adding in new functions, removing old functions or really altering the way the code works.
For the moment I am still nailing down the project and folder structure that I want to have for me project scenes. I have something that I like for now that is building nicely. This morning I tightened up this code, reducing my line count by probably a hundred lines, and then implemented custom scene saving with versioning. The next step is to save out an image on scene save so the the management tool will display an image of the scene, and then following that I will enable the UI to read all the versions and display them so you can choose to open which ever version you require.
Slowly but surely this is coming along. I hope it will only be a week or so until I can start using the first rudimentary release to manage my own personal and freelance shots.
Images/Video to come once it is all wrapped up a bit nicer.

Monday, November 25, 2013

Asset Management Tool

I have been starting to prepare for some downtime once I wrap up at Image Engine and return to Australia. I am really hoping that I can sort out a new position, but in the case that I don't I want to be ready for some freelance work. SO I have started developing my own asset management software. I have got some cool ideas about what I want to do, and have been recently cleaning up my pose manages tool, and realised that it wouldn't take "too much" work to convert it to the basis of an asset management tool.
The code is coming along pretty quick, and currently I am at the point of developing my default folders and shot structure, methods to add new shots, add new assets and tie all this into the pose manager too.
Versioning will be the next pass which should be pretty easy. It's been cool as I have had to learn some new python which is always interesting, and I am getting to develop on my rigging pipeline too so that I can develop how my assets tie into this tool correctly.
It's going to be a great tool to have as it should make my asset tracking at home so much cleaner and more manageable, but also it's going to be a great tool to demonstrate my pipeline ideas to potential employers. Screen shots and working videos to come.

Friday, November 8, 2013

Updated Showreel

I have finally got some new footage to add to my showreel. In this latest update my work on RIPD has been added.

Rigging Reel 2013 from Tim Forbes on Vimeo.


For any more info shoot me an email at: timforbesdigital@gmail.com

Tuesday, October 29, 2013

Face Rigging part 1

As promised here is my first video showing the progress of my facial rigging project. Fully joint based facial rigging in Maya.

Joint Based Muscle Face Rig from Tim Forbes on Vimeo.

Monday, October 28, 2013

Face Rigging

So I have been working on setting up a joint based muscle face rig system. It is coming along nicely, and I showed it to a work mate yesterday and he was blown away and said I've gotta post the work. You can see a little bit of it in my reel here: Showreel, but I will record a detailed screen grab of the rig working and post it up to show off the deformation and skin sliding that I have set up. I have set up a very cool sticky lip system as well as some nice soft eyes and muscles that slide over the surface of the underlying skeleton to preserve volume and create some nice skin sliding effects.
Finally I am doing a dynamics pass to get some jiggle in the looser neck skin, and I think I will do a final hi-res render mesh that I may sculpt some wrinkles on to be driven by the muscles so I end up with a nice overall package. The final result will hopefully be a rendered greyscale pass with some nice lighting to show off the deformation.
I'm going to try for an initial post of the rig in progress in few days by the time I record and upload it.

Friday, August 23, 2013

Elysium On FXGuide

This is a cool little documentary on FxGuide about Image Engines role in Elysium. Definitely worth a watch and it shows some cool breakdowns on the shuttles and droids that I rigged. Enjoy :-)

Saturday, August 17, 2013

More Elysium

So I am still super stoked on Elysium. FX Guide dd an interesting article on the movie and posted some great little images that I have put here. Check out the article here: FX Giude on Elysium. I rigged the droids and vehicles you see in the images below. The amazing realism is thanks to Image Engine and all their amazing artists.

Monday, August 12, 2013

Elysium Credits

So I went to see Elysium on Sunday night with Kate and some friends. I managed to get a piccy of my name up on the big screen. Stoked! There is also a great article on the work that Image Engine did on Elysium here: FX Guide On Elysium

Friday, August 9, 2013

Elysium Finally Released

So Last night I finally got to see Elysium. We got to go to a preview screening put on by Sony. Open candy bar.... Anyways, the movie was amazing, Neill Blomkamp was there ti say a few words before the film rolled. We were all so stoked with how the movie looked. Image Engine killed it and I am so proud to have worked on such an amazing film.
Elysium Premiere

Friday, August 2, 2013

Elysium

I'm so stoked with the release of Elysium, I had to get a tacky photo taken with the banner. Image Engine completed so many bad ass shots on this show, and I was fortunate enough to get to rig most of the assets. I am super proud of all the work we completed and how good it looks!

elysium_photo

And the new trailer :-)

Monday, November 12, 2012

Updated showreel

The same as the last one, just updated with my work from Battleship and The Thing.I also added a new personal piece in there, some facial rigging. Still a work in progress whenever I have a spare moment, but it has some cool joint based facial muscle deformation.

Rigging Reel End 2012 from Tim Forbes on Vimeo.

Tuesday, October 16, 2012

Cinefex

Thanks to Image Engine for the two page spread.