Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Touching child generators

    SDK Help
    0
    11
    1.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 07/01/2004 at 11:29, xxxxxxxx wrote:

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

      ---------
      Hello,
      my generator object has another generator object (of the same type) as a child in his hierarchy.
      But I cannot "Touch" the child generator for it prevents the child generator from operating correctly when I do so.
      Touching the generator after checking the cache does not work either, it prevents it from working too and will only cause memory leaks (and the refreshing in the editor is not working either).
      Anybody knows a solution to this problem? I need this to make my generator work correctly.
      My generator works roughly like this:
      Generator A
      ---- within generator A -----
      Get the child generator B
      Clone it and return it
      ---- within generator A end -----
      the child generator B will most likely also have another child generator C and so on.
      Any idea or help is highly appreciated. Thank you in advance

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 07/01/2004 at 14:51, xxxxxxxx wrote:

        I suggest that you check out the source of GetAndCheckHierarchyClone(). It shows how to use the various cache functions. The important thing to keep in mind is that you have to use GetHierarchyClone() to do the actual cloning, it cannot be emulated. It sounds like you would use HCLONE_ASIS.

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 07/01/2004 at 15:18, xxxxxxxx wrote:

          I already looked at this but this doesn´t help me or I don´t know how it should because I also have 2 other child objects.
          Generator A
          --- Child 1
          --- Child 2
          --- Generator B 
               --- Child 1
               --- Child 2
               --- Generator C
                     [...]
          How can I use GetAndCheckHierarchyClone() on all of them? (I would have three dirty values. Which returned object clone should I return if all chidren haven´t changed?)
          Thanks in advance
          Samir

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            On 09/01/2004 at 13:48, xxxxxxxx wrote:

            Are all three generators "live"? Or is GetVirtualObjects() only supposed to be called in the first one? I'm afraid I don't understand what's supposed to happen.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

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

              On 09/01/2004 at 19:43, xxxxxxxx wrote:

              yes, they are "live" (I hope I understand you correctly. ) Each generator is completely executed, also the ones cloned in the generator.
              May I send you some sample code? [email protected] I guess again 🙂 Am away at the weekend but will send you some reduced code (that surely will show you the problem) on Sunday evening.
              Thanks for your help, I really start getting crazy 😞 And it´s now time that this gets "fixed" because I cannot keep on coding otherwise.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

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

                On 10/01/2004 at 09:49, xxxxxxxx wrote:

                Please do. However, I will be away for a few days, so it could take some time for me to reply. (Back on Friday the latest.)

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

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

                  On 09/12/2004 at 10:22, xxxxxxxx wrote:

                  Good heavens! I read this thread with great excitment only to be disappointed at the bottom to see that it was conintued offline!

                  I have exactly the same issue as Katachi did. Was this ever resolved? If so then I would love to find out what the solution is 😉

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

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

                    On 09/12/2004 at 14:35, xxxxxxxx wrote:

                    Hi,

                    yes, GetAndCheckHierarchyClone() is working as it should.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

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

                      On 09/12/2004 at 18:41, xxxxxxxx wrote:

                      Thanks for reponding Katachi!

                      I had first tried that and it seemed to work, but then I wandered over to GetClone. That is where my trouble began. I will go back to GetAndCheckHierarchyClone

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

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

                        On 15/12/2004 at 07:35, xxxxxxxx wrote:

                        Having worked a little more with GetAndCheckHierarchyClone I have a question:

                        It seems that GetAndCheckHierarchyClone calls all the various GetVirtualObject functions of the child generators only when they are changed otherwise it retrieves the child from a cache (using HCLONE_ASPOLY). So if one alters a parameter for object C (in Katachi's example above) then C, B, and A are regenerated. However, if one alters A, since it is higher up in the hierarchy, only A is regenerated and B and C are from the cache.

                        How could one best make the hierarchy regenerate all the child generators if A is changed? For example, in the Atom.cpp of the SDK, how could one change it so that when one reduced the subdivisions of an Atom generator A, it would automatically reduce the subdivisions of a child Atom generators B and C and then regenerate them?

                        Any insight here may save me lots trial and error - thanks!

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

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

                          On 16/12/2004 at 05:59, xxxxxxxx wrote:

                          To try to answer my own question above...

                          One can place a conditional in the GetVirtualObjects before the GetAndCheckHierarchyClone that checks if any relevant changes to the parent generator have taken place. If the condition is true, then set the current generator to Dirty and use any of the parent's parameters to alter the current generator's parameters.

                          In the example of how to make Atom recursive (by placing Atoms as children of itself) and making it that setting the subdivisions at the top ripple down I placed this code before the GetAndCheckHierarchyClone:

                            
                            
                               BaseContainer *bc=op->GetDataInstance();   
                            
                               // TESTING -- MAKE DIRTY IF PARENT CHANGED       
                               BaseObject* parent = op->GetUp();  
                               if (parent) {  
                                    BaseContainer *pc = parent->GetDataInstance();             
                                    // Check if parent is an Atom and if it has a different subdivision value  
                                    if (pc->GetLong(ATOMOBJECT_SUB) && pc->GetLong(ATOMOBJECT_SUB) != bc->GetLong(ATOMOBJECT_SUB) ) {  
                                         // alter this Atom based on the parent atom  
                                         bc->SetLong(ATOMOBJECT_SUB, pc->GetLong(ATOMOBJECT_SUB, 8));  
                                         // set this Atom as dirty so that it is re created in the hierachy check  
                                         orig->SetDirty(DIRTY_DATA);  
                                    }            
                               }  
                                 
                               Bool dirty = FALSE;  
                            
                               // generate polygonalized clone of input object  
                               BaseObject *main=NULL,*res=op->GetAndCheckHierarchyClone(hh,orig,HCLONE_ASPOLY,&dirty;,FALSE,NULL);   
                            
                               // if !dirty object is already cached and doesn't need to be rebuilt  
                               if (!dirty) return res;   
                               if (!res)   return NULL;   
                            
                            
                            
                          

                          In this way, we can still use the great feature of GetAndCheckHierachyClone that checks for changes in a bottom-up way, passing cached generators up to the GetVirtualObjects of parent generators, but still make bottom items regenerate when there have been relevant changes at the top.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post