Posts

Finding the Centre Position of a Polygon Face: Maya Python API

In the past few days I found myself having to find the position of face centres of a polygon. Looking through the Maya documentations I find no MEL or Python commands that can do this. So I had to do a Google search the answer. The most useful solution I found was from a discussion in Google Groups, in a reply by Justin Israel (who works in Weta Digital according to his Google+ profile ): https://groups.google.com/d/msg/python_inside_maya/UoMVxr0deVo/OJ2K8IpevxQJ Here is an excerpt of Justin's answer: import pymel.core as pm import maya.OpenMaya as OpenMaya face = pm.MeshFace("pCube1.f[64]") pt = face.__apimfn__().center( OpenMaya.MSpace.kWorld) centerPoint = pm.datatypes.Point(pt) Here is another interesting article discussing how we can go about finding the centre position of a face:  http://mayastation.typepad.com/maya-station/2009/11/where-is-the-center-of-a-polygon.html

Maya Expressions 03 - Changing Colours

Image
In this next installment of my tutorial series on Maya expressions, We put our conditional statements to practical use by showing how we can use expressions to get the translate Y of one object to drive the colour attributes of another object. I also show some code checking techniques by using the print command to expose useful information to the script editor, showing what is going on in our expressions during execution time, so we can ensure that flow of the execution is as we intend it to be. I hope that it also shows that all attributes use numerical values in one for or another before they are evaluated to result in colours, vectors or on/off states.

The Zen of Python: Import This

I have been coding quite a bit in Python these few months. In the midst of research and reading up, I revisited the Zen of Python . This is a set of 20 software principles that influenced the development of the language. Having read this a few years back (it was first written around 1999), now I am seeing some of the principles in a new light. I'm still learning and finding my way around so I decided to learn more about what these principles mean to different people. Here's a great presentation I found on Slideshare.net  when I dug deeper into how different people explain each of these 20 principles in their own ways. An Introduction to the Zen of Python from doughellmann Incidentally I just found out that the Zen of Python is coded into the language itself. You can get Python to display this by entering this line of code: import this It will return the following result, right inside your interpreter: The Zen of Python, by Tim Peters Beautiful is bette...

Modelling and Setting Up Rail / Roller Coaster Tracks

Image
Upon the request of  a former colleague and good friend, I decided to post a video showing exactly how to set up a roller coaster track in Maya. In this video I show how I go about modelling roller coaster tracks. In the video I go through the technical steps as well as the thought processes I go through my head as I tackle the task. This video is a bit long but I believe I cover quite a bit of ground on how to handle curves, extrusion, motion path, constraints and the animation snapshot tool. I hope you find something useful from the video

Maya Expressions Part 02 - Conditional Statements

Image
In this second video of my Maya Expressions series, I show how use the graph editor to display a visual representation of the value of our expressions with a graph. Then I move on to explain the basics of conditional statements in Maya's expression language, which also works with MEL scripts. A basic conditional statement in MEL and Maya expression language has the structure as such: if (condition) {     statement1;     statement2; } Condition is a test to see if a comparison between values is true, or false, for most cases. Example 1: if (cube1.translateX > cube2.translateX) { do_something; } In the above example, if cube1's translateX value is greater than cube2's translateX value, then do_something will be performed. Example 2: if (cube1.translateX == cube2.translateX) { do_something; } In the above, we are testing for equality. if both the values are equal, the do_something will be executed. Example 3: if (cube1.scaleX >= cube2.scal...

Maya Modelling Tools and Workflow Video

Image
In this latest video tutorial, I show a set of 2 very handy Maya tools, and the workflow context in which I often use them. First I start off creating a complex shape that has edges running in various directions. This is achieved by using a combination of several deformers. Even though deformers are categorised as animation tools, I try to show here that they can be used in a modelling situation as well. This gives a hint at huge possibilities for even more complex objects to be constructed this way. The key is to understand what different deformers do on their own, before we can plan how to use them in combination. Having an object that is bent by deformers gives it a very organic shape. The majority of the resulting faces are neither oriented along world axes nor object local axes. This is one of the situations where these tools will shine. The one of the essential tools of my modelling workflow is the Slide Edge Tool. This allows the artist to position one or multiple selecte...

Introduction to Expressions in Maya

Image
I've just posted a video introduction to what expressions are and how to achieve a few basic movements with expressions. In this very basic introduction to expressions in Maya, I talk about how with expressions, we can drive attributes of objects with the current frame, the current time, or with another attribute that is animated. First I talk about what expressions are, where in the Maya interface we can input expressions, how to create them, and update them. Then I show the simplest form of expression, where we learn to feed an attribute with a constant value. Following that I make use of the frame  variable to read the value of the current frame in the timeline to drive our object's attribute. Then I get a bit more complex, showing how to use subtraction, division and multiplication to offset,, amplify or reduce the the resulting value to a fraction of what it would otherwise be. I also briefly show how to use the connection editor to connect 2 attributes, so tha...