Planet Tech Art
Last update: December 21, 2013 03:00 AM
December 20, 2013

#### How To Make Birds Fly Good

It’s hands down the best resource about bird flight I’ve seen. Great info for animators and riggers with plenty of example pictures and videos.

#### Elephant Ride

I had the pleasure to work with the great guys at Irie studios on the Elephant Ride video. I was hired to create a rig for the elephants. As requested I used Maya Muscle for additional deformations and muscle simulation. I will record a video that showcases the rig and post it in a few days.
The video premiered on Myspace yesterday.

Video Premiere: D. Prosper, “Elephant Ride” from BRAINFEEDER on Myspace.

Here's a little rig sneak peak:

December 19, 2013

#### Physical Technical Art

Over the next couple of months I'm going to be blogging mainly on the topic of what I like to call Physical Technical Art, the tangible side of games development. So… what does that mean you say? Game Development in most parts is a software exercise; once concept art and motion capture has been digitized [...]

#### Shader Toy – GLSL ES Online Editor, Compiler & Previewer

Digging around the web the other day looking for GLSL ES info and I came across this site, it's a nifty online editor, compiler and previewer. It comes with some examples of 2D, 3D and Plane Deformer shaders and it can take input from Time, Mouse(LMB with current pixel and clicked pixel), Viewport Resolution and [...]

#### Shift dragging files into Maya 2012

Shift dragging files into Maya 2012 can be a risky business; it turns out that it will delete your file. So if you are after new ways of off-loading some of those pesky files that clutter your hard-drive simply shift drag them into Maya and all your dreams will come true. This works for even [...]

#### Modifying project files in Visual Studio during pre-build

So it turns out that Visual Studio uses the application's cache if a file is open at build time instead of loading the file off disk...ok so this is good, when you want to save memory and speed up the build process. BUT when you are editing a source file that is [...]

#### Perforce: Force update missing workspace files

Q: So I've accidentally deleted some random local files and I have no idea which ones. How do I get the files back when Perforce thinks they are still in my local workspace? I don't want to force update all the files, that would take way too long. A: Force update will do the trick, but it [...]

#### Qt Overdraw

When I was working on my last tutorial I came across an interesting issue with the Qt UI. I went through all the elements using windows modifier and notices a number of elements that appear to be dupes. Maya Perspective window after I started to shift some elements out For starters we have a duplicated [...]

#### Integrating .Net & Maya 2012 UI – Pt 1

This article is specific to Maya 2012, I have also created an alternate tutorial for Maya 2009 (32bit) Developers In this multi-part tutorial we’ll be covering two main areas, embedding .Net forms within Maya and extracting Maya UI components and embedding them within your .Net dialogs. To get this to work we will be exploiting [...]

#### Integrating .Net & Maya 2009 UI – Pt 1

This article is specific to Maya 2009, I have also created an updated tutorial for Maya 2012 (64bit) Developers In this multi-part tutorial we’ll be covering two main areas, embedding .Net forms within Maya and extracting Maya UI components and embedding them within your .Net dialogs. To get this to work we will be exploiting [...]

#### Reel 2010

This is a compilation of some of the Maya tools I have created and was able to show. 3dsMax reel still to come. If you want more details, check out the videos section. www.youtube.com/watch?v=tE15ntpdlCc

If you have been waiting for the alpha/beta to start on Joystick Lite keep an eye out here or on one of the social media. Development of the tool is underway again and will be heading into late alpha as soon as I can get a forum up and running.

I will be looking for a select group of testers that will be able to push it through its paces and make sure that it is production ready. If you are interested in joining in drop me an email at Email: info@penproductions.ca letting me know what sort of work you do and how you would like to be using it.

#### Master Classes

PEN Productions and Paul Neale now offer Master Classes that will cover many topics including Max Script, Character Rigging and Mudbox. Many more will be added in the coming months.

Master Classes..

