SculptBrushParams Class Reference

#include <lib_sculptbrush.h>

Detailed Description

The parameters to pass in when registering a sculpt brush.

RegisterToolPlugin(MY_BRUSH_ID, "MyBrushName", PLUGINFLAG_HIDEPLUGINMENU|PLUGINFLAG_TOOL_SCULPTBRUSH|PLUGINFLAG_TOOL_NO_OBJECTOUTLINE, nullptr, "MyBrushHelpText", NewObjClear(MySculptBrush,pParams));
Bool RegisterToolPlugin(Int32 id, const maxon::String &str, Int32 info, BaseBitmap *icon, const maxon::String &help, ToolData *dat)
Definition: lib_sculptbrush.h:931
static SculptBrushParams * Alloc()
#define PLUGINFLAG_TOOL_SCULPTBRUSH
Tool is a sculpt brush.
Definition: c4d_tooldata.h:201
#define PLUGINFLAG_TOOL_NO_OBJECTOUTLINE
Object outlines on selection not supported.
Definition: c4d_tooldata.h:202
#define PLUGINFLAG_HIDEPLUGINMENU
Hide the plugin's menu entry.
Definition: c4d_baseplugin.h:31

By default the .res file includes the tabs for Stamps and Stencils and the options for Size, Pressure, Steady Stroke, Spacing and the Draw Modes.
If any of these options are need then hide them in the .res file by adding the following lines to the top of it:

CONTAINER toolmysculptbrush
{
NAME toolmysculptbrush;
INCLUDE toolsculptbrushbase;
HIDE MDATA_SCULPTBRUSH_STAMP_GROUP; // Setting EnableStamp(false) will also remove the Stamp Tab
HIDE MDATA_SCULPTBRUSH_STENCIL_GROUP; // Setting EnableStencil(false) will also remove the Stencil Tab
HIDE MDATA_SCULPTBRUSH_SETTINGS_RADIUS_MOD; // This is the FX option for Size.
HIDE MDATA_SCULPTBRUSH_SETTINGS_STRENGTH_MOD; // This is the FX option for Pressure.
}
@ HIDE
Layer should be completely ignored from both calculation and GUI display, e.g. the linked object has ...
@ CONTAINER
BaseContainer.
@ NAME
String Get/Set. The layer name.
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE
Definition: toolsculptbrushbase.h:56
@ MDATA_SCULPTBRUSH_SETTINGS_STAMPSPACING
Definition: toolsculptbrushbase.h:41
@ MDATA_SCULPTBRUSH_SETTINGS_STEADYSTROKE_VALUE
Definition: toolsculptbrushbase.h:39
@ MDATA_SCULPTBRUSH_SETTINGS_STEADYSTROKE
Definition: toolsculptbrushbase.h:38
@ MDATA_SCULPTBRUSH_SETTINGS_RADIUS_MOD
Definition: toolsculptbrushbase.h:30
@ MDATA_SCULPTBRUSH_SETTINGS_RADIUS
Definition: toolsculptbrushbase.h:31
@ MDATA_SCULPTBRUSH_SETTINGS_STRENGTH
Definition: toolsculptbrushbase.h:35
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_FILL_SYMMETRY
Definition: toolsculptbrushbase.h:80
@ MDATA_SCULPTBRUSH_SETTINGS_FILL_BACKFACES
Definition: toolsculptbrushbase.h:83
@ MDATA_SCULPTBRUSH_SETTINGS_STAMPSPACING_VALUE
Definition: toolsculptbrushbase.h:43
@ MDATA_SCULPTBRUSH_STENCIL_GROUP
Definition: toolsculptbrushbase.h:199
@ MDATA_SCULPTBRUSH_SETTINGS_STRENGTH_MOD
Definition: toolsculptbrushbase.h:34
@ MDATA_SCULPTBRUSH_STAMP_GROUP
Definition: toolsculptbrushbase.h:129

By Default the Draw Modes that are available are Freehand, Line, Lasso Fill, Polygon Fill and Rectangle Fill.
To remove any of these or add more, customize the list. Here is an example below where support is added for all the different modes, including DragDab and DragRect.
Just remove any from this list to suit the brush. By default Freehand is set, so if the Draw Mode is hidden the brush will still work.

CONTAINER toolmysculptbrush
{
NAME toolmysculptbrush;
INCLUDE toolsculptbrushbase;
{
COLUMNS 3;
GROUP
{
COLUMNS 3;
{
CYCLE
{
}
}
}
STATICTEXT { JOINENDSCALE; }
STATICTEXT { JOINEND; }
}
}
@ LONG
Int32 data.
@ BOOL
Bool Boolean, one DescID.
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_LINE
Definition: toolsculptbrushbase.h:67
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_DRAGDAB
Definition: toolsculptbrushbase.h:65
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_LASSO_FILL
Definition: toolsculptbrushbase.h:61
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_POLY_FILL
Definition: toolsculptbrushbase.h:63
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_FREEHAND
Definition: toolsculptbrushbase.h:66
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_DRAGRECT
Definition: toolsculptbrushbase.h:64
@ MDATA_SCULPTBRUSH_SETTINGS_GROUP
Definition: toolsculptbrushbase.h:25
@ MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_RECTANGLE_FILL
Definition: toolsculptbrushbase.h:62

