for
(
Int32
controllerIndex = 0; controllerIndex < controllerCount; ++controllerIndex)
{
BaseObject
*
const
controller = psd->
GetExternalController
(controllerIndex);
if
(controller ==
nullptr
)
return
maxon::UnexpectedError(
MAXON_SOURCE_LOCATION
);
ApplicationOutput
(
"Controller: "
+ controller->
GetName
());
}
}
}
// collapse data
const
CAMORPH_MODE_FLAGS
collapseFlags =
CAMORPH_MODE_FLAGS::ALL
|
CAMORPH_MODE_FLAGS::COLLAPSE
;
morph->
SetMode
(doc, poseMorphTag, collapseFlags,
CAMORPH_MODE::AUTO
);
Interpolation
For auto-weighting an interpolation mode is used:
The modes are:
// This example switches the interpolation setting
// of the given CAReferencePSD.
const
CAMORPH_PSDINTERPOLATION_MODE
interpolation = psd->
GetInterpolationMode
();
if
(interpolation ==
CAMORPH_PSDINTERPOLATION_MODE::AXIS
)
psd->
SetInterpolationMode
(
CAMORPH_PSDINTERPOLATION_MODE::JOINT
);
Driver
The joints referenced in the used weight tag can be forced to work as drivers for the PSD.
// This example loops through all joints weighted in the
// referenced Weight tag. All joints are forced as drivers.
GeData
data;
poseMorphTag->
GetParameter
(
ID_CA_POSE_WEIGHTTAG_UI_ONLY
, data,
DESCFLAGS_GET::NONE
);
C4DAtom
*
const
wTag = data.
GetLinkAtom
(doc,
Tweights
);
if
(wTag)
{
CAWeightTag
*
const
weightTag =
static_cast<
CAWeightTag
*
>
(wTag);
const
Int32
jointCount = weightTag->
GetJointCount
();
for
(
Int32
jointIndex = 0; jointIndex < jointCount; ++jointIndex)
{
psd->
ForceJointAsDriver
(jointIndex,
true
);
}
}
Pose
The PSD is based on a skeleton reference pose.
// This example restores the reference pose of the CAReferencePSD.
// get PSD data
CAReferencePSD
*
const
psd = mnode->
GetPSDReference
();
if
(psd)
{
psd->
RestoreReferencePose
();
}
Controllers
Non-joint objects can also be used as controllers.
// This example sets all selected non joint objects
// as a controller object of the given point morph.
// get PSD data
CAReferencePSD
*
const
psd = mnode->
GetPSDReference
();
if
(psd)
{
AutoAlloc<AtomArray>
objects;
if
(objects)
{
// get selected objects
doc->
GetActiveObjects
(objects,
GETACTIVEOBJECTFLAGS::NONE
);
// 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);
// only add non-joint objects
if
(baseObject && !baseObject->
IsInstanceOf
(
Ojoint
))
{
// add object as controller
const
矩阵
mg = baseObject->
GetMg
();
psd->
SetExternalControllerMatrix
(baseObject, mg);
}
}
}
}
延伸阅读
BaseObject * GetExternalController(Int32 controllerIndex)
C4DAtomGoal * GetLinkAtom(const BaseDocument *doc, Int32 instanceof=0) const
CAMORPH_PSDINTERPOLATION_MODE GetInterpolationMode() const
#define Tweights
Weights.
定义:
ge_prepass.h:1276
@ AUTO
Auto mode. Used to collapse the data automatically into their correct mode.
Matrix GetMg() const
定义:
c4d_baseobject.h:482
@ JOINT
Per joint interpolation (joint axis average).
Int32 GetCount() const
定义:
c4d_baselist.h:1619
#define MAXON_SOURCE_LOCATION
定义:
memoryallocationbase.h:66
Bool SetMode(BaseDocument *doc, CAPoseMorphTag *tag, CAMORPH_MODE_FLAGS flags, CAMORPH_MODE mode)
Bool ForceJointAsDriver(Int32 jointIndex, Bool forceDriver)
void RestoreReferencePose()
Displays skeleton and user defined controller at the reference pose.
@ POINTS
Points morphing.
void GetActiveObjects(AtomArray &selection, GETACTIVEOBJECTFLAGS flags) const
CAMORPH_DATA_FLAGS GetInfo()
maxon::Int32 Int32
定义:
ge_sys_math.h:58
#define ApplicationOutput(formatString,...)
定义:
debugdiagnostics.h:207
@ ALL
Expand or collapse all data.
Int32 SetExternalControllerMatrix(BaseObject *controller, const Matrix &globalMatrix)
Int32 GetExternalControllerCount() const
@ ID_CA_POSE_WEIGHTTAG_UI_ONLY
定义:
tcaposemorph.h:54
CAReferencePSD * GetPSDReference()
Bool IsInstanceOf(Int32 id) const
定义:
c4d_baselist.h:1373
String GetName() const
定义:
c4d_baselist.h:2318
CAMORPH_MODE_FLAGS
定义:
lib_ca.h:849
CAMORPH_PSDINTERPOLATION_MODE
定义:
lib_ca.h:907
void SetInterpolationMode(CAMORPH_PSDINTERPOLATION_MODE interpMode)
@ ABS
Absolute morph data.
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
@ EXPAND
Expand data. Needs to be passed before accessing any data.
@ COLLAPSE
Collapse data. Needs to be passed to collapse the expanded data, for instance after data access.
#define Ojoint
Joint.
定义:
ge_prepass.h:1028
C4DAtom * GetIndex(Int32 idx) const