MX Driver has a new low price of just $199 CAN. MX Driver has been designed as an animators tool for working with Car, Truck and Trailer animations. It is not a vehicle simulator that calculates its own trajectory and rollover. It has automation built in that will aid in the creation of realistic and even cartoony vehicle animations. Read more about it.. MX Driver 2 #### PEN Licensing System is ready for 2012. The PEN Licensing System is a generic tool that can be used by any Max Script tool that needs to be protected. The system is easy to implement and simple for clients to use. A key generator is included that allows for tracking of generated licenses and license keys. PEN Licensing system was developed to address the need for a quick, easy and secure way to license Max Script tools. Without a licensing system it is very easy for wares sites to provide free versions of the tools that you have worked hard to create. With this system any vendor can provide encrypted and secure licensing for scripted tools of all kinds. #### Red9 Language packs?? This is great, Red9 in Chinese!! Big thanks to Jerry (sorry I don't know your second name) from the python google groups who sent me this last night. Seems like he's converted all of the Red9 UI's into chinese for his company to use. Now that kind of begs the question, is multi-language support something others would be interested in? It's easy enough to modify the text in all the UI's to be pointers to a language pack similar to how Maya does it internally, question is, would there be enough call for this? If you'd be interested let me know cheers and a happy Christmas Oh StudioPack v1.41 will be out over the weekend ;) Mark #### Protected: Winter workshop masterclass portal There is no excerpt because this is a protected post. The post Protected: Winter workshop masterclass portal appeared first on Rigging Dojo. #### Blendshape FaceRig » MotionBuilder #FaceRigging with #blendshapes from #photogrammetry head scans…in #MotionBuilder Just don’t open the relation constraints…very dark things living in there. photogrammetry » Maya3D » MotionBuilder December 18, 2013 #### Onward and Upward Well Hobbit is out, it seems to have been received with a mixture of excitement and disappointment, I wont mention which camp I fall into, suffice to say that I think Smaug turned out pretty well. Let me know what you thought. This was my first film with an Animation TD credit, as I ended up doing much more technical and development work than actual animation. Anyway, here’s a trailer for the next crop of Weta work to look forward to! #### Limited: Winter break workshop 99$ rigging and animating with motion capture

UPDATE: Registration is closed, thank you. Rigging Dojo Winter break workshop for Rigging and Animating with Motion capture. Only 99$Attention animation students (and others) on winter break! We are offering … The post Limited: Winter break workshop 99$ rigging and animating with motion capture appeared first on Rigging Dojo.

#### QuickLauncher v0.1.3

Hi guys,

Just wanted to let you know that QuickLauncher has been updated adding support for script packages, I uploaded my own scripts to github in case anyone needs some samples to get started.

There is also a quick demo on vimeo... I know, my english is not very good, but I'm doing my best :)

Cheers!

December 17, 2013

#### MGODI – Jobs look for you

MGODI

I’m very proud to say that we’ve just wrapped up the first version of a new app called MGODI we’ve been working on along with Joep (for those who don’t know him, he’s the mastermind behind End User Event).

What is MGODI do you ask? Well, it’s everything I wanted, especially when I was out there looking for a job!
MGODI is an app that connects companies and people, also people and people!

As a user you can create your profile and specify which are your skills and your expertise, and then, every time someone posts a job that match your skills and expertise…. guess what? You get notified! We want to have jobs looking for you. You can filter jobs by skills, expertise and country, of course, if you prefer, you can disable this filters and get ALL the job postings, which is great too

After you’ve been matched to a job, the process is really easy, you apply, on the other side, people are able to see your profile, your portfolio and send you an email. That’s it, that simple. After this, both parties do their own thing, we are just there to help out on the first step.

Of course, now you say “yeah right, how much is that gonna cost me?” and  I say: Nada, nicles, niet, zip, nothin!

