THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/08/2003 at 18:11, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.100
Platform: Mac ;
Language(s) : C++ ;
---------
I want to duplicate some of the functionality of objects->modelling->array, but am having some trouble: I can clone an object once, but further cloning causes crashes...
BaseObject*
Test::GetVirtualObjects(PluginObject* op, HierarchyHelp* hh)
{
BaseObject* child = op->GetDown(); // first child
if (!child)
return 0; // no children: no output
Bool dirty = false;
BaseObject* cloneroot = child; // first child only (why not '= op'?)
// GetAndCheckHierarchyClone will
// - make a clone of the given hierarchy
// - check dirty flags
// - touch hierarchy
// what does it return if (!dirty)?
// eg (Atom.cpp) had: "return caclone;"
// is caclone == op->GetCache(hh) in this case??
BaseObject* caclone = op->GetAndCheckHierarchyClone
(hh, cloneroot, HCLONE_ASIS, &dirty;, 0, false);
if (!dirty) // cache is good
return op->GetCache(hh); // return cache
if (!caclone)
return 0; // nothing cloned: nothing to do
BaseObject* gridroot = BaseObject::Alloc(Onull);
Vector v(0, 0, 0);
// THIS WORKS FINE
// insert clone
caclone->InsertUnderLast(gridroot);
v.x = -100;
v.y = -100;
caclone->SetPos(v);
// THIS CODE WILL CAUSE CRASH
// second clone
dirty = false;
caclone = op->GetHierarchyClone
(hh, cloneroot, HCLONE_ASIS, &dirty;, 0);
caclone->InsertUnderLast(gridroot);
v.x = 100;
v.y = 100;
clone2->SetPos(v);
// THIS CODE WILL CAUSE CRASH
// third clone
dirty = false;
// - why does GetAndCheckHierarchyClone need an extra arg (Bool allchilds)?
// - if 'allchilds' is false, which parts of the hierarchy are left out?
caclone = op->GetAndCheckHierarchyClone
(hh, cloneroot, HCLONE_ASIS, &dirty;, 0, false);
caclone->InsertUnderLast(gridroot);
v.x = 100;
v.y = -100;
clone2->SetPos(v);
return gridroot;
}
Other semi-related questions:
- why does Array only operate on its first child (not all children)? (this goes for some other operators, too)
- why do some operators (eg deformations) operate on their parents (rather than their children)?
- why can't I animate an Array's dependent's transform without adding a Null to the hierarchy? eg: with Array -> Null -> Cube, I can animate the cube's rotation, but with Array -> Cube, I can't.
Thanks in advance, and sorry if I'm missing anything obvious here...
.angus.