Adverti horiz upsell

Voxel Grid Generator 4.0.0 for Maya (maya script)

Script for generating voxel grid model(Animation Support).

Button download


  • 2015, 2014, 2013, 2012, 2011, 2010, 2009

Operating Systems

  • Mac
  • Windows


Last Modified:09/05/2014
File Size: 15.7 KB


particle, grid, mel, maya

This script is used for generating voxel-array models. You can use two different methods to create voxel array. 

By particle Instancer: this algorithm generating 3D particle array in the volume of selected geometry and use particle instancer to create voxel

By creating polygon cubes directly: create polyCubes inside the volume of selected geometry directly, choose "Use Instance" to keep the modeling relationship between reference cube(automatically hided) and voxels

Personally, I recommand using the former, coz particle instancing is much more faster in Maya than generating a bunch of cubes in the scene which might slow down your system. Of course, you can utilize the second method for some special circumsatances like preparing basic scene for rigid body simulation, etc.

---Update V1.8
Fix the bug caused by Maya's floating number caculation when sampling the points on perpendicular edges.

 ---Update V2.1.5
 Custom Object Instance supported.
Particle Grid Only: control whether to generate particle grid within geometry without instance.
Use Hollow: control whether generating hollow in the center of the grid, depends on the Hollow Distance bellow. This option can efficiently save your memory when creating large number of instance objects.  

---Update V 2.5.1
NURBS Surface Supported.
 Use Existing Particle Sys.: Use an existing particle system spicified by the Particle Sys. name field above instead of creating a new particle grid.

---Update V2.8.1
 Automatically soften the sampling geometry to avoid the cusp vertexes which may lead to incorrect result. Now the polygon-sampling process can work prefectly even with structures like cylinder or pyramid. 

You can now use separating num. field to indicate how many voxel elements to create in different dimension when using the "By Geometry Group" model. Toggle on the "Use Absolute Value" to active this model. And in this circumstance, the "Spacing" parameter only control the edge length of basic cube object(i.e. it will affect nothing when you specify a custom object as voxel element.)

---Update V 3.0.0
Close  Packing Mode: A new mode for generating 3D grid, which mimics the close-packed hexagonal structure. You can get more compact distribution by using this algorithim. It's more suitable for spherical shape models and will give you a better result if you wanner build a dynamic constraint network. Only the spacing parameter will affect the distribution of 3D grid in this mode.

 Add Attributes: In particle instancing mode, you can now add some extra per-particle attributes by turning on the three following checkboxes. 
     distance: the distance from the particle to the closest position to the geometry.  attribute name  --  VXG_cloSampleDis
     position: the coordinate of the particle's closest position on the geometry.  attribute name  --  VXG_cloSamplePos
     normal: the normal of the particles's closest point on the geometry.  attribute name  --  VXG_cloSampleNorm
By calling these attributes in particle expression, you can get more control of the particle instance. 

---Update V3.1.0
Small bugs fixed.
The "toggle normal" process is enhanced; it will automatically detect the softenEdge node in the history stack and avoid creating multiple softenEdge nodes when you run this script on the same object for several times. 
Add a "Copy" mode in Container Operation which duplicates the origin model first. This can backup your model if you want it to be left unchanged.

---Update V3.5.0
UI redesigned, since the parameters are getting a little massive, different modules are separated into multiple tabs. It may be a bit cumbersome to switch between tabs so I pack an old version the the rar file.

The particle mode now can bake animated model into voxels by caching particles on each frame. 

To use baking animation mode, you need to:
    Press down the "Use Particle Cache Animation" button.
    Type in a folder name to the "Cache Dict." textbox, Maya's particle cache can only be saved under your project dictionary, this parameter indicates the name of the folder to create in the cache sub folder of your project. By default it's "untitled" and you can quickly set it to the name of your scene by "Auto detect" button.
    Use Set Time Range menu and "Frame Range" define the duration of the animation. The "update" button can read the current timeline or render 
