Sample Projects

Python: Distribute Objects on Surface Using Texture

This code applies an object or objects to the surface of another object using a texture to control placement and scale. Dark areas of the texture will reduce the scale, and lighter areas yield larger objects. The tool allows users to clamp the minimum and maximum values, and additional controls to randomize placement, rotation, and scale of the objects. There is also a setting to cull objects on faces below a specific brightness value. To use the tool, the user selects and loads the objects to place, as well as the target surface, changes values if necessary, and presses the Distribute Geo button.

The tool works by iterating over each face of the target surface, gathering the vertex numbers and corresponding UVs, and averages the texel values for each UV associated with the face. Then it selects an object to place, aligns the object to the face normal (if requested) and moves the object to the center of the face. Once the object is placed it is translated, rotated, and scaled, according to the settings in the UI.

Download distributeObjectsOnSurface.py

Download sample Maya file (spike face example below)

Here is the UI, next to a scene where buildings are placed on a plane according to the texture.

In this example, trees are added to a mountain.

The tool can interpret both artist-created textures and procedural 2D textures. It can also preserve the original rotation of the objects, or orient them to follow the normals of the target surface.

Python: Directory-Wide Automated Poly Reduction Tool

The following Python code is a tool for reducing poly counts on meshes across an entire directory. This tool uses Maya’s reduce feature. The code prompts the user to select a directory and a reduction percentage. In order to easily review the changes, a screen shot is taken before and after the operation. Output image resolution is exposed in the tool. In the event the user would like to review the results before committing the changes, the tool provides a preview option. Screen shots are taken and geometry is reduced, but no changes are saved. The images are saved by default in the root of the selected directory, which the user can open directly from the tool.

Download polyReductionTool.py

Python: Texture Remap Tool

The following Python code works by getting all the textures in a scene, querying the user for a new texture directory, and setting the textureFileName attribute for each file to the new address. The tool has a find and replace option, and will create an error report of failed assignments if requested. The attached file has three folders, each with textures. The files in the first two folders are named the same, but the files in the third folder have been renamed.

Download textureRemapTool.py

Download Sample Files

Unity – C# Exploding Cubes

Download ExplodingCubes Project Files

[tube]0IlZhmJk1z8&hd=1[/tube]