#include <lib_sculptbrush.h>
详细描述
The parameters to pass in when registering a sculpt brush.
SculptBrushParams
* pParams =
SculptBrushParams::Alloc
();
RegisterToolPlugin
(MY_BRUSH_ID,
"MyBrushName"
,
PLUGINFLAG_HIDEPLUGINMENU
|
PLUGINFLAG_TOOL_SCULPTBRUSH
|
PLUGINFLAG_TOOL_NO_OBJECTOUTLINE
,
nullptr
,
"MyBrushHelpText"
, NewObjClear(MySculptBrush,pParams));
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
;
// This is Size
HIDE
MDATA_SCULPTBRUSH_SETTINGS_RADIUS_MOD
;
// This is the FX option for Size.
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STRENGTH
;
// This is Pressure
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STRENGTH_MOD
;
// This is the FX option for Pressure.
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STEADYSTROKE
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STEADYSTROKE_VALUE
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STAMPSPACING
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_STAMPSPACING_VALUE
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_FILL_BACKFACES
;
HIDE
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_FILL_SYMMETRY
;
}
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;
GROUP
MDATA_SCULPTBRUSH_SETTINGS_GROUP
{
COLUMNS 3;
GROUP
{
COLUMNS 3;
LONG
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE
{
CYCLE
{
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_FREEHAND
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_DRAGRECT
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_DRAGDAB
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_LINE
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_LASSO_FILL
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_POLY_FILL
;
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_RECTANGLE_FILL
;
}
}
BOOL
MDATA_SCULPTBRUSH_SETTINGS_DRAWMODE_FILL_SYMMETRY
{ }
BOOL
MDATA_SCULPTBRUSH_SETTINGS_FILL_BACKFACES
{ }
}
STATICTEXT { JOINENDSCALE; }
STATICTEXT { JOINEND; }
}
}
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
)
{
case
C4DPL_INIT_SYS
:
if
(!
g_resource
.
Init
())
return
false
;
return
true
;
case
C4DMSG_PRIORITY
:
SetPluginPriority
(data,
C4DPL_INIT_PRIORITY_MODULES
+1);
return
true
;
}
return
false
;
}
构造函数 & 析构函数文档编制
◆
SculptBrushParams()
◆
~SculptBrushParams()
成员函数文档编制
◆
Alloc()
Allocates a
SculptBrushParams
object. Destroy the allocated
SculptBrushParams
object with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
返回
-
The allocated
SculptBrushParams
object, or
nullptr
if the allocation failed.
◆
Free()
Destructs
SculptBrushParams
objects allocated with
Alloc()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in,out]
|
params
|
The
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.
-
注意
-
Setting to
false
frees up some resource and computation time.
Setting to
false
also removes the tab from the brush interface.
-
参数
-
[in]
|
enable
|
true
if the brush uses stencils,
false
if not. Default is
true
.
|
◆
EnableStamp()
void EnableStamp
|
(
|
Bool
|
enable
|
)
|
|
Enables/disables stamps in the brush.
-
注意
-
Setting to
false
frees up some resource and computation time.
Setting to
false
also removes the tab from the brush interface.
-
参数
-
[in]
|
enable
|
true
if the brush uses stamps,
false
if not. Default is
true
.
|
◆
EnableInvertCheckbox()
void EnableInvertCheckbox
|
(
|
Bool
|
enable
|
)
|
|
Enables/disables the Invert checkbox in the brush.
-
注意
-
By default the invert checkbox is not part of the base .res file so add it manually:
GROUP
MDATA_SCULPTBRUSH_SETTINGS_GROUP
{
COLUMNS 3;
BOOL
MDATA_SCULPTBRUSH_SETTINGS_INVERT
{ }
STATICTEXT {
DUMMY
; }
STATICTEXT {
DUMMY
; }
}
-
参数
-
[in]
|
enable
|
true
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.
-
注意
-
By default the Buildup slider is not part of the base .res file so to add it manually:
GROUP
MDATA_SCULPTBRUSH_SETTINGS_GROUP
{
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; }
}
-
参数
-
[in]
|
enable
|
true
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.
-
参数
-
◆
EnableFlood()
void EnableFlood
|
(
|
Bool
|
enable
|
)
|
|
Enables/disables the Flood function in the brush:
SculptBrushToolData::FloodSelectedLayer
is implemented.
-
注意
-
By default the Flood button is not part of the base .res file so add it manually:
GROUP
MDATA_SCULPTBRUSH_SETTINGS_GROUP
{
COLUMNS 3;
BUTTON
MDATA_SCULPTBRUSH_SETTINGS_FLOOD
{ }
STATICTEXT { JOINENDSCALE; }
STATICTEXT { JOINEND; }
}
-
参数
-
◆
EnableMultiThreading()
void EnableMultiThreading
|
(
|
Bool
|
enable
|
)
|
|
Enables/disables multithreading for the brush.
Private
.
-
警告
-
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.
-
参数
-
[in]
|
enable
|
true
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().
-
参数
-
[in]
|
enable
|
true
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.
-
注意
-
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.
-
参数
-
[in]
|
enable
|
true
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).
-
参数
-
[in]
|
enable
|
true
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
.
-
警告
-
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.
-
参数
-
[in]
|
enable
|
true
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.
-
注意
-
EnableBrushAccess(true)
must also be set.
-
参数
-
[in]
|
enable
|
true
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.
-
参数
-
[in]
|
enable
|
true
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
函数。
-
参数
-
[in]
|
enable
|
true
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.
-
参数
-
[in]
|
enable
|
true
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.
-
由于
-
R17.032
-
参数
-
[in]
|
enable
|
true
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.
-
由于
-
R17.032
-
参数
-
[in]
|
enable
|
true
if the brush supports backface sculpting,
false
if not. Default is
false
.
|
◆
SetFloodType()
Specifies what kind of data the Flood operation will change (points or mask).
-
参数
-
◆
SetBrushMode()
Specifies the type of brush (grab or normal).
-
参数
-
◆
SetFirstHitPointType()
Specifies what should happen when the user first clicks on model before dragging.
-
参数
-
◆
SetUndoType()
Specifies what kind of data the brush changes and stores in the undo system (point or mask).
-
参数
-
◆
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
& ~DIRTYFLAGS
SELECT
) to ensure that the object is not recalculated when just the select flags are changed.
In all other cases the object will be rebuilt.
-
由于
-
R17.032
-
参数
-
[in]
|
flags
|
The dirty flags to check. By default this is set to
DIRTYFLAGS::ALL
.
|
◆
SetMovePointFunc()
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);
-
参数
-
[in]
|
surfaceMovePointFunc
|
The static method to call for each brush dab.
|
定义:
lib_sculptbrush.h:929
@ BOOL
Bool Boolean, one DescID.
@ NAME
String Get/Set. The layer name.
#define PLUGINFLAG_TOOL_SCULPTBRUSH
Tool is a sculpt brush.
定义:
c4d_tooldata.h:201
#define C4DMSG_PRIORITY
Called to query plugins about their loading time priority. Answer with SetPluginPriority(),...
定义:
c4d_plugin.h:38
static SculptBrushParams * Alloc()
@ CONTAINER
BaseContainer.
#define C4DPL_INIT_PRIORITY_MODULES
Base priority for modules.
定义:
c4d_plugin.h:55
#define SetPluginPriority(data, i)
定义:
c4d_plugin.h:198
The brush data for an individual dab. This is passed into the method defined by the user in SculptBru...
定义:
lib_sculptbrush.h:349
#define PLUGINFLAG_TOOL_NO_OBJECTOUTLINE
Object outlines on selection not supported.
定义:
c4d_tooldata.h:202
maxon::Int32 Int32
定义:
ge_sys_math.h:58
@ HIDE
Layer should be completely ignored from both calculation and GUI display, e.g. the linked object has ...
void SetMovePointFunc(Bool(*surfaceMovePointFunc)(BrushDabData *dab))
#define PLUGINFLAG_HIDEPLUGINMENU
Hide the plugin's menu entry.
定义:
c4d_baseplugin.h:26
Bool PluginMessage(Int32 id, void *data)
maxon::Bool Bool
定义:
ge_sys_math.h:53
GeResource g_resource
Global resources for Cinema 4D.
#define C4DPL_INIT_SYS
Initialize system.
定义:
c4d_plugin.h:28
@ CUSTOMGUI
Custom GUI. (CustomGuiData)