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

    BaseDraw scale

    Cinema 4D SDK
    r19 r20 r21 c++
    2
    3
    509
    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.
    • rsodreR
      rsodre
      last edited by rsodre

      Hello,

      Drawing my BaseObject gizmos on the viewport with BaseDraw, using it's matrix, the drawn elements are also drawn in the same scale of the matrix. This looks very weird on my objects, I prefer them to be unscaled. Is there something I can do besides altering each drawn coordinate?

      This is how I'm setting the matrix:

      bd->SetMatrix_Matrix( op, op->GetMg() );
      

      Multiplying the matrix by the inverse scale matrix will not work, the drawn elements will be unscaled but in the wrong position.

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by r_gigante

        Hi @rsodre thanks for reaching out us.

        With regard to your question I think you have to separate from the global transformation matrix the scaling part and create an inverted scale transformation matrix to compose with your gizmos's transformation matrix to get rid of the scale.

        ...
                // given a generic BaseObject get its global transformation 
        	const maxon::Matrix fullTransformation = obj->GetMg();
        	const maxon::Vec3<maxon::Float> scaleVector = fullTransformation.sqmat.GetScale();
        	const maxon::Vec3<maxon::Float> inverseScaleVector = maxon::Vec3<maxon::Float>(1/scaleVector[0], 1/scaleVector[1], 1/scaleVector[2]);
        	const maxon::Matrix inverseScaleTransformation (maxon::Vec3<maxon::Float>(0, 0, 0), maxon::GetScaleMatrix(inverseScaleVector));
        
                // use this inverse-scale transformation to compensate gizmo scale
        ...
        
        

        Let me know if it works as expected.
        Cheers,

        rsodreR 1 Reply Last reply Reply Quote 1
        • rsodreR
          rsodre @r_gigante
          last edited by

          @r_gigante Thanks, I used an inverse scale matrix wen calculating my gizmo points.

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