Archive for the ‘Python’ Category

Voxelize Meshes Script v.2

Thursday, February 25th, 2010

With the help of the patient people in the python_inside_maya forum, I’ve improved the Voxelize Meshes Script, mostly by more efficient use of the allIntersections method.

Instead of checking each point on the grid to see whether it’s inside one of the target meshes, this version shoots rays through the meshes along each axis and puts blocks at the intersections. This makes it approximately a zillion times faster, though I’m sure it could still be improved.

Update: Richard Kazuo from the p_i_m forum has excised lingering traces of pymel from my script, I’ve updated the code below with his improved version. It should now run with Maya’s default Python installation. Thanks Richard!

Update 2: Here’s the even-more-efficient voxelize_meshes_v.3.py … I’m putting this to bed now.

Maya Python code:
(more…)

Voxelize Meshes Script

Wednesday, February 10th, 2010

This script will voxelize selected meshes over the frame range of the timeline.

It is currently rather slow.

Pymel code:
(more…)

Voxelize Mesh Script

Monday, February 8th, 2010

This script will voxelize an animated mesh. It creates an array of cubes which fills the bounding box of the mesh’s motion through its animated range, and animates the visibility of each cube over the frame range based on its proximity to the mesh.

It’s quite slow, and would be faster if it used my octree, but it’s a start.

Written in Python with PyMEL for Maya.

Code follows:
(more…)

Pymel OOOctree

Sunday, February 7th, 2010

Please find below an expanding object-oriented octree implemented in Python with PyMEL for Maya. In this configuration, the octree functions as a space-partitioning scheme used to quickly find intersections between the bounding boxes of objects in scenes with many objects. It is not perfect but it does the job.

OOOctree_v.1.py

Usage and code follows.
(more…)

A Brief History of Manhattan

Wednesday, February 3rd, 2010

Not to scale.

Donut-upon-Avon

Wednesday, February 3rd, 2010

This donut was grown on the banks of the Upper Avon, and is popularly known as Shakespeare’s Donut. First described by Washington Irving, it was later the inspiration for the plan of the Globe Theater. Not coincidentally, a globe’s outer surface may be described by the transverse rotation of a sideways donut. However, this is not recommended.

How Globes Are Made, on Vimeo.

Octree Towers

Sunday, January 31st, 2010

I found a sneaky bug in my overhang-detection code which was preventing altitude. Here are 10,000 blocks of altitude.

(more…)

Moldsville

Saturday, January 30th, 2010

Mold-style growth, from the edges.

City of Ten Thousand Objects

Tuesday, January 26th, 2010

Count ‘em, 10000.

With the octree this only took an hour to generate.

Update: Okay, so I counted, and there are only 9,999. My bad.

Bear of Cubes

Sunday, January 24th, 2010

It’s about time somebody made a bear out of cubes.

Not much of a bear, really. It can’t be blamed for that, but I can.

The Cube of all Cubes

Saturday, January 23rd, 2010

Here are 2500 cubes all smushed into another cube without overlapping, which I accomplished by means of a cleverly-arranged series of object-oriented whistles and knobs in just over two of your Earth minutes.

(more…)

Octree Test

Saturday, January 9th, 2010

Chart showing octree superiority

That’s mathematics, son. You can argue with me, but you can’t argue with figures.

Commentary and code follows.
(more…)

Expanding Octree

Wednesday, January 6th, 2010

Another visualization of an octree expanding to encompass an increasingly wide-spread array of points, coded in Python for Maya using Pymel.

Live Octree

Wednesday, January 6th, 2010

Normally octrees start large and subdivide. This is fine for static scenes, or scenes in which the boundaries are known, or scenes managed by reasonable people.

Being perverse, I decided to make an octree that could adapt to its circumstances, and grow extra layers if necessary to accommodate objects beyond its limits.

This, my friends, is what we are witnessing here today. The first live, growing octree ever captured on film. By me.

As locators generate, this octree subdivides to keep any node from holding more than 10 at once. If a locator generates outside of the octree, the tree grows super-nodes until the point is contained.

Random Octree

Tuesday, January 5th, 2010

As my cubitecture expands, brute-force collision detection becomes ever more ridiculous. Above is a test visualization of an octree space-partitioning scheme, which I’ll modify for use in my block-placement code.

Code follows:
(more…)