THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/10/2004 at 14:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.503
Platform: Windows ;
Language(s) : C++ ;
---------
Instead of morph Objects, I'm storing the morph information in tags attached to the bones (just for organization - no direct effect on bones). But, the MorphMixer object is causing problems with the geometry as long as bones are fixed. Here's the general hierarchy:
PolygonObject
-- MorphMixer Object
-- Bone MorphTag|MorphTag|...
-----Bone MorphTag|MorphTag|...
-----Bone MorphTag|MorphTag|...
-----etc. on Bone Hierarchy
Now, the morph sliders are working, the morphs are working, but the cause of the distortion on the overall geometry is hard to determine. Well, here's is the code for applying the morphs. If you see a problem needing attention or have an alternative methodology, please help!
// Create morphed object
BaseObject *MorphMixerObject::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh)
{
Bool dirty;
LONG index = MORPHMIXER_POSEOFFSET;
Vector *destadr = NULL;
BaseObject *ret = NULL, *orig;
BaseContainer *data = op->GetDataInstance();
// Get Polygonal Object receiving morphs, return NULL if none
if (!(orig = op->GetUp()) || !orig->IsInstanceOf(Opoint)) return NULL;
// check cache for validity and check master object for changes
dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA);
orig->Touch();
if (!dirty) return op->GetCache(hh);
// Clone base object
if (!(ret = (BaseObject* )orig->GetClone(COPY_NO_HIERARCHY|COPY_NO_ANIMATION|COPY_NO_BITS,NULL))) return NULL;
// and transfer tags
if (!op->CopyTagsTo(ret,NOTOK,NOTOK,FALSE,NULL))
{
BaseObject::Free(ret);
return NULL;
}
// transfer name
ret->SetName(op->GetName());
// retrieve destination and base points
destadr = ((PolygonObject* )ret)->GetPoint();
ApplyMorph(GetActiveDocument(), op->GetNext(), orig, destadr, data, &index;);
// send update message
ret->Message(MSG_UPDATE);
return ret;
}
// Apply Morph to MorphMixer- recursive
void MorphMixerObject::ApplyMorph(BaseDocument *doc, BaseObject *obj, BaseObject *mobj, Vector *dest, BaseContainer *bc, LONG *index)
{
LONG nr;
Real strength;
LONG *indices, *lind;
Vector *deltas;
BaseContainer *pbc;
BaseObject *mo;
PluginTag *pt;
struct morphData mData;
mData.bGet = TRUE;
mData.indices = NULL;
for (; obj; obj = obj->GetNext())
{
// Apply related Morphs to MorphMixer list
for (nr = 0; pt = (PluginTag* )obj->GetTag(ID_MORPHTAG, nr); nr++)
{
// Verify morph object
pbc = pt->GetDataInstance();
if ((mo = pbc->GetObjectLink(MORPHTAG_OPOLYGON_LINK, doc)) != mobj) continue;
// Get morph percentage from slider
strength = bc->GetReal(*index);
// Get morph point count, indices, and deltas
pt->Message(MSG_CHANGE, &mData;);
indices = mData.indices;
deltas = mData.morphs;
lind = indices+pbc->GetLong(MORPHTAG_MCOUNT_LONG);
// Add weighted morph
for (; indices != lind; indices++, deltas++)
dest[*indices] += (*deltas * strength);
(*index)++;
}
ApplyMorph(doc, obj->GetDown(), mobj, dest, bc, index);
}
}
Thanks,
Robert