Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    use existing Catmull Clark algorithm

    Cinema 4D SDK
    python c++ 2024
    4
    14
    2.3k
    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.
    • bacaB
      baca @CJtheTiger
      last edited by

      Hi @CJtheTiger ,

      Just build / rebuild your base shape and then apply Subdivide command.
      And then continue with subdivided geo, to adjust it's look.

      There's some logic how new points are added during subdivision.
      But I'm not it sure if it's good idea to create a square mesh, subdivide it and then remap to your circle somehow.

      As an example I started from 4-side disc, and applied subdivision command onto it five times. And the only issue is left — is to maintain boundary size and circular shape.
      hyper_nurbs.gif

      CJtheTigerC 2 Replies Last reply Reply Quote 0
      • CJtheTigerC
        CJtheTiger @baca
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • CJtheTigerC
          CJtheTiger @baca
          last edited by

          @baca thanks for your suggestion.

          And the only issue is left — is to maintain boundary size and circular shape.

          Both of these issues are the reason why I want to create the points myself. The radius needs to be exact, and the circle needs to be as perfect as possible.

          I created a Python script for a Python Generator that creates this:

          9b4269f6-48b6-4e1a-86ea-0ec5bcbbc564-grafik.png

          And subdividing that has the same result.

          https://github.com/YoYoFreakCJ/C4D-NestedSquarePythonGenerator

          3f9702e6-90db-4b81-9ffc-0d9012700ece-283571962-90f18634-b877-48ff-a2e6-e0d48cfca000.png

          I could do a loop selection around the outer loop and apply the fit circle command but that's hacky as hell.

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @CJtheTiger
            last edited by

            Hi @CJtheTiger,

            When you must build upon the subdivision, insert modelling steps after it, you can use SMC when build the cache of your object. But I would always try to avoid that when possible and instead use an Osds instead in your cache wrapping around your output.

            I would not recommend reimplanting the SDS, because at the end of the day, they are not that trivial to implement. Using SMC should be fairly performant here, since you do not have to clone any inputs as you construct the input yourself.

            I am not sure if I understand the rest of the discussion correctly, but when you want a better circle approximation using cubic interpolation/SDS, you just need more control points, which then leads to more complex geometry when you want a nice topology and no quads. When you do want to deal with terminating quad loops in the center, you could also just cylindrically distort a plane, do what I did here:

            dc8f1c53-bcd2-41ac-98ba-29da1d5f35e5-image.png

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • CJtheTigerC
              CJtheTiger
              last edited by

              To close this topic up:
              No, it is not possible to use the existing Catmull Clark algorithm, I'd have to implement it myself.

              ferdinandF 1 Reply Last reply Reply Quote 0
              • ferdinandF
                ferdinand @CJtheTiger
                last edited by ferdinand

                Hey @CJtheTiger,

                I am glad that you found your solution. But your conclusion is not correct. I know that there sometimes can be subjective truths, but I also must keep future readers in mind which might jump right to the end of a thread to look at its outcome; and which then might be led astray by your conclusion.

                Our SDS are exposed, I even provided a code example above. And while you are of course free to reimplement things, it is not recommended to do so, as you then lose all the general features of our modeling core such as UV-handling and mnemonization and the subdivision specific features such as edge weighting.

                Cheers,
                Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

                CJtheTigerC 1 Reply Last reply Reply Quote 0
                • CJtheTigerC
                  CJtheTiger @ferdinand
                  last edited by

                  Hi @ferdinand,
                  sorry I did not mean to spread misinformation. However since I specifically asked to not use an SDS and not invoke the message pipeline this post aimed to clarify whether it's possible to reference the actual class or methods to execute the algorithm which from what I gathered in this post is not possible. Correct me if I'm wrong.
                  Sorry again.
                  Cheers,
                  CJ

                  ferdinandF 1 Reply Last reply Reply Quote 0
                  • ferdinandF
                    ferdinand @CJtheTiger
                    last edited by ferdinand

                    Hey @CJtheTiger,

                    No need to be sorry. Well, SendModellingCommand (SMC) is not a message or part of the message stream. It is just an abstraction around calling functions/commands. So instead of calling foo(1, 2, 3) you call command(ID_FOO, (1, 2, 3) which then calls foo for you. There is also no do_catmull_clark() function in our code base which could be called. There is the subdivision command which also includes SDS routines. In the backend this is also all part of the new modeling core which does fancy things like mnemonization for you which is important for performance (a user has 100 instances of your plugin with the same settings and just pays the price of one without and explicit instance objects).

                    SMC can sometimes be disadvantageous when the inputs are already part of an active document and oneself is bound to threading restrictions (think of a polygon object input for some generator object). When you then want SMC such input, you cannot do that because that would be a threading violation. So, you must copy the data into a dummy document to do your computations there. Which is not only expensive but can also get tricky when one then must evaluate the dependencies of that input (or do brutish things like clone the whole document).

                    But this does not apply in your case here since you own your input. The threading restrictions are also not a problem unique to SMC and also apply to calling functions. Calling SMC with MCOMMAND_SUBDIVIDE is calling our SDS function.

                    Cheers,
                    Ferdinand

                    MAXON SDK Specialist
                    developers.maxon.net

                    CJtheTigerC 1 Reply Last reply Reply Quote 1
                    • CJtheTigerC
                      CJtheTiger @ferdinand
                      last edited by

                      Good morning @ferdinand,

                      thanks for clearing things up. This made it click for me:

                      SendModellingCommand (SMC) is not a message or part of the message stream. It is just an abstraction around calling functions/commands. So instead of calling foo(1, 2, 3) you call command(ID_FOO, (1, 2, 3) which then calls foo for you.

                      I was under the assumption that SMC invokes the messaging pipeline.

                      It's great getting all of these insights. Thank you so much!

                      If I could I'd mark your last response as the answer but unfortunately it seems like this is not a thing anymore in the new forums?

                      Have a nice day,
                      Daniel

                      ferdinandF 1 Reply Last reply Reply Quote 0
                      • ferdinandF
                        ferdinand @CJtheTiger
                        last edited by ferdinand

                        Hey @CJtheTiger,

                        yes, we disabled Ask as question because it was a lot of extra work for us to maintain because 60%-80% of users set their topics never as solved.

                        Cheers,
                        Ferdinand

                        MAXON SDK Specialist
                        developers.maxon.net

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