About

A morph can use the mixing mode "Correctional PSD" (Pose Space Deformation). A CAReferencePSD object allows accessing the related data. The class is defined in the lib_ca.h header file.

Access

The CAReferencePSD object is obtained from the CAMorphNode object, see CAMorphNode Points.

// This example accesses the PSD data of the given point morph.
// expand data to access it
morph->SetMode(doc, poseMorphTag, expandFlags, CAMORPH_MODE::ABS);
// check stored data
if (mnode->GetInfo() & CAMORPH_DATA_FLAGS::POINTS)
{
// get PSD data
CAReferencePSD* const psd = mnode->GetPSDReference();
if (psd)
{
// loop through all controllers
const Int32 controllerCount = psd->GetExternalControllerCount();
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
morph->SetMode(doc, poseMorphTag, collapseFlags, CAMORPH_MODE::AUTO);
String GetName() const
Definition: c4d_baselist.h:2381
Definition: c4d_baseobject.h:225
Definition: lib_ca.h:924
Int32 GetExternalControllerCount() const
BaseObject * GetExternalController(Int32 controllerIndex)
maxon::Int32 Int32
Definition: ge_sys_math.h:60
@ POINTS
Points morphing.
CAMORPH_MODE_FLAGS
Definition: lib_ca.h:850
@ ALL
Expand or collapse all data.
@ COLLAPSE
Collapse data. Needs to be passed to collapse the expanded data, for instance after data access.
@ EXPAND
Expand data. Needs to be passed before accessing any data.
@ ABS
Absolute morph data.
@ AUTO
Auto mode. Used to collapse the data automatically into their correct mode.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
const char * doc
Definition: pyerrors.h:226

Interpolation

For auto-weighting an interpolation mode is used:

The modes are:

// This example switches the interpolation setting
// of the given CAReferencePSD.
CAMORPH_PSDINTERPOLATION_MODE GetInterpolationMode() const
void SetInterpolationMode(CAMORPH_PSDINTERPOLATION_MODE interpMode)
CAMORPH_PSDINTERPOLATION_MODE
Definition: lib_ca.h:908
@ JOINT
Per joint interpolation (joint axis average).

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);
}
}
Definition: c4d_baselist.h:1395
Bool ForceJointAsDriver(Int32 jointIndex, Bool forceDriver)
Definition: lib_ca.h:179
Int32 GetJointCount()
Definition: c4d_gedata.h:83
C4DAtomGoal * GetLinkAtom(const BaseDocument *doc, Int32 instanceof=0) const
#define Tweights
Weights.
Definition: ge_prepass.h:1432
@ ID_CA_POSE_WEIGHTTAG_UI_ONLY
Definition: tcaposemorph.h:54

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)
{
}
void RestoreReferencePose()
Displays skeleton and user defined controller at the reference pose.

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)
{
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 Matrix mg = baseObject->GetMg();
psd->SetExternalControllerMatrix(baseObject, mg);
}
}
}
}
Py_ssize_t i
Definition: abstract.h:645
Definition: ge_autoptr.h:37
Matrix GetMg() const
Definition: c4d_baseobject.h:482
Bool IsInstanceOf(Int32 id) const
Definition: c4d_baselist.h:1436
Int32 SetExternalControllerMatrix(BaseObject *controller, const Matrix &globalMatrix)
#define atom
Definition: graminit.h:72
#define Ojoint
Joint.
Definition: ge_prepass.h:1087

Further Reading