All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Custom Metaball Kernels

The kernel function used by metaballs is defined by the TS_MetaKernel class. This class contains a token, a label and four function pointers. The function pointers are used to evaluate the kernel function, while the token and label are used for saving, loading and UI. Furthermore, the custom kernel will show up as a menu item in all the Kernel Function parameters in Houdini.

The parameter to the evaluation functions represents the distance squared from the center of a unit metaball. The functions are responsible for evaluating the weight or gradient at the given distance. The functions should check the bounds on the arguments passed to it. The file TS/TS_cosKernel.C illustrates a sample kernel function which uses a half cosine curve as the basis function.

A current restriction is that only the first character of the kernel token is significant (for binary geometry files at a minimum). Therefore, it is important to choose a very unique kernel token. The tokens are case sensitive, so: cubic is different than Cubic. However, cubic may be equivalent to cosine (because only the first character is significant).

To register your custom kernel, you need to provide the newMetaKernel() entry point.

static TS_MetaKernel cosKernel = {
"cosine", // Token
"Half Cosine", // Label

To install your custom kernel, you need to create a MetaKernels file that will be found in your HOUDINI_PATH environment variable. The contents of this file should contain a list of .so/.dll paths located relative to the search paths in the HOUDINI_DSO_PATH environment variable. For example:

# MetaKernels : Kernel extension table

In this case, you should install the TS_MyKernel.so file into the dso subdirectory under where MetaKernels is found.

See Also