Also make sure the priority for any sculpting plugins are set correctly. Sculpt brush plugins need to be loaded after the main sculpting plugin.
To ensure this set the priority in PluginMessage(Int32 id, void *data) as shown below:

Bool PluginMessage(Int32 id, void *data)
{
switch (id)
{
if (!g_resource.Init()) return false;
return true;
return true;
}
return false;
}
Bool PluginMessage(Int32 id, void *data)
#define SetPluginPriority(data, i)
Definition: c4d_plugin.h:198
GeResource g_resource
Global resources for Cinema&#160;4D.
Bool Init()
maxon::Bool Bool
Definition: ge_sys_math.h:55
maxon::Int32 Int32
Definition: ge_sys_math.h:60
#define C4DPL_INIT_PRIORITY_MODULES
Base priority for modules.
Definition: c4d_plugin.h:55
#define C4DPL_INIT_SYS
Initialize system.
Definition: c4d_plugin.h:28
#define C4DMSG_PRIORITY
Called to query plugins about their loading time priority. Answer with SetPluginPriority(),...
Definition: c4d_plugin.h:38

Private Member Functions

 SculptBrushParams ()
 
 ~SculptBrushParams ()
 

Alloc/Free

static SculptBrushParamsAlloc ()
 
static void Free (SculptBrushParams *&params)
 

Enable Methods

void EnableStencil (Bool enable)
 
void EnableStamp (Bool enable)
 
void EnableInvertCheckbox (Bool enable)
 
void EnableBuildup (Bool enable)
 
void EnableNonModelPickMode (Bool enable)
 
void EnableFlood (Bool enable)
 
void EnableMultiThreading (Bool enable)
 
void EnableBrushAccess (Bool enable)
 
void EnableToolSpecificSmooth (Bool enable)
 
void EnableModifier (Bool enable)
 
void EnablePython (Bool enable)
 
void EnableDrawDirection (Bool enable)
 
void EnableCustomStamp (Bool enable)
 
void EnableRespectSelections (Bool enable)
 
void EnableFillToolIsolatedPointRemover (Bool enable)
 
void EnablePressureHUD (Bool enable)
 
void EnableMouseData (Bool enable)
 
void EnableBackfaceSculpting (Bool enable)
 

Set Methods

void SetFloodType (SCULPTBRUSHDATATYPE type)
 
void SetBrushMode (SCULPTBRUSHMODE mode)
 
void SetFirstHitPointType (FIRSTHITPPOINTTYPE type)
 
void SetUndoType (SCULPTBRUSHDATATYPE type)
 
void SetPolygonObjectDirtyFlags (DIRTYFLAGS flags)
 
void SetMovePointFunc (Bool(*surfaceMovePointFunc)(BrushDabData *dab))
 

Constructor & Destructor Documentation

◆ SculptBrushParams()

SculptBrushParams ( )
private

◆ ~SculptBrushParams()

~SculptBrushParams ( )
private

Member Function Documentation

◆ Alloc()

static SculptBrushParams* Alloc ( )
static

Allocates a SculptBrushParams object. Destroy the allocated SculptBrushParams object with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated SculptBrushParams object, or nullptr if the allocation failed.

◆ Free()

static void Free ( SculptBrushParams *&  params)
static

Destructs SculptBrushParams objects allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]paramsThe SculptBrushParams object to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ EnableStencil()

void EnableStencil ( Bool  enable)

Enables/disables stencils in the brush.

Note
Setting to false frees up some resource and computation time.
Setting to false also removes the tab from the brush interface.
Parameters
[in]enabletrue if the brush uses stencils, false if not. Default is true.

◆ EnableStamp()

void EnableStamp ( Bool  enable)

Enables/disables stamps in the brush.

Note
Setting to false frees up some resource and computation time.
Setting to false also removes the tab from the brush interface.
Parameters
[in]enabletrue if the brush uses stamps, false if not. Default is true.

◆ EnableInvertCheckbox()

void EnableInvertCheckbox ( Bool  enable)

Enables/disables the Invert checkbox in the brush.

Note
By default the invert checkbox is not part of the base .res file so add it manually:
{
COLUMNS 3;
STATICTEXT { DUMMY; }
STATICTEXT { DUMMY; }
}
@ MDATA_SCULPTBRUSH_SETTINGS_INVERT
Definition: toolsculptbrushbase.h:48
Parameters
[in]enabletrue if the brush uses the Invert checkbox, false if not. Default is false.

