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

    Rotate parent so child plane is parallel to ground

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 326 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

      On 11/04/2015 at 00:23, xxxxxxxx wrote:

      I'm trying to rotate a parent object that has a plane for a child so the child plane is parallel to the C4D ground plane.

      It isn't quite working.
      Once I have the normal of the plane, how do I rotate the parent?
      Am I rotating the parent around the center of the plane to do this?

      Code please.

      Thanks,

      Chris

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

        On 17/04/2015 at 07:41, xxxxxxxx wrote:

        Hello,

        all you need to do is to handle the matrices of the objects. When you say that the plane should be "parallel" to the ground that means that the plane should not be rotated in world space, right?

        So the world space rotation should be zero. The world space rotation of the plane is the result of the world space rotation of the parent plus the local rotation of the plane relative to the parent. So the world space rotation of the plane is zero when the world space rotation of the parent is "minus" the local rotation of the plane.

        Sine we are handling rotations as matrices there is no "minus" but you can invert the matrix with the standard Python operator "~".

        So the most simple code could look like:

          
        localPlaneMatrix = plane.GetMl()  
        op.SetMg(~localPlaneMatrix)  
          
        c4d.EventAdd()  
        

        your final code may depend on your actual situation and the complexity of your hierarchy.

        best wishes,
        Sebastian

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

          On 20/04/2015 at 13:18, xxxxxxxx wrote:

          Yeah, getting matrices down is a little confusing at first but super helpful.  Here's a helpful website for understanding/helping a bit.

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

            On 21/04/2015 at 14:57, xxxxxxxx wrote:

            Thanks Sebastian, I was missing the '~' for inverse.  Works fine.

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