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

    SetSize() helper

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 219 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 28/02/2011 at 15:39, xxxxxxxx wrote:

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

      ---------
      Hey everyone..  I made this little helper function that might be useful to some people.  I use it to resize objects using real cm measurements.    Hope you find it helpful.  I know this can be done using Scaling functions but this function allows you to use real size measurements instead of scalars.  Basically it converts your real measurements into scalars which are then used to scale the object.  🙂
       
      So instead of having to know that you are scaling the original size by 2, you can change the size of a cube from 200 to 400 without having to use scalars.

        
      //This function is used to resize objects.  
        
      void SetSize(BaseObject *op, Vector size){  
        
          //Get the radius for the original size  
          Vector orig = op->GetRad();    
          //Divide the current size by the original size..  
          Vector scalar = Vector(size.x / orig.x, size.y / orig.y, size.z / orig.z);    
        
          //Declare the Matrix  
          Matrix m;  
            
          //Normalize the Matrix Vectors  
          Vector normV1 = m.v1;  
          normV1.Normalize();  
          Vector normV2 = m.v2;  
          normV2.Normalize();  
          Vector normV3 = m.v3;  
          normV3.Normalize();  
        
          //Scale the Matrix by the determined scalar  
          m.v1 = normV1 * scalar.x;  
          m.v2 = normV2 * scalar.y;  
          m.v3 = normV3 * scalar.z;  
        
          //Set the objects Matrix to the new Matrix.  
          op->SetMl(m);  
      }  
      

      BaseObject *op
      This is the object that you wish to resize.

      Vector size
      This is the vector that represents the size of the object.  For example.  If you wish to use a Vector description from the attributes manager you would do the following.

        
      BaseContainer *bc = op->GetDataInstance();  
      SetSize(op, bc->GetVector(MY_VECTOR));  
      

      Hope this helps someone.  🙂

      ~Shawn

      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 01/03/2011 at 10:08, xxxxxxxx wrote:

        LOL..  It's a little bit like having a SetRad() function.  😉

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