THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/01/2012 at 06:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12-R13
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;
---------
While the documentation helps a bit, I am very confused about how to proceed with converting morphs from my plugin into the new Pose Morph tag (CAMorphTag, CAMorph, CAMorphNode). Here is the skeletal code for how I think it should be working (untested, just coding it out) but am uncertain (e.g.: do you need to call UpdateMorphs() after each change or can it be called after all changes as I am showing? and so on).
// Morph tag
CAPoseMorphTag* mtag = CAPoseMorphTag::Alloc();
if (!mtag) return ErrorException::OOMThrow(EE_DIALOG, GeLoadString(IPPERR_MEMORY_TEXT), "Morphs_Figure_R12.mtag");
mtag->SetName("Morphs");
mesh->InsertTag(mtag);
doc->AddUndo(UNDOTYPE_NEW, mtag);
// - Must be initialized prior to any use
mtag->InitMorphs();
// - Apply any edits before modifying (?)
mtag->ExitEdit(doc,TRUE);
// - For each bone, add its morphs and configure (CAMorphNode)
BaseObject* bone = NULL;
BaseContainer* bbc = NULL;
BaseTag* tag = NULL;
BaseContainer* tbc = NULL;
IPPDial* ippd = NULL;
CAMorph* camorph = NULL;
CAMorphNode* camnode = NULL;
String prefix;
LONG m, lbi = bpidx+1L;
LONG i = 0L;
for (m = FIRST_BPINDEX; m != lbi; ++m)
{
bone = fbc->GetObjectLink(m, doc);
if (!bone) continue;
bbc = bone->GetDataInstance();
if (!bbc) continue;
prefix = bone->GetName()+".";
for (tag = bone->GetFirstTag(); tag; tag = tag->GetNext())
{
if (!tag->IsInstanceOf(ID_IPPDIALTAG)) continue;
ippd = (IPPDial* )tag->GetNodeData();
if (!ippd) continue;
if (!ippd->HasMorphs()) continue;
tbc = tag->GetDataInstance();
if (!tbc) continue;
// Add morph to the list
mtag->AddMorph();
camorph = mtag->GetMorph(i);
camnode = camorph->GetFirst();
// Expand morph data
camorph->SetMode(doc,mtag,CAMORPH_MODE_FLAGS_ALL|CAMORPH_MODE_FLAGS_EXPAND,CAMORPH_MODE_ABS);
if (!(camnode->GetInfo() & CAMORPH_DATA_FLAGS_POINTS)) continue;
// Access morph point data
// ...
// Compress morph data
camorph->SetMode(doc,mtag,CAMORPH_MODE_FLAGS_ALL|CAMORPH_MODE_FLAGS_COLLAPSE,CAMORPH_MODE_AUTO);
mtag->Message(MSG_UPDATE);
++i;
break;
}
}
// Must be called after changes to tag
mtag->UpdateMorphs();
return TRUE;