About
The CAWeightMgr class represents the Weight Manager dialog window and its functionality. It gives access to the displayed tags (of type CAWeightTag) and joints.
Settings
The settings presented by the Weight Manager dialog are stored with the BaseDocument. They can be safely accessed with these functions:
- CAWeightMgr::SetParameter(): Set the Weight Manager setting.
- CAWeightMgr::GetParameter(): Returns the Weight Manager setting.
The setting IDs are defined in oweightmgr.h
.
@ ID_CA_WEIGHT_MGR_ENABLE_DISPLAY
Definition: oweightmgr.h:51
@ ID_CA_WEIGHT_MGR_DISPLAY_POINTS
Definition: oweightmgr.h:50
@ ID_CA_WEIGHT_MGR_DISPLAY_ALL_WEIGHTS
Definition: oweightmgr.h:48
const char * doc
Definition: pyerrors.h:226
Update
The CAWeightMgr class accesses an internal cache. This internal cache is automatically updated if the Weight Manger window is opened or the weight tool is active. If this is not the case the internal cache must be updated manually to handle scene changes.
- CAWeightMgr::Update(): Updates the internal cache.
- CAWeightMgr::SetDirty(): Sets the Weight Manager dirty to force an update on the next call to CAWeightMgr::Update().
AutoAlloc<CAWeightTag> wTag;
AutoAlloc<BaseObject> sObject {
Oskin };
if (wTag == nullptr)
if (sObject == nullptr)
CAWeightTag* const weightTag = wTag.Release();
BaseObject* const skinObject = sObject.Release();
polyObject->InsertTag(weightTag);
doc->InsertObject(skinObject, polyObject,
nullptr);
const Int jointCount = joints.GetCount();
for (
Int i = 0;
i < jointCount; ++
i)
{
BaseObject*
const joint = joints[
i];
weightTag->AddJoint(joint);
}
CAWeightMgr::Update(
doc);
CAWeightMgr::SelectAllJoints(
doc);
CAWeightMgr::AutoWeight(
doc);
Py_ssize_t i
Definition: abstract.h:645
#define Oskin
Skin deformer.
Definition: ge_prepass.h:1097
#define SELECTION_NEW
Starts a new selection.
Definition: c4d_basedocument.h:410
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
maxon::Int Int
Definition: ge_sys_math.h:55
Weight Tags
The Weight Manager dialog displays the joints of multiple (selected) weight tags.
- CAWeightMgr::GetTagCount(): Returns the number of displayed tags.
- CAWeightMgr::GetWeightTag(): Returns the CAWeightTag at the given index.
- CAWeightMgr::GetMeshObject(): Returns the host object of the weight tag at the given index.
- CAWeightMgr::GetTagIndex(): Returns the index of the given CAWeightTag.
const Int32 tagCount = CAWeightMgr::GetTagCount(
doc);
if (tagCount == 0)
for (
Int32 tagIndex = 0; tagIndex < tagCount; ++tagIndex)
{
const CAWeightTag*
const tag = CAWeightMgr::GetWeightTag(
doc, tagIndex);
if (tag == nullptr)
const BaseObject*
const hostObject = CAWeightMgr::GetMeshObject(
doc, tagIndex);
if (hostObject == nullptr)
}
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Int32 Int32
Definition: ge_sys_math.h:51
Joints
Each CAWeightTag stores weights for joints. These joints are displayed in the Weight Manager dialog.
- CAWeightMgr::GetJointCount(): Returns the number of joint objects of the tag with the given index.
- CAWeightMgr::GetJointIndex(): Returns the index of the given joint object.
- CAWeightMgr::GetJointId(): Returns the ID of the given joint object.
- CAWeightMgr::GetJointObject(): Returns the joint object at the given index and tag index or ID.
- CAWeightMgr::ValidateJointIndex(): Returns true if the given tag/joint index pair exists.
const Int32 jointCount = CAWeightMgr::GetJointCount(
doc, tagIndex);
{
const BaseObject*
const joint = CAWeightMgr::GetJointObject(
doc, tagIndex,
i);
if (joint == nullptr)
}
Selection
It is possible to select joint objects in the Weight Manager. Several operations only apply to such selected objects.
- CAWeightMgr::IsJointSelected(): Returns true if the joint object with the given index or ID is selected.
- CAWeightMgr::SelectJoint(): Selects the joint object with the given index or ID.
- CAWeightMgr::UnselectJoint(): Deselects the joint object with the given index or ID.
The selection state of all joint objects can easily be managed with:
- CAWeightMgr::SelectAllJoints(): Selects all joint objects
- CAWeightMgr::UnselectAllJoints(): Deselects all joint objects.
- CAWeightMgr::UnselectAllJointListNodes(): Deselects all of the nodes in the Weight Manager joint list.
AutoAlloc<AtomArray> objects;
if (objects == nullptr)
CAWeightMgr::UnselectAllJoints(
doc);
for (
Int32 i = 0;
i < objects->GetCount(); ++
i)
{
C4DAtom*
const atom = objects->GetIndex(
i);
BaseObject*
const joint =
static_cast<BaseObject*
>(
atom);
if (joint == nullptr)
if (joint->IsInstanceOf(
Ojoint))
{
const UInt64 id = CAWeightMgr::GetJointId(
doc, weightTag, joint);
{
CAWeightMgr::SelectJoint(
doc,
id);
}
}
}
Definition: apibasemath.h:54
CHILDREN
Check if the children are dirty.
Definition: ge_prepass.h:5
#define atom
Definition: graminit.h:72
#define BIT_ACTIVE
Active.
Definition: ge_prepass.h:888
#define Ojoint
Joint.
Definition: ge_prepass.h:1096
maxon::UInt64 UInt64
Definition: ge_sys_math.h:54
Locked
The Weight Manager can lock a joint object to prevent unintended changes.
- CAWeightMgr::IsJointLocked(): Returns true if the joint object with the given index or ID is locked.
- CAWeightMgr::LockSelectedJoints(): Locks the selected joint objects.
- CAWeightMgr::UnlockSelectedJoints(): Unlocks the selected joint objects.
The lock state of all joint objects can be managed with:
- CAWeightMgr::LockAllJoints(): Locks all joint objects.
- CAWeightMgr::UnlockAllJoints(): Unlocks all joint objects.
CAWeightMgr::UnselectAllJoints(
doc);
const Int32 jointCount = CAWeightMgr::GetJointCount(
doc, tagIndex);
{
if (CAWeightMgr::IsJointLocked(
doc, tagIndex,
i) ==
false)
{
CAWeightMgr::SelectJoint(
doc, tagIndex,
i);
}
}
CAWeightMgr::UnlockAllJoints(
doc);
CAWeightMgr::LockSelectedJoints(
doc);
Functions
The weight algorithms are edited with these static functions:
- CAWeightMgr::GetAutoWeightAlgoIndex(): Returns the index of the given auto weight algorithm (used with ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE).
- CAWeightMgr::GetAutoWeightAlgoId(): Returns the maxon::Id of the given auto weight algorithm index.
- CAWeightMgr::GetAutoWeightRef(): Returns the auto weight reference. See AutoWeightInterface Implementation.
- CAWeightMgr::GetAutoWeightDictionary(): Returns the DataDictionary with the algorithm's settings.
- CAWeightMgr::SetAutoWeightDictionary(): Sets the DataDictionary of the given algorithm.
- Note
- The auto weight algorithm IDs are defined in maxon/autoweight.h, the settings in maxon/autoweight_attributes.h.
Several weight tools of the Weight Manager can be invoked with dedicated functions. These functions add an undo step.
- CAWeightMgr::NormalizeWeights(): Applies a normalization.
- CAWeightMgr::ClearWeights(): Clears all weights.
- CAWeightMgr::AutoWeight(): Runs an auto weight algorithm.
- CAWeightMgr::MirrorWeights(): Mirrors the weights.
- CAWeightMgr::BakeWeights(): Bakes the effector weights.
- CAWeightMgr::FlipWeights(): Flips the weights.
- CAWeightMgr::SmoothWeights(): Smooths the weights.
- CAWeightMgr::ApplyWeightFunction(): Applies the currently selected weighting function.
- Note
- The functions take the selection state of a joint object into account.
Copy and paste functions are:
- CAWeightMgr::CopyWeights(): Copies the weights of the selected joint objects.
- CAWeightMgr::PasteWeights(): Pastes the copied weights on the selected joint objects.
const maxon::Id targetMode = maxon::AutoWeightAlgos::BoneglowClass().GetId();
GeData geData;
maxon::DataDictionary data = CAWeightMgr::GetAutoWeightDictionary(
doc, targetMode)
iferr_return;
data.Set(maxon::ANIMATION::AUTOWEIGHT::BONEGLOW::USEVISIBILITY,
true)
iferr_return;
data.Set(maxon::ANIMATION::AUTOWEIGHT::BONEGLOW::VISIBILITYRATIO, 0.3_f)
iferr_return;
CAWeightMgr::AutoWeight(
doc);
Definition: apibaseid.h:243
Py_ssize_t * index
Definition: abstract.h:374
int64_t Int64
64 bit signed integer datatype.
Definition: apibase.h:177
@ ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE
Definition: oweightmgr.h:151
#define iferr_return
Definition: resultbase.h:1531
Further Reading