CAWeightTag Manual

内容表

关于

The CAWeightTag class represents a weight tag. A weight tag stores weights that define the influence a joint object has on a deformed mesh. The class is defined in the lib_ca.h header file.

CAWeightTag objects are an instance of Tweights .

Access

A CAWeightTag tag can be accessed like any other tag, see BaseTag and VariableTag Manual .

// This example accesses the selected weight tag // and prints the names of weighted joints.

// get weight tag

BaseTag * const tag = doc-> GetActiveTag ();
if (tag == nullptr || !tag-> IsInstanceOf ( Tweights )) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION ); CAWeightTag * const weightTag = static_cast< CAWeightTag * > (tag);

// loop through all joints const Int32 jointCount = weightTag-> GetJointCount (); for ( Int32 i = 0; i < jointCount; ++i) { const BaseObject * const joint = weightTag-> GetJoint (i, doc); if (joint == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Joint: " + joint-> GetName ()); }

Allocation/Deallocation

CAWeightTag instances are created with the usual tools, see Entity Creation and Destruction Manual (Classic) .

// This example creates a new CAWeightTag // and adds it to the given polygon object. CAWeightTag * const weightTag = CAWeightTag::Alloc (); if (weightTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); polygonObject-> InsertTag (weightTag);

特性

Standard parameters on a CAWeightTag can be edited with C4DAtom::GetParameter() and C4DAtom::SetParameter() . The parameter IDs are defined in tcaweight.h .

Joints

A CAWeightTag manages a list of references to various joint objects.

// This example adds all selected joint objects to the given weight tag. AutoAlloc<AtomArray> objects; if (objects == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// get selected objects doc-> GetActiveObjects (objects, GETACTIVEOBJECTFLAGS::CHILDREN );

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

// only add joint objects if (baseObject-> IsInstanceOf ( Ojoint )) { weightTag-> AddJoint (baseObject); } }

For each joint the reset (or rest) state is stored:

The JointRestState structure has these members:

// This example loops through all joints known by the given weight tag // and prints the rest state length to the console.

// loop through all joints const Int32 jointCount = weightTag-> GetJointCount (); for ( Int32 i = 0; i < jointCount; ++i) { const JointRestState state = weightTag-> GetJointRestState (i); const Float length = state. m_Len ; ApplicationOutput ( "Rest Length: " + String::FloatToString (length)); }

Weights

A CAWeightTag stores weights for each point and joint.

注意
The order of weight values does not correspond to the point order.
// This example loads the weights stored for the given joint // and prints them to the console window.

// check if any weights are stored const Int32 weightCount = weightTag-> GetWeightCount (jointIndex); if (weightCount == 0) continue ; const Int32 pointCount = polyObject-> GetPointCount ();

// allocate memory maxon::BaseArray<Float32> weights; weights. Resize (pointCount) iferr_return ;

// load weights Float32 * const handle = weights. GetFirst (); weightTag-> GetWeightMap (jointIndex, handle, pointCount);

// print weights

for ( Int32 weightIndex = 0; weightIndex < pointCount; ++weightIndex) { const Float32 weight = weights[weightIndex]; ApplicationOutput ( "Weight: " + String::FloatToString (weight)); } // This example loops through all points to receive weights for each point.

// loop through all points const Int32 pointCount = polyObject-> GetPointCount (); for ( Int32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) { const Float weight = weightTag-> GetWeight (jointIndex, pointIndex); ApplicationOutput ( "Point " + String::IntToString (pointIndex) + " : " + String::FloatToString (weight)); }

矩阵

函数

CAWeightTag offers these functions:

// This example moves a joint and its rest state // and updates the rest state data.

// update rest state JointRestState state = weightTag-> GetJointRestState (1); state. m_oMg . off = state. m_oMg . off + 向量 (0, 100.0, 0); state. m_oMi = ~state. m_oMg ; weightTag-> SetJointRestState (1, state);

// update joint object position BaseObject * const joint = weightTag-> GetJoint (1, doc); if (joint) joint-> SetMg (state. m_oMg );

// calculate states weightTag-> CalculateBoneStates ( NOTOK );

延伸阅读

String::FloatToString
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
定义: c4d_string.h:529
CAWeightTag::GetWeightMap
void GetWeightMap(Int32 index, Float32 *map, Int32 cnt, Bool includeEffectors=false)
JointRestState::m_oMi
Matrix m_oMi
Inverse matrix of the actual Joint object.
定义: lib_ca.h:117
CAWeightTag::AddJoint
Int32 AddJoint(BaseObject *op)
BaseObject
定义: c4d_baseobject.h:224
JointRestState::m_Len
Float m_Len
Bone rest length.
定义: lib_ca.h:118
CAWeightTag::GetWeight
Float GetWeight(Int32 index, Int32 pntindex)
Tweights
#define Tweights
Weights.
定义: ge_prepass.h:1276
Float
maxon::Float Float
定义: ge_sys_math.h:64
PointObject::GetPointCount
Int32 GetPointCount(void) const
定义: c4d_baseobject.h:1439
CAWeightTag::Alloc
static CAWeightTag * Alloc()
定义: lib_ca.h:192
BaseObject::SetMg
void SetMg(const Matrix &m)
定义: c4d_baseobject.h:488
Float32
maxon::Float32 Float32
定义: ge_sys_math.h:66
BaseTag
定义: c4d_basetag.h:46
maxon::BaseArray::Resize
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
定义: basearray.h:1077
AtomArray::GetCount
Int32 GetCount() const
定义: c4d_baselist.h:1619
maxon::BaseArray::GetFirst
const MAXON_ATTRIBUTE_FORCE_INLINE T * GetFirst() const
定义: basearray.h:1034
iferr_return
#define iferr_return
定义: resultbase.h:1434
CAWeightTag
定义: lib_ca.h:178
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
BaseDocument::GetActiveTag
BaseTag * GetActiveTag(void)
maxon::BaseArray
定义: basearray.h:366
CAWeightTag::GetJointCount
Int32 GetJointCount()
CAWeightTag::GetJoint
BaseObject * GetJoint(Int32 index, BaseDocument *doc)
CAWeightTag::CalculateBoneStates
void CalculateBoneStates(Int32 index)
CAWeightTag::GetJointRestState
JointRestState GetJointRestState(Int32 index)
String::IntToString
static String IntToString(Int32 v)
定义: c4d_string.h:495
NOTOK
#define NOTOK
定义: ge_sys_math.h:265
BaseDocument::GetActiveObjects
void GetActiveObjects(AtomArray &selection, GETACTIVEOBJECTFLAGS flags) const
C4DAtom
定义: c4d_baselist.h:1331
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
CAWeightTag::SetJointRestState
void SetJointRestState(Int32 index, const JointRestState &state)
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145
maxon::Mat3::off
V off
The translation vector.
定义: matrix.h:279
AutoAlloc
定义: ge_autoptr.h:36
GETACTIVEOBJECTFLAGS::CHILDREN
@ CHILDREN
Child objects are added to the selection too, provided they are selected. Otherwise only the topmost ...
CAWeightTag::GetWeightCount
Int32 GetWeightCount(Int32 index)
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
定义: c4d_baselist.h:1373
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
JointRestState::m_oMg
Matrix m_oMg
Global matrix of the actual Joint object.
定义: lib_ca.h:116
JointRestState
定义: lib_ca.h:108
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
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