The XFurStudioAPI is a static class that allows you to dynamically paint and edit the fur appearance at runtime with virtual, world-space spherical brushes through code. The Painter Objects included with XFur Studio 3 are based on the XFurStudioAPI as is XFur Studio Designer, meaning that you have the same powerful set of tools used to customize the fur within the editor available at runtime to expand massively the number of things you can do with XFur within your game.
Using the XFurStudioAPI is very simple and in this last section of the manual we will cover its main functions.
Groom
The Groom function, as its name implies, allows you to pass a world-space direction to an XFur Instance’s specific fur material and apply deformation in the form of grooming to the fur in that same direction. This world space direction is internally transformed to mesh based coordinates to ensure that the direction stays the same even in animated characters
//"target" - The target XFur Studio instance whose fur will be groomed
//"matIndex" - The index of the material to be edited
//"brushCenter" - The center of the brush sphere, in world coordinates
//"brushNormal" - The normal / direction in which the brush is looking, in world coordinates
//"brushSize" - The size of the brush sphere in world units
//"brushOpacity" - The opacity of the brush as a float between 0 and 1
//"brushHardness" - The hardness of the brush as a float between 0 and 1
//"groomDirection" - The direction in world coordinates in which the fur will be groomed
//"invert" - If true, grooming data will be removed rather than applied
public static void Groom( XFurStudioInstance target, int matIndex, Vector3 brushCenter, Vector3 brushNormal,
float brushSize, float brushOpacity, float brushHardness, Vector3 groomDirection, bool invert = false )
//Example :
public Transform myBrushObject;
void OnApplyGrooming(){
//Will groom the fur upwards wherever the myBrushObject transform intersects the xfurInstance object within
//a 0.25f units radius
XFurStudioAPI.Groom( xfurInstance, 0, myBrushObject.position, myBrushObject.forward, 0.25f, 0.35f, 0.5f,
Vector3.up );
}
Paint
The Paint function allows you to modify all the other aspects of the fur that are driven by textures, including its length / thickness / occlusion ( via the FurData0 map ), its color ( via the FurColorMap ), its color variation ( via the ColorVariationMap ) and even the output of the VFX module to add effects such as blood, snow or rain / wetness at runtime.
//"target" - The target XFur Studio instance whose fur will be groomed
//"painterMode" - The data that will be modified
//"matIndex" - The index of the material to be edited
//"brushCenter" - The center of the brush sphere, in world coordinates
//"brushNormal" - The normal / direction in which the brush is looking, in world coordinates
//"brushSize" - The size of the brush sphere in world units
//"brushOpacity" - The opacity of the brush as a float between 0 and 1
//"brushHardness" - The hardness of the brush as a float between 0 and 1
//"brushColor" - The color of the brush. For fur data values and masks use either white or black
//"brushTexture" - Optional brush texture ( functionality not fully implemented yet)
public static void Paint( XFurStudioInstance target, PaintDataMode painterMode, int matIndex, Vector3 brushCenter,
Vector3 brushNormal, float brushSize, float brushOpacity, float brushHardness, Color brushColor, Texture brushTexture )
//Example :
public Transform myBrushObject;
void OnApplyRedPaint(){
//Will paitn the fur red wherever the myBrushObject transform intersects the xfurInstance object within
//a 0.25f units radius. Since brushTexture is not fully implemented yet it is extremely important to
//pass this value as Texture2D.whiteTexture
XFurStudioAPI.Paint( xfurInstance, XFurStudioAPI.PaintDataMode.FurColor, 0, myBrushObject.position,
myBrushObject.forward, 0.25f, 0.35f, 0.5f, Color.red, Texture2D.whiteTexture );
}
With these two functions you can easily create all kinds of interactions between your game’s world, its players and XFur Studio™ 3 in ways that were not possible before. An almost limitless amount of gameplay possibilities are available thanks to these API commands and the new modules system, Painter Objects, WindZone objects and more. With XFur Studio™ 3 you have the most complete, efficient and advanced fur simulation system for Unity in any rendering pipeline you use, and for any device you develop.
If you have any questions, suggestions or technical issues related to this tool please don’t hesitate in contacting us to our support email. For support requests, please make sure to include your invoice / proof of purchase with your invoice number visible, the exact Unity version & rendering pipeline you used as well as the exact version of XFur Studio you are using for your project as well as all the relevant information and screenshots that may help us reproduce the issue.
We thank you for choosing XFur Studio 3 for your project and hope that it will assist you in creating all sorts of amazing creatures and worlds.