It’s free for all users to register, have their profile and portfolio. For posting a job, there’s a small amount of 2.99$. All of this is available for iOS 6.0+ as a universal app for your iPhone/iPad. Well, that’s pretty much it and it’s been a hell of a ride, BUT we’re not finished, we are now working on the Android which will come with some new features (that will also be made available for the iOS version), expect it in the first quarter of 2014, meanwhile be sure to check our website and download the app! You can find out more here: www.mgodi.com #### Removing external hiring as a tool (Part 3 of 3) In this post I hope to explain how hiring externally as a tool for fixing problems ultimately leads to a weaker organization. When I began writing this post, I was having a hard time. Whereas the post talking about what a bad idea firing is was easy, the situation is considerably better for hiring. For starters, there are more organizations that do a good job. Very rigorous hiring practices, even during growth. It’s also easier to talk about how a company hires people than how it fires people, as its generally a positive experience (which is why this article probably seems a lot weaker than the previous). Of course sometimes you need to hire specialists for very specific areas (I’m talking something like ‘hardware emulation’ or ‘low-level rendering engines’, not ‘databases’ or ‘UI programming’), where it is prohibitive to train or grow people in a year. And sometimes there are amazing individuals you just need to have (take Ward Cunningham being hired into New Relic or John Carmack becoming CTO of Occulus as examples). Then there are organizations in periods of rapid growth. While rapid growth is always risky, it’s often necessary to bring enough force to bear in innovative companies. I’d much rather see stable growth but it’s not always an option. So I needed a clear demonstration of the problems. Then, like manna from an ironic heaven, I saw this article about Abercrombie’s CEO. After investor calls for his resignation, Abercrombie renewed his contract and stated their plan to hire in three executives to manage each of their brands. The idea is that one of them will replace the current CEO, and the CEO has done a bad job managing things, and of course did not groom internal candidates, so it seems they are due to come from the outside. I don’t understand how anyone expects this to end well. Each Brand President will come in, make changes (including, probably, layoffs!) that benefit the short term (because their goal is to be CEO), and then: 1) The one that becomes CEO will stay a few years. The average tenure of a CEO in America is about 4.5 years. 2) The two that do not will likely leave, meaning new executives will be hired in and there will be more instability. This is the sort of hiring- not just at the CEO level but all leadership levels down to team lead- that I think can be misguided. Why? Mostly, because it disguises a problem. Most organizations buy into the idea that internal candidates should be preferred to external ones (another Lean principle!), yet still need to look outside for senior talent and managers. I would compare the situation and solution to DevOps: if deployments are an issue, the worst thing to do is isolate their handling to a small group and deploy less frequently. The DevOps movement has shown us the power of the mantra of “if it hurts, do it more often.” I believe the inability of an organization to groom internal candidates indicates severe management problems, and because the feedback cycle is so slow for personnel changes, trying to defer it and “fix it for the next time” will never actually fix the issues. Internal hiring will force an organization to confront its issues, which can include: • Stifling managers that do not or cannot groom their reports for seniority and leadership. • A dysfunctional project that people do not want to work on and would be under-staffed if people were allowed to transfer. • Projects that depend on a couple of people, making them unable to transfer. • A general lack of learning and growth, perhaps because everyone is 100% allocated, with no slack time. • Work that is not challenging or evolving, causing the same experience over and over. • Valuing efficiency and specialties of individuals over utility and value. All of these issues (and more) cause issues with internal hiring, but also are bad for the organization overall. Wouldn’t it be great if you could both fill a key role and address issues? Is the risk too great of promoting a bad candidate? I don’t know: is the risk too great of hiring in an unknown quantity into a leadership position? Is the risk too great of having a candidate who wants a job change but your organization can’t give it to him or her? If you are looking to do anything but shrink, you should always have ‘junior’ positions open and take the cream of the crop. This is especially true if you are outside a major tech hub. There’s also another type of problematic hiring: adding resources to failing projects (whether outside or inside hires). We all know Brookes’ Law, that “adding people to a late project makes it later” but I can’t count how many times people do it anyway. If there are problems with a project, adding people is the worst way to address issues. “We need more resources” is a tantalizingly simple explanation for why something isn’t getting done, but I’ve never seen it be the actual reason. It is, like hiring leadership, a great way to disguise and distract from the real problems. This topic requires a separate post, though. I also want to point out a perversion of ‘internal hiring’: creating an excess of managers and handing out seniority titles as candy. What I’m advocating here is when you need a manager, look internally, not to turn someone into a manager because they want it. Likewise, I’m not saying you should give someone a more senior title because otherwise you’d open up a senior developer spot, I’m suggesting you give them the responsibilities (say, team leadership) and see how they handle it. It is much easier to hide the lack of internal hiring in technology companies because it is growing so quickly (there’s a need for external hires, and people can get jobs elsewhere if they become frustrated). But ultimately I see a dependence on external hires on the other side of the ‘firing as a tool’ coin. I don’t think you can do one without the other. They are inseparable from not just a cultural level but a practical one as well. It is about investing in your employees over looking for easy answers. #### MotionBuilder 2012: Mirror Animation In this tutorial I’m going to show you how to mirror animation using MotionBuilder 2012. First, select the take you want to mirror, then create a new take and click Yes when the message box pops up that says, “Copy the data from the current take to the new take.” Double click the character node in the Navigator and under the Character Settings tab check Mirror Animation and change CharacterSolverSelector to MB Character Solver. Now Bake(plot) To Skeleton then Bake(plot) To Rig. (If you use Plot All (All Properties) under Key Controls instead of Bake(plot) To Skeleton then make sure the character’s Control Rig is unchecked.) After doing the above steps my character rotates in the Y axis by 180. If something like that happens to you then do the following to turn him/her/it back around: Select the Reference control, delete its key frames, uncheck Mirror Animation, and set its rotateY to 180. (If you need the key frames on the Reference control then you’ll need to rotate the Y axis by 180 on the key frames instead.) At this point you could leave the Reference control with a value of 180 for its rotateY, but if you want to zero out its rotations then Bake(plot) To Skeleton and set its rotate X, Y, and Z back to zero. Then do Bake(plot) To Rig one more time and you’ll have a character with mirrored animation and the Reference control will have zeroed out rotations. So those are the manual steps if you want to mirror an animation, but I created a script that will automatically do all those steps for you. You can download it here: December 15, 2013 #### Tone mapping When working with HDR values, two troublesome situations often arise. The first happens when one tries to encode an HDR color using an encoding that has a limited range, for instance RGBM. Values outside the range still need to be handled gracefully, ie not clipped. The second happens when an HDR signal is under sampled. One very bright sample can completely dominate the result. In path tracing these are commonly called fireflies. In both cases the obvious solution is to reduce the range. This sounds exactly like tonemapping so break out those tone mapping operators, right? Well yes and no. Common tone mapping operators work on color channels individually. This has the downside of desaturating the colors which can look really bad if later operations attenuate the values, for instance reflections, glare, or DOF. Instead I use a function that modifies only the luminance of the color. The simplest of which is this: $$T(color) = \frac{color}{ 1 + \frac{luma}{range} }$$ Where$T$is the tone mapping function,$color$is the color to be tone mapped,$luma$is the luminance of$color$, and$range$is the range that I wish to tone map into. If the encoding must fit RGB individually in range then$luma$is the max RGB component. Inverting this operation is just as easy. $$T_{inverse}(color) = \frac{color}{ 1 - \frac{luma}{range} }$$ This operation, when used to reduce fireflies, can also be thought of as a weighting function for each sample: $$weight = \frac{1}{ 1 + luma }$$ For a weighted average, sum all samples and divide by the summed weights. The result will be the same as if the samples were tone mapped using$T$with$range$of 1, averaged, then inverse tone mapped using$T_{inverse}$. If a more expensive function is acceptable then keeping more of the color range linear is best. To do this use the functions below where 0 to$a$is linear and$a$to$b$is tone mapped. $$T(color) = \left\{ \begin{array}{l l} color & \quad \text{if luma \leq a}\\ \frac{color}{luma} \left( \frac{ a^2 - b*luma }{ 2a - b - luma } \right) & \quad \text{if luma \gt a} \end{array} \right.$$ $$T_{inverse}(color) = \left\{ \begin{array}{l l} color & \quad \text{if luma \leq a}\\ \frac{color}{luma} \left( \frac{ a^2 - ( 2a - b )luma }{ b - luma } \right) & \quad \text{if luma \gt a} \end{array} \right.$$ These are same as the first two functions if$a=0$and$b=range\$.

