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 to get sphere coordinates

    Cinema 4D SDK
    s26 c++ windows
    2
    6
    1.1k
    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.
    • P
      pchg
      last edited by

      Hello colleagues, I used C++ to write the C4D S26 plugin on Windows 10, I import .abc and want to get the center point coordinates of each sphere, not the vertex coordinates

      BaseObject* obj = doc->GetActiveObject();
      PointObject* pointObj = static_cast<PointObject*>(obj);
      Int32 pointCount = pointObj->GetPointCount();		
      Vector* points = pointObj->GetPointW();
      const ::Matrix globalMtx = pointObj->GetMg();
      for (Int32 i = 0; i < pointCount; ++i)
      {
        Vector site = pointObj->GetMg() * points[i];
        GePrint("Frame " + String::IntToString(count) + ": " + String::VectorToString(site));
      }
      

      111.png
      2222.png

      1 Reply Last reply Reply Quote 0
      • P
        pchg
        last edited by

        Thanks in advance!

        i_mazlovI 1 Reply Last reply Reply Quote 0
        • i_mazlovI
          i_mazlov @pchg
          last edited by

          Hello @pchg ,

          Normally importers in cinema reflect the geometry contained in the original file, or in other words what's contained in the original scene will be in cinema in the closest possible state.

          In your case your original scene contains a single geometry that consists of multiple so-called "polygon islands". It looks to me the easiest way to proceed for you would be to first split your geometry into a list of distinct objects (spheres) and then iterate over them separately.

          You can achieve this by calling SendModelingCommand with the MCOMMAND_EXPLODESEGMENTS cmd id. The effect you need is the same as if you were to run command "Polygon Islands to Objects" from within cinema GUI.

          Please note, recently there was related discussion on this command call: c4d.MCOMMAND_EXPLODESEGMENTS makes target object dead.

          The SMC command will return a hierarchy of polygon objects to you, which you can then normally traverse (using functions GetDown() and GetNext() of BaseObject) and retrieve the transform information using related functions: BaseObject - Properties - PSR.

          Cheers,
          Ilia

          MAXON SDK Specialist
          developers.maxon.net

          P 2 Replies Last reply Reply Quote 0
          • P
            pchg @i_mazlov
            last edited by

            Thanks @i_mazlov
            I want to get the coordinate information of all spheres under this editable object

            BaseDocument* doc = GetActiveDocument();
            BaseObject* obj = doc->GetActiveObject();
            ModelingCommandData mcd;
            mcd.doc = doc;
            mcd.op = obj;
            const bool result = SendModelingCommand(MCOMMAND_EXPLODESEGMENTS, mcd);
            

            Wrong result, result = false, or whether it should be done

            const bool result = SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd);
            BaseObject* res = static_cast<BaseObject*>(mcd.result->GetIndex(0));
            while (res != nullptr)
            {
            Vector points = res ->GetAbsPos();
            res = res -> GetNext();
            }
            

            but only one coordinate

            1 Reply Last reply Reply Quote 0
            • P
              pchg @i_mazlov
              last edited by

              @i_mazlov Thanks

              BaseObject* activeObject = doc->GetActiveObject();
              if (!activeObject)
              	return break;
              ModelingCommandData mcd;
              mcd.doc = doc;
              mcd.op = activeObject;
              const bool result = SendModelingCommand(MCOMMAND_EXPLODESEGMENTS, mcd);
              if(result)
              {
              	EventAdd();
              }
              

              Although I got all the spheres, all the sphere animation was lost, What should I do?

              1 Reply Last reply Reply Quote 0
              • i_mazlovI
                i_mazlov
                last edited by

                Hi @pchg ,

                This thread is almost a full duplicate of your adjacent thread: How to preserve the animation of a sphere. The answer is provided there.

                Cheers,
                Ilia

                MAXON SDK Specialist
                developers.maxon.net

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