Cloning trouble
-
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.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2003 at 05:52, xxxxxxxx wrote:
(Sequential answers to all enclosed sentences ending with a '?' or '??'.)
- You don't want to include the actual Array object, only use its first child as input data.
- GetCache(hh).
- Yes. (You can actually check out the source for GetAndCheckHierarchyClone() yourself, in c4d_baseobject.cpp.)
- I think this parameter would be better named 'allsiblings', as it includes all siblings of the object in the clone. (These siblings are usually all children of the real parent, since you pass its first child.) Again, check out the source to see the details.
- The siblings of the object to clone.
- By design and convention.
- By design and convention. (This is the difference between generators and deformers. The latter always deforms its parent, including the whole tree from that point down. Takes some time to get used to, but all built-in deformers work this way.)
- By design. The array controls the rotation of the cloned objects. Using a dummy null makes it possible to override this, since then the null is rotated instead. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/08/2003 at 18:51, xxxxxxxx wrote:
Thanks for your comprehensive reply Mikael!
Why does a second call of BaseObject::GetHierarchyClone() cause a crash? (Unfortunately you missed my main question because it was not explicitly stated.)
What's the difference between GetClone() and GetHierarchyClone()? I've got multiple cloning to work by using Atom::GetClone() for subsequent clones, but don't really know *why* GetClone() works where GetHierarchyClone() doesn't... so if someone could explain how they differ, that would be good.
Here's how I'm now making subsequent clones:
static const LONG CLONE_FLAGS = COPY_NO_ANIMATION | COPY_NO_INTERNALS; BaseObject* clone = static_cast<BaseObject*> (clroot->GetClone(CLONE_FLAGS, 0 /*aliastrans*/)); clone->InsertUnderLast(gridroot);
Thanks again.
.angus.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/08/2003 at 09:15, xxxxxxxx wrote:
Sorry, I read that question first, but forgot among all the others. The answer is that I don't know. You're just supposed to call it once, I guess. Then you already have a calculated clone, so you can clone that clone instead. But I'll report it to the programmers.