I have used these methods for lightmap encoding, environment map encoding, fixed point bloom, screen space reflections, path tracing, and more.

December 13, 2013

#### “Delighting customers” is Lean’s secret handshake

Whenever I see the words “delighting customers” (which is, let’s face it, an awkward phrase) in a non-Lean context like a job description, I can feel the author winking at me. It tells me “we try to be Lean and if you get our drift you probably want to join us.” It instantly gives said company plenty of extra points.

I just wonder how long until “delighting customers” becomes a played out catchphrase (if it’s not already)?

December 12, 2013

#### Red9 StudioPack - Time and Key Management

Hi all, thought I'd do a new demo to go through some of the new time management tools in the latest build v1.41 which I'll push out sometime over Christmas. Hopefully this all makes sense although there's so much more that I could expose here, just a case of not going to  mad with complex UIs and too many checkboxes.

Anyway, as always all feedback is very welcome

cheers

Mark

December 11, 2013

#### The Division: Snowdrop Showcase

Check out some of our tech! I hope we are able to share some under the hood tech at some point, it really is one of the best engines I ever worked with.

#### John Carmack Lighting and Rendering

Check out Principles of Lighting and Rendering with John Carmack from QuakeCon 2013. It’s an introductory lecture on how we simulate the physics of light and shadow in real-time computer graphic rendering.

