Problems with cloning...



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/09/2008 at 11:46, xxxxxxxx wrote:

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

    ---------
    Hi,

    I have written a generator object, that returns a virtual hierarchy.

    I can also create clones of objects that create clones themselves (e.g. the Array Object) as shown here:
    _<_img border="0" src= "http://www.c4d-jack.de/projects/spread/cloning_problem_1.jpg"_>_

    It is also possible to put my object into another cloning object (again like e.g. the Array Object) :<_<_img border="0" src= "http://www.c4d-jack.de/projects/spread/cloning_problem_3.jpg"_>_pg">

    But here comes the first problem: It is not possible for me to create clones of my own object, see he_<_img border="0" src= "http://www.c4d-jack.de/projects/spread/cloning_problem_2.jpg"_>__2.jpg">

    That's the first problem. What can I do here? Is there something I have to do? I just create clones of the source object(s) by using obj- >GetClone(0, NULL); and then inserting the cloned object into the virtual hierarchy, which I return in ::GetVirtualHierarchy().

    + + + + + + + + + + + + +

    2nd Problem:
    As you can also see on the sceenshots 1 and 3, my source objects are still visible. I do obj->Touch() on all ob them after creating the clones, but that does only hide the top object. If I have a whole hierarchy which I clone (like the Array Object on screenshot 1) only the Array Object gets hidden, but the Sphere Object stays visible. Do I have to iterate the object's whole hierarchy and touch every object I find, or is there a nicer way?

    Thanks for any help I am really stuck here :-(

    Best regards & greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/09/2008 at 12:54, xxxxxxxx wrote:

    OK, already got it. Have to use the AliasTrans class, too.

    > \> // Use AliasTrans \> AliasTrans \*at = AliasTrans::Alloc(); \> if (!at || !at->Init(doc)) return FALSE; \> \> cl=static_cast<BaseObject\*>(tp->GetClone(0, at)); \> if (!cl) return FALSE; \> \> // Alias Translate \> at->Translate(TRUE); \> \> // insert as last object under main \> cl->InsertUnderLast(main); \> \> // Free AliasTrans object \> AliasTrans::Free(at); \>

    But since I do this, I have several memory leaks. If I comment the whole AliasTrans stuff away, no leaks appear in the c4d trace window.

    It seems Free(at) is not enough. Anything else to do here?

    Cheers,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/09/2008 at 00:39, xxxxxxxx wrote:

    cl=static_cast<BaseObject\*>(tp->GetClone(0, at)); \> if (!cl) return FALSE;

    The memory leaks are probably because you forget to free the AliasTrans here.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2008 at 02:59, xxxxxxxx wrote:

    Does anybody know something about my 2nd Problem? Do I really have to iterate the whole hierarchy and touch every object?

    > Quote: Originally posted by c4dJack on 17 September 2008
    >
    > * * *
    >
    > User Information:
    >
    > Cinema 4D Version:   10.1
    > Platform:   Windows  ; Mac  ;
    > Language(s) :    C++  ;
    >
    >
    > ---------
    >
    >
    > 2nd Problem:
    > As you can also see on the sceenshots 1 and 3, my source
    > objects are still visible. I do obj->Touch() on all of
    > them after creating the clones, but that does only hide
    > the top object. If I have a whole hierarchy which I
    > clone (like the Array Object on screenshot 1) only the
    > Array Object gets hidden, but the Sphere Object stays
    > visible. Do I have to iterate the object's whole
    > hierarchy and touch every object I find, or is there a
    > nicer way?
    >
    >
    > * * *

    Thanks again in advance...

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2008 at 04:41, xxxxxxxx wrote:

    Hi Jack,

    use GetAndCheckHierarchyClone() instead. No need for dependence lists etc. then. It handles the hiding and touching too.

    Use it like this.

    > BaseObject\* down = op->GetDown(); if(!down) return BaseObject::Alloc(Onull); \> down = op->GetAndCheckHierarchyClone(hh, down, HCLONE_ASPOLY, &dirty;, NULL, TRUE); \> \> if (!dirty) return down;

    You will get a null-object with all the objects of your hierarchy cloned underneath it. Decide with HCLONE_ASPOLY what you want the hierarchy clones to be (HCLONE_ASIS for example to simply get clones, not converted to polys...see doc for more info).

    Now go on coding. ;-)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 21/09/2008 at 05:15, xxxxxxxx wrote:

    Thanks, working fine! :-)

    Cheers,
    Jack


Log in to reply