Monday, December 2, 2013

Voxels part 2. MAYA .NET API and MFnMesh::allIntersections.

In part one we created a simple script, which generates voxels for a selected mesh object using
MFnMesh::allIntersections function. In this part we are going to write a VoxelGenerator node using Maya .NET API. Why node? Because we want to update our voxel on mesh changes. Actually I believe this node can be created using Maya python API, but i did it using C# in order to learn it, and check how usefull it is.

Let's define node attributes. Number and position of voxels depend on a grid density and a base object position in 3D space. So the input attributes should be: input - (short) "density", (kMesh) "inputGeometry", and output - (int) "voxelsNumber".

I use Microsoft Visual Studio 2013 and Autodesk Maya 2014. For easy start download and install Maya C# Wizards for Visual Studio. You can find it in Cyrille Fauvel blog. After the installation create a new maya plugin in the Visual Studio and let's begin!