If you want more Carmack, there’s also a keynote from the same QuakeCon that’s almost 3 hours long where he talks about a wide range of topics.

#### PyCharm. PyDev for snobs.

I was fortunate enough to stumble into a free trial of PyCharm right at the glorious 3.0 release. There was a flurry of rants and raves running through the Tech Art community upon this release and for good reason. With 3.0, JetBrains released an Open Source “Community” version which is fully featured. After using for a couple of days, I was hooked and splurged for a commercial license through my company, though I was prepared to scrape up all the spare change in the house to afford the Personal version and use it for the rest of my life.

# Features, Shmeatures

Pycharm has all the usual features you’ve come to expect from any decent IDE: highlighting, completion, etc. The hotkey/popup features are quite awesome. CTRL+SHIFT+R (Navigate -> File) is the fastest way to open files in your project. The CTRL+SHIFT+A (Help -> Find Action) is your shortcut to all other shortcuts and popups.

## Interpreter Setup

If you spend a lot of time pointing to your mayapy.exe and adding and removing paths from your workspace, you’ll appreciate how much more intuitive these dialogs are than PyDev’s.

## Perforce

The Perforce integration is almost too good. It tries manage the ‘Current’ or ‘Active’ changelist and will automatically add any file you start to modify to this changelist. It is a little annoying the way it tries to organize every file you have open amongst the changelists but once you get used to it, it starts to have its benefits. PyCharm also keeps a list of recently used changelists which is quite handy, actually.

## Look

‘Darcula’ is a beautiful color scheme which comes default. And when I say ‘color’ I pretty much mean the absence of it. Greys are where it’s at when it comes to staring at code all day. There’s the token oranges when needed as well, but you can customize all UI colors, per usual.

## Auto-Save

Oh, the auto-save will make you lazy (and fast) as hell, too.

# Code Inspection

PyCharm’s code inspection is the most thorough I have ever seen. It is so thorough that I turn off the strict adherence to PEP 8 standards as our company deviates from these slightly. I’m one of those “0 in box types” even in my IDE in that I always fix all code inspections. This has the added benefit whenever you open any file, you can immediately see if there are simple syntax errors by the code inspection color highlighting in the margins. In the process of examining all the inspection notes, there are fairly detailed explanations of what the issues are and it offers to automatically fix them whenever possible. It has actually been my secret teacher and made me a much better programmer.

## Code Style

Each language has its own style settings and the settings for Python are quite complete: indentation, spaces, wrapping, blank lines, etc. Every option is available. Then you just auto-format before you save and viola! You’re code looks perfect.

# Still need Wing

PyCharm fits nicely into my arsenal of coding tools right next to Wing IDE. PyCharm’s debugging uses the Pydev module which doesn’t compare to Wing Pro’s built-in features. Wing is still the king for real-time debugging of Maya and MotionBuilder or other external python applications, especially with the Debug Probe feature. But I’ve always used two IDEs in my day to day routine: Wing for debugging and Eclipse w/ Pydev for my main coding environment. PyCharm replaces PyDev as my main coding platform now.

# Intangibles

The best part of PyCharm is it’s feel. It feels awesome, fast, tight, professional, snappy, very little crashing. Wing always feels a little slow and lagging. Eclipse/PyDev feels tighter than Wing but still doesn’t compare to PyCharm.

## Versions

Download is available for Win, OSX, Linux and the Community version is now free and does pretty much everything you need. Then when you get hooked, go ahead and save up for a license (they deserve the 10th of a bitcoin).

All of this just scratches the surface really. I’m sure you’ll find several little goodies that make your day to day workflow a whole lot easier (list them here in the comments if you have the time!)

Do yourself a favor. Go out and install right now. You’ll never regret it. Enjoy!!

###### Thanks to http://mayapy.wordpress.com/ for the cool icon.

December 10, 2013

#### Eye Reference

Been looking up some eye reference today. Head over to photographer Suren Manvelyan’s website and he has some great up close shots of human and animals eyes.

