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

    Polygonize the scene

    SDK Help
    0
    6
    558
    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

      On 02/12/2015 at 15:05, xxxxxxxx wrote:

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

      ---------
      Hello.

      I am trying to implement a renderer and i need to convert the whole hierarchy to polygons.
      What i do right know is to traverse the hierarchy and make everything editable using MCOMMAND_MAKEEDITABLE.
      That way i need to take care of the links (instance, Moinstance, Splire Wrapper , etc), because in some cases they break (depending on where they point to).
      Even though it works, the way i have implemented it seems way too complex.

      1. Is there any better way to do this ?

      Also, this procedure doesn't work for emitter that emit objects (e.g. spheres).
      I have seen in the forum that GetDeformCache returns a polygonized object (if the cache is built previously with a Hierarchy subclass).
      2) Is it safe to use insertObject to added to the document afterwards ?

      Sometimes i cannot use the Hierarchy class to build the caches.
      So i try to use the following code:
      cache = object->GetCache();
      deform_cache = cache->GetDeformCache();
      After that i clone deform_cache and use InsertObject to add it to the document.
      For primitives it works, but for clones it doesn't (GetDeformCache returns NULL).
      3) How can i get the deform cache without using Hierarchy class ?

      My purpose is to polygonize the whole scene. 
      4) Which is the best way to do it ?
      Sorry if I am asking something obvious but my knowledge and experience in C4D C++ SDK is limited.

      Thank you for your time.

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

        On 02/12/2015 at 15:50, xxxxxxxx wrote:

        1. Use CURRENTSTATETOOBJECT (CSTO) ALWAYS!!!!
        2. Use it at each root object.
        3. You will end up (still) with a hierarchy in many cases.  Your best recourse is to study the documentation on the process, experiment on the results that best match your expectations, and work your solutions to match those.  To the point, when using CSTO you may still end up with a hierarchy of Null objects and results (Polygon mesh object/Spline objects/etc.).
        4. Implementing a renderer, I sincerely hope that you are using a copy of the scene/document.  Then you can have some leverage in manipulation.  Never alter the original scene/document.
        5.  BaseDocument:Polygonize() returns a polygonized representation of the entire scene/document.

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

          On 03/12/2015 at 00:05, xxxxxxxx wrote:

          Hello.

          First of all thank you for your response.
          The reason why i don't currentstatetoobject is because it doesn't handle properly the render instances.

          Example:
          Array (render instance ON)
              Cube

          If i use CSTO on the array, it will produce only the first cube as polygon, while with Make Editable command on the cube and then on the Array, i will get :

          Null
               Cube as Polygon
               Instance1
               Instance2
               Instance3
               Instance4
               ...etc...

          which I think is the correct result.

          Thank you.

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

            On 03/12/2015 at 01:18, xxxxxxxx wrote:

            Hello,

            please notice that the cache returned by GetCache() or GetDeformCache() does not necessarily contain only polygon objects. It can also contain generator objects with their own cache. You would have to browse trough the hierarchy of the cache objects to get all polygon data. This is shown in the documentation of GetCache().

            Best wishes,
            Sebastian

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

              On 05/12/2015 at 00:27, xxxxxxxx wrote:

              Hello !

              Isn't it necessary to build the cache prior of getting it (via GetCache and GetDeformCache).
              If any object (e.g. hair) doesn't have built cache, how do i build it for a specific frame ?

              Thank you.

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

                On 07/12/2015 at 02:22, xxxxxxxx wrote:

                Hello,

                if you want to make sure the scene is build you can call ExecutePasses() on the given document.

                Best wishes,
                Sebastian

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