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

    still question about object axis

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 371 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 14/06/2009 at 13:55, xxxxxxxx wrote:

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

      ---------
      hi there,

      i am totally struggling now.. i need to set the axis of an object to a specific value and i have absolutely no clue how to do this. not even a shade of knowledge...

      for example i want to set it to the global (0,0,0) coordinate..

      maybe someone can help me solve this? i've got the first tip here, but i must admit that i dont understand that matrix stuff good enough to use it...

      thanks in advance,
      ello

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

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

        On 14/06/2009 at 15:29, xxxxxxxx wrote:

        could it really be that it is that simple???

        > `

          
        \>  void setAxis(BaseDocument *doc, BaseObject *op, Vector pos)  
        \>  {  
        \>       Matrix m;  
        \>       Matrix tm;  
        \>       m.off = pos;  
        \>       while(op)  
        \>       {  
        \>            if (op->GetType()==Opolygon)  
        \>            {  
        \>                 tm = op->GetMl();  
        \>                 PointObject *pobj = static_cast<PointObject*>(op);  
        \>                 Vector *parr = pobj->GetPointW();  
        \>                 LONG pcnt = pobj->GetPointCount();  
        \>                 GePrint(LongToString(pcnt));  
        \>                 for(int i=0;i<pcnt;i++)  
        \>                 {  
        \>                      parr[i]*=tm;  
        \>                 }  
        \>    
        \>                 op->SetMl(m,FALSE);  
        \>            }  
        \>            setAxis(doc,op->GetDown(),pos);  
        \>            op = op->GetNext();  
        \>       }  
        \>  }  
        \>  
        

        `

        in my first tests it seems that this is it??

        thanks for checking,
        ello

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

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

          On 14/06/2009 at 15:55, xxxxxxxx wrote:

          hm, now i face another problem.. what is wrong with my code? i am trying to calculate the center of a polygonobject, but it doesnt work:

          > `

            
          \>                 Vector cpos = Vector(0);  
          \>                 PointObject *pobj = static_cast<PointObject*>(op);  
          \>                 Vector *parr = pobj->GetPointW();  
          \>                 LONG pcnt = pobj->GetPointCount();  
          \>                 if (pcnt>0)  
          \>                 {  
          \>                      for(int i=0;i<pcnt;i++)  
          \>                      {  
          \>                           cpos += parr[i];  
          \>                      }  
          \>                      cpos /= pcnt;  
          \>                 }  
          \>  
          

          `

          where's my fault?

          thanks and cheers,
          ello

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

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

            On 15/06/2009 at 13:44, xxxxxxxx wrote:

            hmm, somehow the axis is not centered correctly, nearby, but not exactly where it should be..

            > `

              
            \>  void setAxisSingleObject(BaseObject *op, Vector pos)  
            \>  {  
            \>       Matrix m;  
            \>       m.off = -pos;  
            \>       if (op->GetType()==Opolygon)  
            \>       {  
            \>            PointObject *pobj = static_cast<PointObject*>(op);  
            \>            Vector *parr = pobj->GetPointW();  
            \>            LONG pcnt = pobj->GetPointCount();  
            \>            for(int i=0;i<pcnt;i++)  
            \>            {  
            \>                 parr[i]*=m;  
            \>            }  
            \>            m.off = pos;  
            \>            op->SetMl(m,FALSE);  
            \>       }  
            \>  }  
            \>    
            \>  void centerAxis(BaseObject *op)  
            \>  {  
            \>            if (op->GetType()==Opolygon)  
            \>            {  
            \>                 Vector cpos = Vector(0);  
            \>                 PointObject *pobj = static_cast<PointObject*>(op);  
            \>                 Vector *parr = pobj->GetPointW();  
            \>                 LONG pcnt = pobj->GetPointCount();  
            \>                 if (pcnt>0)  
            \>                 {  
            \>                      for(int i=0;i<pcnt;i++)  
            \>                      {  
            \>                           cpos += parr[i];  
            \>                      }  
            \>                      cpos /= pcnt;  
            \>                      setAxisSingleObject(op, cpos+op->GetPos());  
            \>                 }  
            \>            }  
            \>  }  
            \>  
            

            `

            anyone sees where i am wrong here?

            thanks in advance.
            cheers,
            ello

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