CAWeightMgr Manual

内容表

关于

The CAWeightMgr class represents the Weight Manager dialog window and its functionality. It gives access to the displayed tags (of type CAWeightTag ) and joints.

设置

The settings presented by the Weight Manager dialog are stored with the BaseDocument . They can be safely accessed with these functions:

The setting IDs are defined in oweightmgr.h .

// This example changes the settings that are displayed in the Weight Manager dialog.

// enable "Display Weighting" CAWeightMgr::SetParameter (doc, ID_CA_WEIGHT_MGR_ENABLE_DISPLAY , true ); // enable "Draw All Joints" CAWeightMgr::SetParameter (doc, ID_CA_WEIGHT_MGR_DISPLAY_ALL_WEIGHTS , true ); // enable "Points" CAWeightMgr::SetParameter (doc, ID_CA_WEIGHT_MGR_DISPLAY_POINTS , true );

更新

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.

// This example creates and adds a weight tag and a skin object // to the given polygon object. The joints stored in the given BaseArray // are linked in the weight tag. The weight manager is updated // and used to create auto-weights.

// add weight tag and skin object

AutoAlloc<CAWeightTag> wTag; AutoAlloc<BaseObject> sObject { Oskin }; if (wTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); if (sObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); CAWeightTag * const weightTag = wTag. 发行 (); BaseObject * const skinObject = sObject.Release(); polyObject-> InsertTag (weightTag); doc-> InsertObject (skinObject, polyObject, nullptr );

// add joints from a BaseArray const Int jointCount = joints.GetCount(); for ( Int i = 0; i < jointCount; ++i) { BaseObject * const joint = joints[i]; weightTag-> AddJoint (joint); }

// select tag doc-> SetActiveTag (weightTag, SELECTION_NEW );

// update weight manager CAWeightMgr::Update (doc);

// select all joints CAWeightMgr::SelectAllJoints (doc);

// auto weight CAWeightMgr::AutoWeight (doc);

Weight Tags

The Weight Manager dialog displays the joints of multiple (selected) weight tags.

// This example loops through all Weight Tags // displayed in the Weight Manager window.

// get tag count const Int32 tagCount = CAWeightMgr::GetTagCount (doc); if (tagCount == 0) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION );

// loop through all tags for ( Int32 tagIndex = 0; tagIndex < tagCount; ++tagIndex) { // print tag name const CAWeightTag * const tag = CAWeightMgr::GetWeightTag (doc, tagIndex); if (tag == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Weight Tag: " + tag-> GetName ());

// print host object name const BaseObject * const hostObject = CAWeightMgr::GetMeshObject (doc, tagIndex); if (hostObject == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Host Object: " + hostObject-> GetName ()); }

Joints

每个 CAWeightTag stores weights for joints. These joints are displayed in the Weight Manager dialog.

// This example loops through all joints (influences) // handled in the weight tag at the given index.

// get count const Int32 jointCount = CAWeightMgr::GetJointCount (doc, tagIndex);

// loop through all joints for ( Int32 i = 0; i < jointCount; ++i) { const BaseObject * const joint = CAWeightMgr::GetJointObject (doc, tagIndex, i); if (joint == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// print joint name ApplicationOutput ( "Joint: " + joint-> GetName ()); }

Selection

It is possible to select joint objects in the Weight Manager. Several operations only apply to such selected objects.

The selection state of all joint objects can easily be managed with:

// This example loops through all selected objects. If the object // is a joint it will also be selected in the weight manager.

// get all selected objects AutoAlloc<AtomArray> objects; if (objects == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> GetActiveObjects (objects, GETACTIVEOBJECTFLAGS::CHILDREN );

// deselect all influences CAWeightMgr::UnselectAllJoints (doc);

