Python Plugin – Star Shape Node

Python Plugin – Star Shape Node

On a plane trip last weekend, I passed the time refreshing myself on python plugins for Maya. I wrote a plugin that generates “star shape” polygon meshes, with some input attributes to control the shape and mesh density.

For folks who know how to write plugins in the C++ API, the python API for Maya is a fairly straightforward conversion. For Python users, it’s tricky since it forces you to think of things in a C++ sort of way.

It took me about a day, counting some time after my flight when I got back. The hardest part was getting the faces wired up to the vertex positions correctly, and getting the UVs assigned.

This is a quick way to create some quad meshes centered around a split of various sizes. You can control how “pointy” the star is, by controlling how far out the “antipoint” concave points extend.

The points are UV mapped, so that each grid that makes up one of the points spans from UV 0-1. You can map a texture to each point grid that way. One idea for expansion of this plugin is to add a choice to UV map each face. UV mapping the entire shape is easy enough to do through the createUVs menu with a planar map that I don’t think there’s a need to add it to this plugin.

Control for the mesh rests in four easy attributes:

Radius: Distance from the center to the tip of one of the points
Radius Ratio: Ratio between the distance to the antipoints and the distance to the point.
C Sections: Number of Sections around the Circumference.
R Sections: Number of Sections Radially away from the origin.

So, here’s the file.

Unzip it into your maya/scripts/ directory, and run this example script (that is also included in the file).
import maya.cmds as cmds
import starShapeNode

Leave a reply