Here’s some good video ref I found on YouTube:

December 09, 2013

#### Texture Monkey... version"some big number"

We are now getting Perforce. Oh how I  missed thee Perforce! And what a fantastic opportunity to revisit my favorite pet project, Texture Monkey! Be be honest, I'm kinda sick of re-writing this tool, but I've got it to a point where it meets a couple of extra prerequisites that it was sucking at before, mainly:

• It's written at a point where I actually feel I can competently write functional and readable code.
• It's UI uses the QT framework. Which it MUCH nicer to work with than the previous WX.
• It's been built around the premise that it  should easily be portable across projects without having to change any of the source code- provided afew assumptions about project structure are met.
• It does more than texture exporting, and now supports Perforce integration as well.
• Most importantly, it is written in a modular fashion, and can be expanded upon or cut back without too much trouble.
 Now with extra stuff!
Behind the scenes:
• It stores and loads tool settings as metadata in each PSD file, so you don't have to select those settings again when opening the file later. In addition to that, if you change the settings, then export the file, these new settings are saved to the PSD for later use.
• It supports exporting multiple LOD textures for different asset bundles. This is an experimental feature, and may be cut. But its fun to play around with. The idea behind this is that Unity doesn't make a distinction between different IOS devices, and instead lumps them all into one category in it's asset settings, even though there is a significant difference in specs between devices.
• It brings Perforce into the tool chain. When it checks out whatever active document is in Photoshop, it also brings along with it all the associated exported texture maps, basing it's search on the export locations stored in the Metadata and the source file name.
• I'm still thinking about adding a check in function... I kind of want to get people to check in via the P4 client, just so they have an overview of exactly what they are checking in before they actually commit it (especially if things like models are dependent on the texture changes, but fall out of the purview of this tool) For now, I have just added a function that brings the P4 client to the foreground.
• I have tried to add a little flexibility for other artists to be able to use this tool. It's mainly aimed at people working on textures for models, but by adding custom destinations and formats hopefully it will be of some use to export to custom locations in different formats.
• The configuration is all stored as an .ini file, and contains all the file naming rules, default destination folders and stuff like that. It can be hand edited, but I don't think I'm going to bother with a custom UI at this point.
• The Style is one billion times better, mainly due to LoneWolf's dark orange stylesheet he has provided on tech-artists.org

It might not be the absolute best solution, but I have been able to put into practice my idea of storing the tool settings in the PSD metadata, and it actually works pretty well.

The current setup works like this:

• On export, go through a dictionary of controls inside the GUI and check the settings.
• Store each object name and it's setting as a text block with easily splittable characters. For this I chose to use ~ and | as neither of these are used for windows file or directory names.
• Write this text block to the PSD metadata.
• Meanwhile, in the export, use the GUI's current settings to determine output locations, formats and files to include.
• A background thread is constantly listening for any changes in the current active Photoshop document.
• If the name of the document changes, it automatically kicks off a function that reads the metadata out of the active PSD and splits it into objectName, setting value pairs.
• If no data is found, it kicks off a process to apply default settings.
• This data is passed to another function that finds these QT objects, and applies the relevant setting recast as the applicable object type- eg bool, int, string.
• These settings are only saved when the document is exported. I'm expecting a little grief from the artists about this if they switch documents before exporting them at least once, so I might try to fix it.
With the listener process working on a pretty short timer and a very simple function, it's possible to get what feels like real time feedback in the tool without experiencing any lag or hangs. This is the first time I've made a tool where it's a two way street- usually it's just my tool telling Photoshop what to do. It's actually pretty satisfying to click between documents in Photoshop and watch all the checkboxes of Texture Monkey light up and change.

 Main settings to be saved are the different maps and resolutions associated with the various LODs, although settings for format and destination folders are saved as well.

#### Shaun Friedberg Webinar

Weta’s Senior TD Shaun Friedberg did a live webinar posted by CGSociety. He gives advice and tells his story of how he got to where he’s at. It’s audio only so you can listen to it while you work.

December 08, 2013

#### Trunk Rig Demo

Came across this demo of an impressive trunk rig developed by Jeff Brodsky for the film The Legend Of Tembo.

Here’s a video where he takes you through how the rig works:

December 07, 2013

#### Random MotionBuilder Python Tidbits