// loop through all objects for ( Int32 i = 0; i < objects-> GetCount (); ++i) { // get object C4DAtom * const atom = objects-> GetIndex (i); BaseObject * const joint = static_cast< BaseObject * > (atom); if (joint == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// check if joint if (joint-> IsInstanceOf ( Ojoint )) { // get id const UInt64 id = CAWeightMgr::GetJointId (doc, weightTag, joint); if ( id != maxon::LIMIT<UInt64>::MAX ) { // check if selected if (joint-> GetBit ( BIT_ACTIVE )) CAWeightMgr::SelectJoint (doc, id ); } } }

Locked

The Weight Manager can lock a joint object to prevent unintended changes.

The lock state of all joint objects can be managed with:

// This example inverts the lock state of all influences // in the weight tag with the given index.

// deselect all CAWeightMgr::UnselectAllJoints (doc);

// get count const Int32 jointCount = CAWeightMgr::GetJointCount (doc, tagIndex);

// loop through all joints for ( Int32 i = 0; i < jointCount; ++i) { // check if locked if ( CAWeightMgr::IsJointLocked (doc, tagIndex, i) == false ) { // select unlocked CAWeightMgr::SelectJoint (doc, tagIndex, i); } }

// unlock all CAWeightMgr::UnlockAllJoints (doc);

// lock selected CAWeightMgr::LockSelectedJoints (doc);

函数

The weight algorithms are edited with these static functions:

注意
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.

注意
The functions take the selection state of a joint object into account.

Copy and paste functions are:

// This example configures the Weight Manager settings and applies the "Auto Weight" function.

// get modes const maxon::Id targetMode = maxon::AutoWeightAlgos::BoneglowClass().GetId(); const maxon::Int64 index = CAWeightMgr::GetAutoWeightAlgoIndex (doc, targetMode) iferr_return ;

// set mode GeData geData; geData. SetInt64 (index); CAWeightMgr::SetParameter (doc, ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE , geData);

// get settings maxon::DataDictionary data = CAWeightMgr::GetAutoWeightDictionary (doc, targetMode) iferr_return ;

// set settings data.Set(maxon::ANIMATION::AUTOWEIGHT::BONEGLOW::USEVISIBILITY, true ) iferr_return ; data.Set(maxon::ANIMATION::AUTOWEIGHT::BONEGLOW::VISIBILITYRATIO, 0.3_f) iferr_return ; CAWeightMgr::SetAutoWeightDictionary (doc, data, targetMode) iferr_return ;

// apply CAWeightMgr::AutoWeight (doc);

延伸阅读