global start/end frame and set them to the baking time range.
    "Clear Cache" will delete any Maya particle cache file in the folder your specify and print a piece of information in the script editor.

Important tips for particle cache:
     The geometry-group model can't deal with animation coz Maya doesn't support obj sequence or in-built point animation for mesh by default and it doesn't make any scene to generate a bunch of geos per frame and then create blendshape or switch animation. In contrast, particle cache is a more efficient way for this.
     Maya reads cache for each particle shape node by matching their name with the *.pdc file in the cache folder, so make sure you change the Particle sys. name each time before you run this script because although maya will automatically rename the new particle object, it will leave the name of the shape node the same, which might confuse you when all the particles perform the same behavior.
    You can easily change the cache folder name to create a new folder under cache/particle, but I recommend you only to use one folder name for one scene because Maya can only read cache files from one specific path at the same time which is control by the "dynGlobals1" node. 
    The structure of project dictionary is slightly changed since version 2013(I guess)  by the introduction of Alembic; although this script can detect your Maya version and generate a corresponding path, some issues may still come up. So leave me a message if you find any problems :)

---Update V3.5.2
UI bug fixed, some control didn't work will in the lower version.
Clear Cache bug fixed, it seems the project dictionary only changed from Maya 2014, which made this script unable to delete the cache in 2013.

---V4.0.0 beta
This script can now generate voxel grid depends on fluid。 This function is under test so it's only supported in Geometry Copy mode.
You can set the "Grid Mode" under the "By geometry Copy" tab to evoke sample fluid mode. The "spacing" parameter doesn't work in the mode coz the voxel size is automatically calculated by the script according to the fluid container's resolution, but you can still specify a custom geometry. 
Fluid Attribute: specity which fluid attribute to sample, by default it's set to density, you can change it to "temperature" or "fuel" to sample different channels if your simulation contains such volume. Be careful that unlike the fluid module in Houdini, Maya can't contain custom channels in fluid, so only limited channels can be accepted and if you type in unsupported channels, the sampling will fail and return nothing. 
Three more parameters can be used to control fluid sample mode under the "Global Settings" tab.
Use Fluid Attribute Threshold: toggle this on to use the min threshold and max threshold to control the fluid sampling. Any voxel less than the min threshold and greater than the max threshold will be ignored. If this option is off, any voxel contains a value greater than 0 will be sampled and a model is created at the center of the voxel. Be careful if you want to sample voxels with very low value coz a fluid simulation like smoke sim usually has most voxels density greater than 0, although they looks like transprant, these voxels can still be sampled, which might not be the result you want. 

A tip for using this script with polygon object: I found the sampling for polygon surface normal will go terribly wrong if you rotate the object more than 90 degrees and leads to incorrect results especially when baking particle animation; it seems to be the problem caused by the closestPoitnOnMesh node and I haven't figured out a way fit it yet. 
Of course, for now, there is a way to avoid this issue by transforming the points in their local space. Before you set the transforming animation, select all the points and create a cluster constraint. Then set your keyframes on the cluster handle. 
The animmation drived by rigging or other types of constraints or deformers works correctly spontaneously. 

Fluid Sampling supported in particle mode, and it's also supported in baking particle animation.

Add Attr. Fluid: you can also store some fluid attributes at corresponding location on the particles
    voxel value: the value of the voxel depends on the channel you selected. attribute name  --  VXG_voxelValue
    velocity: the average volocity of the voxel, maya sotre the velocity of fluid in voxel edges and a voxel get the mean value of its surrounding edges. attribute name  --  VXG_voxelVel

enjoy it! :) 

Please use the Bug System to report any bugs.
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.

People who favorited this item:

  • PrinceBazooka
  • xeoon
  • Vojtech Lacina
    Vojtech Lacina
  • g2mXagent
  • grave450
  • ChaosWolf
  • kevin lim
    kevin lim
  • miraizu