Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Get Deformed Points from Skin Deformer

    Cinema 4D SDK
    r20 python
    2
    3
    1.0k
    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.
    • B
      bentraje
      last edited by

      Hi,

      I'm trying to get the deformed points from an object with a skin deformer using this code.
      op.GetDeformCache().GetPoint(231)

      The code above is different from just the GetPoint only but it does not correspond with the world position.

      You can see the illustration of the problem here:
      https://www.dropbox.com/s/kwy0cf7y2sfoubm/c4d098_deform_points.png?dl=0

      There are existing threads, but for some reason, the answers are not conclusive:
      https://developers.maxon.net/forum/topic/6566/7105_world-coord-of-points-of-deformed-object
      https://developers.maxon.net/forum/topic/9041/11999_getting-deformed-points

      Is there a way around this?

      Thank you for looking at my problem

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hello,

        The points are stored in a local space (local coordinates). To get the global space (world coordinates) you have to multiply by the object's matrix.

        there's an example in c++

        To go from global to local, just multiply by the invert matrix

            #Retrieves the active Object
            node = doc.GetActiveObject()
            
            if node == None:
                raise ValueError ("there's no object selected")
            
            #Retrieves the deformed cache
            cache = node.GetDeformCache()
            if cache == None:
                raise ValueError("no cache found")
            
            #Retrieves All points    
            points = cache.GetAllPoints()
            
            #Retrieves the object Matrix to go from Object to world coordinates(local to global)
            opMg = node.GetMg()
            # Prints out points in local coordinates.
            print points
            
            # Transforms points to global coordinates
            points = [p * opMg for p in points]
            
            # Prints points in global coordinates.
            print points
            
            # Global to local
            # Retrieves the inverse Matrix of the object with ~
            invOpMg = ~opMg
            # Multiplies each point by the inverse matrix
            points = [p * invOpMg for p in points]
        
            print points
          
        

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • B
          bentraje
          last edited by bentraje

          @m_magalhaes

          Thank you for the explanation:
          "The points are stored in a local space (local coordinates)."

          Printing the three version of points space was really helpful

          The code works as expected! 🙂

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