◆ EnableBuildup()

void EnableBuildup ( Bool  enable)

Enables/disables the Buildup slider in the brush.

Note
By default the Buildup slider is not part of the base .res file so to add it manually:
{
COLUMNS 3;
REAL MDATA_SCULPTBRUSH_SETTINGS_BUILDUP { MIN 1; MAX 100; MINSLIDER 1; MAXSLIDER 100; CUSTOMGUI REALSLIDER; FIT_H; SCALE_H; }
STATICTEXT { JOINENDSCALE; }
STATICTEXT { JOINEND; }
}
@ REAL
Float data.
@ MAX
Maximum NBIT.
@ CUSTOMGUI
Custom GUI. (CustomGuiData)
@ MDATA_SCULPTBRUSH_SETTINGS_BUILDUP
Definition: toolsculptbrushbase.h:45
Parameters
[in]enabletrue if the brush uses the Buildup slider, false if not. Default is false.

◆ EnableNonModelPickMode()

void EnableNonModelPickMode ( Bool  enable)

Enables/disables non model pick mode, i.e. the brush do anything if the user clicks-off of a model: SculptBrushToolData::HandleNonModelPickMode and SculptBrushToolData::DrawNonModelPickMode are implemented.

Parameters
[in]enabletrue if SculptBrushToolData::HandleNonModelPickMode and SculptBrushToolData::DrawNonModelPickMode are implemented, false if not. Default is false.

◆ EnableFlood()

void EnableFlood ( Bool  enable)

Enables/disables the Flood function in the brush: SculptBrushToolData::FloodSelectedLayer is implemented.

Note
By default the Flood button is not part of the base .res file so add it manually:
{
COLUMNS 3;
STATICTEXT { JOINENDSCALE; }
STATICTEXT { JOINEND; }
}
@ MDATA_SCULPTBRUSH_SETTINGS_FLOOD
Definition: toolsculptbrushbase.h:49
Parameters
[in]enabletrue if SculptBrushToolData::FloodSelectedLayer is implemented, false if not. Default is false.

◆ EnableMultiThreading()

void EnableMultiThreading ( Bool  enable)

Enables/disables multithreading for the brush. Private.

Warning
Never enable multithreading!

Tells the system that the brush can be multithreaded. If true then the dabs are distributed over multiple threads and are drawn in any order.
Any calls to the MovePointFunc could now be for any stroke instance and could be out of order and from different threads.

Parameters
[in]enabletrue if the brush multithreaded, false if not. Default is false.

◆ EnableBrushAccess()

void EnableBrushAccess ( Bool  enable)

Enables/disables getting access to the brush via dab->GetBrush().

Parameters
[in]enabletrue if access to the brush is needed, false if not. Default is false.

◆ EnableToolSpecificSmooth()

void EnableToolSpecificSmooth ( Bool  enable)

Enables/disables the brush own smooth operation that gets used when the Shift key is pressed.

Note
Check for this in the MovePointFunc method if (GetBrushOverride() & OVERRIDE::SMOOTHTOOL) is true and then implement the custom smooth method. Otherwise it will use the Smooth Brush for smoothing.
Parameters
[in]enabletrue if the brush handles smoothing, false if not. Default is false.

◆ EnableModifier()

void EnableModifier ( Bool  enable)

Tells the system that the brush can use modifiers from other brushes (display the Modifiers tab).

Parameters
[in]enabletrue if the brush wants to be able to use modifiers from other brushes.

◆ EnablePython()

void EnablePython ( Bool  enable)

Enables/disables Python for the brush. Private.

Warning
Never enable for a C++ plugin! This is only ever used internally by Python brushes. When enabled it routes the calls to SculptBrushToolData::ApplyPythonDab.
All calls are only ever single threaded with no access to the brush data.

◆ EnableDrawDirection()

void EnableDrawDirection ( Bool  enable)

When enabled the Draw Direction UI will appear in the Settings tab.
Calls can then be made to GetDrawDirectionNormal() to get the direction of the normal based on the currently selected Draw Direction.

Parameters
[in]enabletrue to display the Draw Direction UI options. Disabled by default.

◆ EnableCustomStamp()

void EnableCustomStamp ( Bool  enable)

Enables/disables call to SculptBrushToolData::GetCustomData to change the stamp before a dab is drawn.

Note
EnableBrushAccess(true) must also be set.
Parameters
[in]enabletrue if the brush has a custom stamp, false if not. Default is false.

◆ EnableRespectSelections()

void EnableRespectSelections ( Bool  enable)

Enables/disables the brush to respect Point and Polygon selections when in Point or Polygon mode respectively.

