Adding CAMorph to CAPoseMorphTag [SOLVED]

On 12/05/2015 at 11:10, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R16 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi, I am trying to add a absolute pose morph to the pose morph tag in C++. Below is code that adds a new morph to the tag.

CAPoseMorphTag * rootPose = (CAPoseMorphTag * )clone->MakeTag(Tposemorph, nullptr);
rootPose->InitMorphs();
  
C4DAtom * rootAtom = (C4DAtom * )rootPose;
rootAtom->SetParameter(DescID(ID_CA_POSE_POINTS), GeData(1), DESCFLAGS_SET_0);
  
CAMorph * morph = rootPose->AddMorph();
morph->SetTarget(rootPose, document, obj);
morph->SetMode(document, rootPose, CAMORPH_MODE_FLAGS_COLLAPSE, CAMORPH_MODE_ABS);
morph->Apply(document, rootPose, CAMORPH_DATA_FLAGS_POINTS);
rootPose->UpdateMorphs(document);

This code fails to set the morph mixing mode to absolute. I've also tried to set the mixing mode via SetParameter using ID_CA_POSE_MIXING. But this crashes C4D.

C4DAtom * morphAtom = (C4DAtom * )morph;
morphAtom->SetParameter(DescID(ID_CA_POSE_MIXING), GeData(ID_CA_POSE_MIXING_ABS), DESCFLAGS_SET_0);

I noticed that the mixing parameters are inactive. Could this be related?

I have an alembic hierarchy. And I am generating a polygon version of that hierarchy. Each object in the hierarchy has a pose morph tag that targets the alembic equivalent object.

How do I correctly add morph targets with the correct mixing mode?

On 12/05/2015 at 11:55, xxxxxxxx wrote:

Figured it out, you have to set the pose morph tag's active morph index. Like this:

rootPose->SetActiveMorphIndex(0);
rootPose->SetParameter(DescID(ID_CA_POSE_MIXING), GeData(ID_CA_POSE_MIXING_ABS), DESCFLAGS_SET_0);

This seems to select the pose morph in the pose list, allowing you to access the parameters.