Oskin
#define Oskin
Skin deformer.
定义: ge_prepass.h:1029
ID_CA_WEIGHT_MGR_DISPLAY_POINTS
@ ID_CA_WEIGHT_MGR_DISPLAY_POINTS
定义: oweightmgr.h:50
BaseList2D::GetBit
Bool GetBit(Int32 mask) const
定义: c4d_baselist.h:2207
ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE
@ ID_CA_WEIGHT_MGR_AUTOWEIGHT_MODE
定义: oweightmgr.h:151
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
Int
maxon::Int Int
定义: ge_sys_math.h:62
CAWeightTag::AddJoint
Int32 AddJoint(BaseObject *op)
BaseObject
定义: c4d_baseobject.h:224
CAWeightMgr::GetMeshObject
static BaseObject * GetMeshObject(BaseDocument *doc, Int32 tagIdx)
maxon::Int64
int64_t Int64
64 bit signed integer datatype.
定义: apibase.h:174
CAWeightMgr::GetAutoWeightDictionary
static maxon::Result< maxon::DataDictionary > GetAutoWeightDictionary(BaseDocument *doc, const maxon::Id &autoweightId)
AtomArray::GetCount
Int32 GetCount() const
定义: c4d_baselist.h:1619
maxon::Id
定义: apibaseid.h:250
iferr_return
#define iferr_return
定义: resultbase.h:1434
CAWeightTag
定义: lib_ca.h:178
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
CAWeightMgr::IsJointLocked
static Bool IsJointLocked(BaseDocument *doc, Int32 tagIdx, Int32 jointIdx)
ID_CA_WEIGHT_MGR_DISPLAY_ALL_WEIGHTS
@ ID_CA_WEIGHT_MGR_DISPLAY_ALL_WEIGHTS
定义: oweightmgr.h:48
BaseDocument::SetActiveTag
void SetActiveTag(BaseTag *tag, Int32 mode=0)
CAWeightMgr::SelectAllJoints
static void SelectAllJoints(BaseDocument *doc)
CAWeightMgr::Update
static Bool Update(BaseDocument *doc)
BIT_ACTIVE
#define BIT_ACTIVE
Active.
定义: ge_prepass.h:837
CAWeightMgr::AutoWeight
static Bool AutoWeight(BaseDocument *doc)
CAWeightMgr::SetAutoWeightDictionary
static maxon::Result< void > SetAutoWeightDictionary(BaseDocument *doc, maxon::DataDictionary dataDictionary, maxon::Id autoweightId)
CAWeightMgr::GetJointCount
static Int32 GetJointCount(BaseDocument *doc, Int32 tagIdx)
CAWeightMgr::GetAutoWeightAlgoIndex
static maxon::Result< Int > GetAutoWeightAlgoIndex(BaseDocument *doc, const maxon::Id &id)
CAWeightMgr::UnlockAllJoints
static Bool UnlockAllJoints(BaseDocument *doc)
ID_CA_WEIGHT_MGR_ENABLE_DISPLAY
@ ID_CA_WEIGHT_MGR_ENABLE_DISPLAY
定义: oweightmgr.h:51
maxon::LIMIT
定义: apibasemath.h:53
CAWeightMgr::SetParameter
static Bool SetParameter(BaseDocument *doc, Int32 id, const GeData &newValue)
CAWeightMgr::GetJointId
static UInt64 GetJointId(BaseDocument *doc, const CAWeightTag *tag, const BaseObject *joint)
BaseDocument::GetActiveObjects
void GetActiveObjects(AtomArray &selection, GETACTIVEOBJECTFLAGS flags) const
GeData
定义: c4d_gedata.h:82
C4DAtom
定义: c4d_baselist.h:1331
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
CAWeightMgr::GetJointObject
static BaseObject * GetJointObject(BaseDocument *doc, Int32 tagIdx, Int32 jointIdx)
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
CAWeightMgr::SelectJoint
static Bool SelectJoint(BaseDocument *doc, Int32 tagIdx, Int32 jointIdx)
CAWeightMgr::UnselectAllJoints
static void UnselectAllJoints(BaseDocument *doc)
AutoAlloc::Release
TYPE * Release()
定义: ge_autoptr.h:120
AutoAlloc
定义: ge_autoptr.h:36
GETACTIVEOBJECTFLAGS::CHILDREN
@ CHILDREN
Child objects are added to the selection too, provided they are selected. Otherwise only the topmost ...
GeData::SetInt64
void SetInt64(const Int64 &v)
定义: c4d_gedata.h:579
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
定义: c4d_baselist.h:1373
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
CAWeightMgr::GetWeightTag
static CAWeightTag * GetWeightTag(BaseDocument *doc, Int32 tagIdx)
CAWeightMgr::LockSelectedJoints
static Bool LockSelectedJoints(BaseDocument *doc)
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
UInt64
maxon::UInt64 UInt64
定义: ge_sys_math.h:61
SELECTION_NEW
#define SELECTION_NEW
Starts a new selection.
定义: c4d_basedocument.h:382
CAWeightMgr::GetTagCount
static Int32 GetTagCount(BaseDocument *doc)
Ojoint
#define Ojoint
Joint.
定义: ge_prepass.h:1028
AtomArray::GetIndex
C4DAtom * GetIndex(Int32 idx) const
定义: c4d_baselist.h:1634

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1