Parameters
[in]enabletrue if the brush should respect selections, false if not. Default is false.

◆ EnableFillToolIsolatedPointRemover()

void EnableFillToolIsolatedPointRemover ( Bool  enable)

Enables/disables the Fill algorithm to remove any isolated points. That is any points that are selected but have no neighboring selections.
This can happen on high resolution meshes due to the nature of the hit detection against screen space pixels defined by the fill tools.
By setting to false it keeps any isolated points that are selected. This is true by default so isolated points are removed before being sent to the MovePointFunc function.

Parameters
[in]enabletrue if the brush should remove isolated points, false if it should keep them. Default is true.

◆ EnablePressureHUD()

void EnablePressureHUD ( Bool  enable)

Enables/disables displaying the pressure value in the sculpting size/pressure HUD.

Parameters
[in]enabletrue if the brush should display the pressure value, false if not. Default is true.

◆ EnableMouseData()

void EnableMouseData ( Bool  enable)

Enables/disables the callback for the MouseData method.

Since
R17.032
Parameters
[in]enabletrue if you need the MouseData callback, false if not. Default is false.

◆ EnableBackfaceSculpting()

void EnableBackfaceSculpting ( Bool  enable)

Tells the system that this brush supports backface sculpting and that the Backface option should be displayed in the brushes settings.

Since
R17.032
Parameters
[in]enabletrue if the brush supports backface sculpting, false if not. Default is false.

◆ SetFloodType()

void SetFloodType ( SCULPTBRUSHDATATYPE  type)

Specifies what kind of data the Flood operation will change (points or mask).

Parameters
[in]typeThe flood data type. Default is SCULPTBRUSHDATATYPE::POINT.

◆ SetBrushMode()

void SetBrushMode ( SCULPTBRUSHMODE  mode)

Specifies the type of brush (grab or normal).

Parameters
[in]modeThe brush mode. Default is SCULPTBRUSHMODE::NORMAL.

◆ SetFirstHitPointType()

void SetFirstHitPointType ( FIRSTHITPPOINTTYPE  type)

Specifies what should happen when the user first clicks on model before dragging.

Parameters
[in]typeThe first hit point type. Default is FIRSTHITPPOINTTYPE::SELECTED.

◆ SetUndoType()

void SetUndoType ( SCULPTBRUSHDATATYPE  type)

Specifies what kind of data the brush changes and stores in the undo system (point or mask).

Parameters
[in]typeThe brush data type. Default is SCULPTBRUSHDATATYPE::POINT.

◆ SetPolygonObjectDirtyFlags()

void SetPolygonObjectDirtyFlags ( DIRTYFLAGS  flags)

Sets which flags should be checked to do a rebuild of the collision structure for a PolygonObject.
These flags are used to check against the PolygonObjects dirty flags when a stroke is about to be done on a PolygonObject.
If the flags being checked are dirty since the last check then the collision cache structure for the object will be rebuilt.
This can be used in cases such as the Select Brush where you are not directly moving the points of the model during a stroke.
So you can set all the flags except the DIRTYFLAGS::SELECT (using something like (DIRTYFLAGS::ALL & ~DIRTYFLAGSSELECT) to ensure that the object is not recalculated when just the select flags are changed.
In all other cases the object will be rebuilt.

Since
R17.032
Parameters
[in]flagsThe dirty flags to check. By default this is set to DIRTYFLAGS::ALL.

◆ SetMovePointFunc()

void SetMovePointFunc ( Bool(*)(BrushDabData *dab)  surfaceMovePointFunc)

A pointer to the static method that is called to modify the SculptObject.
The MovePointFunc method must be implemented and passed like the following:

class MySculptBrush : public SculptBrushToolData
{
public:
MySculptBrush(SculptBrushParams *pParams) : SculptBrushToolData(pParams) { }
virtual Int32 GetToolPluginId(); // Return the unique id for the plugin as obtained from www.plugincafe.com
virtual const String GetResourceSymbol(); // Return the name of the resource file for the brush.
// This is something like "toolmysculptbrush", where the resource file is "toolmysculptbrush.res".
static Bool MovePointFunc(BrushDabData *dab); // This is the static implementation for the MovePointFunc
};
// Declare the MovePointFunc method
Bool MySculptBrush::MovePointFunc(BrushDabData *dab)
{
// Implement the functionality of the brush here
return true;
}
//Then pass it into the parameters method like
pParams->SetMovePointFunc(&MySculptBrush::MovePointFunc);
The brush data for an individual dab. This is passed into the method defined by the user in SculptBru...
Definition: lib_sculptbrush.h:350
Definition: lib_sculptbrush.h:1215
Definition: c4d_string.h:39
Parameters
[in]surfaceMovePointFuncThe static method to call for each brush dab.