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

    How does C4D calculate pos of selected objects?

    SDK Help
    0
    11
    970
    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 17/06/2015 at 10:29, xxxxxxxx wrote:

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

      ---------
      Hi,

      I was looking for a way to access the position of multiple selected objects, but I couldn't find any method for that. Is there one?

      Because I didn't find one, I tried to make one myself.
      BUT... I don't know how C4D calculates the position of multiple selected objects.
      I did some calculations, but they all seem to be wrong.
      I've searched the internet for an hour, but didn't find anything relevant.

      Could somebody tell me how C4D does this?

      Thanks in advance for your help and time!
      With kind regards,

      Casimir Smets

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

        On 17/06/2015 at 11:15, xxxxxxxx wrote:

        Should simply be the centroid of all of their positions.  Loop through all of the selected lights, get their positions (you may need to consider global vs. local - global is recommended), sum the position vectors (sum += pos), and after the loop divide the vector (sum) by the number of lights.

        PseudoCode:

        Vector sum = Vector(0.0);
        Int32 nlights = number of selected lights;
        for (All selected lights)
        {
        	sum += light->GetMg().off;
        }
        // This will be the centroid between the light positions
        sum = sum / nlights;
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 17/06/2015 at 12:34, xxxxxxxx wrote:

          Hi Robert!

          Well, I think C4D does it another way.
          With 2 objects it works fine, but as soon as there are more, it tends to give problems.

          Still thanks for your answer!

          With kind regards,
          Casimir Smets

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

            On 17/06/2015 at 12:43, xxxxxxxx wrote:

            Let me run some tests on my end and get back with results and code. 🙂

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

              On 17/06/2015 at 12:56, xxxxxxxx wrote:

              AFAIK it's the bounding box of the selected objects' axes.

              MinMax mm;
              for (All selected lights)
              {
                  mm.AddPoint(light->GetMg().off);
              }
              Vector min = mm.GetMin();  
              Vector max = mm.GetMax();
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 17/06/2015 at 14:53, xxxxxxxx wrote:

                Hi Niklas!

                Thanks for your answer!! 🙂

                That did it, apparentally that's the way C4D handles multi-selection of objects.

                (You can mark this as solved)

                With kind regards,
                Casimir Smets

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

                  On 18/06/2015 at 06:22, xxxxxxxx wrote:

                  Hello,

                  to get the axis of a multi-selection one can use BaseDocument::GetHelperAxis().

                  Best wishes,
                  Sebastian

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

                    On 18/06/2015 at 06:32, xxxxxxxx wrote:

                    Hi Sebastian,

                    Thanks for your answer!!
                    GetHelperAxis is faster than the solution Niklas gave me.

                    You can mark this as solved!
                    With kind regards,
                    Casimir Smets

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

                      On 18/06/2015 at 11:01, xxxxxxxx wrote:

                      Hi,

                      Is there also such a function as GetHelperAxis for point/edge/polygon selection?
                      And what about pointselections from multiple objects? Or should I do this manually if I want to support that? (Because C4D doesn't seem to calculate that position...)

                      Thanks in advance for your help and time!
                      Greetings,
                      Casimir Smets

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

                        On 19/06/2015 at 02:03, xxxxxxxx wrote:

                        Hello,

                        point selections on multiple (polygon) objects seem to work fine with GetHelperAxis(). You answered your other question already in your other thread:

                        • How to get Modeling Axis?

                        best wishes,
                        Sebastian

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

                          On 19/06/2015 at 06:18, xxxxxxxx wrote:

                          Hi Sebastian,

                          Thanks for your answer!!
                          That indeed also works for multi-object pointselections.

                          You can mark this as solved!

                          With kind regards,
                          Casimir Smets

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