How to get position and rotation in softbody simulation
-
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!
-
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.