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
    • Recent
    • Tags
    • Users
    • Login

    Center Axis

    Scheduled Pinned Locked Moved SDK Help
    1 Posts 0 Posters 158 Views
    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 Offline
      Helper
      last edited by

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

      On 19/12/2009 at 14:07, xxxxxxxx wrote:

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

      ---------
      Hi,

      I need a little help with this. I thought I was getting it, but it just doesn't seem to be working. I'm missing something with translating the points back to where they need to go. The object moves to the bounding box center correctly.

      Matrix Mg = obj->GetMg();
      Vector globalPos = Mg.off;
      Vector bbLocal = obj->GetMp();
      Vector bbGlobal = bbLocal * Mg;

      //Move object to Bounding Box center
      Matrix newObjMg = Mg; newObjMg.off = bbGlobal;
      obj->SetMg(newObjMg , TRUE);
           
      //Move Points
      Vector trans = bbGlobal - globalPos;
           
      PointObject* pointObj = ToPoint(obj);
      if(!pointObj) return FALSE;
      LONG pointCount = pointObj->GetPointCount();
      if(pointCount == 0) return FALSE;
           
      AutoAlloc<Modeling> mod;
      if (!mod || !mod->InitObject(pointObj)) return FALSE;
           
      LONG i = 0;
      while(i < pointCount)
         {
           Vector pointPos;
           Vector* pPointPos = &pointPos;
           mod->GetPoint(obj, i, pPointPos);
           Vector newPointPos = pointPos - trans;
           mod->SetPoint(obj, i, newPointPos, MODELING_SETPOINT_FLAG_EMPTY);
                
           i++;
         }
           
      if (!mod->Commit()) return FALSE;

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