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

    How to get position and rotation in softbody simulation

    Cinema 4D SDK
    2023 windows python
    2
    2
    470
    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.
    • C
      Christian 0
      last edited by

      Hello,

      I'm currently working on a project in Cinema 4D Python. I'm trying to get the change in position and rotation when I make a softbody simulation. For example, when I try to let a object fall to the ground, I would like to get the new position and rotation at the end of the simulation. I tried the GetMg() function but it always returns the same value. Here is my code:

      import c4d
      
      doc: c4d.documents.BaseDocument
      
      obj = c4d.BaseObject(c4d.Osphere)
      obj[c4d.ID_BASEOBJECT_REL_POSITION] = c4d.Vector(0,100,0)
      softbody_tag = c4d.BaseTag(c4d.Tcloth) 
      c4d.CallButton(softbody_tag, c4d.CLOTH_PBD_STRUT_SOFTBODY_UPDATE_BUTTON)
      obj.InsertTag(softbody_tag)
      doc.InsertObject(obj)
      c4d.EventAdd()
      
      for frame in range(90): 
          doc.SetTime(c4d.BaseTime(frame,doc.GetFps())) 
          doc.ExecutePasses(None, True, True, True, 0)
          c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) 
          print(obj.GetMg())
      

      Could someone please guide me on how I can accurately determine the position and rotation changes in this scenario? Any help or suggestions would be greatly appreciated.

      Thank you in advance!

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Christian 0
        last edited by ferdinand

        Hello @Christian-0,

        Thank you for reaching out to us. I am a bit confused by your question. A soft body simulation is characterized by the fact that it gives up the idea of a geometry transform with governs a geometry as usually applied in computer graphics. In the end this means that the transform of the object (BaseObject.GetMg) will not change but the points will and with it the bounding box of an object. Below you see a soft body cylinder falling. Its transform, the axis, never changes, but the bound box does. Animated are here the points, not the object, hence the term soft body.

        In the API you can get the bounding box values with BaseObject.GetMp and BaseObject.GetRad. When you want a transform, a matrix for that, you would have to compute that yourself. The matrix manual dissects how to construct matrices.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

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