This is how you do a bunch of random things in MotionBuilder with Python.

# set the current frame to the start frame of the current take
takeStartFrame = FBSystem().CurrentTake.LocalTimeSpan.GetStart().GetFrame(True)
time = FBTime(0, 0, 0, takeStartFrame)
FBPlayerControl().Goto(time)

# create a copy of the current take
newTake = FBSystem().CurrentTake.CopyTake('newTakeName')

# evaluate the scene
FBSystem().Scene.Evaluate()

################################################
# delete the camera that comes from Maya
mayaCamera = FBFindModelByName('MayaCamera')

if mayaCamera:
mayaCamera.FBDelete()

################################################
# find out which character is currently selected
character = FBApplication().CurrentCharacter

# turn on Mirror Animation
character.MirrorMode = True

# set the solver to 'MB Character Solver'
character.SetExternalSolverWithIndex(1)

# turn off the Control Rig
character.Active = False

################################################
# rotate the Reference control by 180
controlRefName = FBFindModelByName('Reference')
controlRefName.Rotation = FBVector3d(0.0, 180.0, 0.0)

################################################
# create a locator and set it to 0, 0, 0
worldScaleNull = FBModelNull('WorldScale')
worldScaleNull.Translation = FBVector3d(0, 0, 0)
# set the Look attribute to None
look = worldScaleNull.PropertyList.Find('Look')
look.Data = 0
worldScaleNull.Show = True

# parent a joint named 'C_global_bnd' to the locator and scale it
globalBnd = FBFindModelByName('C_global_bnd')

if globalBnd and globalBnd.Parent != 'None':
globalBnd.Parent = worldScaleNull
worldScaleNull.Scaling = FBVector3d(100, 100, 100)

################################################
# create a custom attribute on selected models
from pyfbsdk import *

attrName = 'My Custom Attr'

selectedModels = FBModelList()
FBGetSelectedModels(selectedModels)

if not selectedModels:
FBMessageBox("Error", "Nothing selected", "OK", None, None)

for model in selectedModels:
anAttribute = model.PropertyList.Find(attrName)

if not anAttribute:
trackerAttr = model.PropertyCreate(attrName, FBPropertyType.kFBPT_charptr, "String", False, True, None)
trackerAttr.Data = 'hello'

################################################
# plot animation example
def plot(self, character, plotWhere):

if plotWhere == 'skeleton':
plotWhere = FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton
elif plotWhere == 'rig':
plotWhere = FBCharacterPlotWhere.kFBCharacterPlotOnControlRig
else:
print "Warning: Plotting to skeleton by default."
plotWhere = FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton

plotOptions = FBPlotOptions()
plotOptions.PlotAllTakes = False
plotOptions.PlotOnFrame = True
plotOptions.PlotPeriod = FBTime(0, 0, 0, 1)
plotOptions.RotationFilterToApply = FBRotationFilter.kFBRotationFilterGimbleKiller
plotOptions.UseConstantKeyReducer = True
plotOptions.ConstantKeyReducerKeepOneKey = True
plotOptions.PlotTranslationOnRootOnly = True
character.PlotAnimation(plotWhere, plotOptions)
return True

December 06, 2013

#### All languages need first class tuples

I was doing some work on a Flask app today and built up some chart data in Python that had a list of two-item tuples like [(<iso datetime string>, <value>), ...]. I needed to iterate over this same structure in JavaScript and of course was reminded how great it is that I can unpack these things easily in Python ala “for datestr, value in chartdata” because I was missing it so much in JavaScript. But rather than keep these as tuples and have to play around with non-idiomatic JS, I just made my tuple into a dictionary, so my chart data became a list of dicts instead of a list of tuples.

I really dislike having to use objects (or names, more precisely) for these micro data structures. Over time I’ve moved more and more away from creating classes for data structures in Python, a ‘best practice’ habit I brought over from C#. It is silly in a dynamically typed language. There’s nothing more clear about:

for entry in chartdata:
chart.add(entry.x, entry.y)

Than:

for x, y in chartdata:
chart.add(x, y)

In fact it’s probably less clear, because there is the totally unhelpful variable name “entry.”

At some point- maybe even three items?- it becomes more clear and self-documenting to use names (that is, dicts instead of tuples), but for the very common cases of simple collections used by nearby code, tuples and automatic unpacking can’t be beat!