Center Axis



  • 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;


Log in to reply