Access to the Cloth Tag Cache (stored values)?
On 27/10/2015 at 16:19, xxxxxxxx wrote:
Cinema 4D Version: 17
Platform: Windows ;
Language(s) : C++ ;
I am looking for a way to access the cache of a cloth tag programmatically. How is it stored in the tag, how can I read and write data in a cache, what is the storage format in RAM, is the data based on frames or subframes...?
Cloth simulations in C4D are prone to flickering due to small point position jumps from frame to frame (unless the simulations are very stiff to begin with). There seems to be no way to improve the calculation results through the general parameters.
However, I need to cache the simulations anyway so the Cloth Nurbs won't lag behind, so there is a handy set of point positions available.
With access to the actual cache, it should be possible to run an intelligent smoothing function over each point to even out miniscule changes that lead to flickering.
The API offers a lot of cache functionality, but that refers to either the object tree in toto, or to other object's caches - I don't find an actual access to the cloth cache.
On 28/10/2015 at 06:22, xxxxxxxx wrote:
unfortunately it is not possible to access the cache stored in a Cloth tag.
On 28/10/2015 at 06:43, xxxxxxxx wrote:
I guess what you want to achieve can be done with a deformer or generator objects "or a tag", I would prefer a tag, so you make it work only if the object got a cloth tag that has a cache, and to read the point data, just use GetCache() and GetDeformCache(), Sebastian may know better at this point.
On 28/10/2015 at 12:30, xxxxxxxx wrote:
Well, too bad. I guess I can read the point data (frame by frame) of the deformed object (?) but I could not write it back anyway, so I'd need to write my own cache AND a tag that applies it again after smoothing out...
On 29/10/2015 at 07:30, xxxxxxxx wrote:
Just for completeness' sake: It does not seem to be necessary to access the DeformCache hierarchy to get the point positions on a single object after the cloth sim ran.
I just tried a Python tag (with a priority of Generators 401 to enforce running after the Cloth dynamics) that merely uses obj.GetPoint() to read the current point position, and the result represents the point vector after deformers (joint, in this case) and cloth sim.
So, it seems to be possible to run a cloth sim, store the results in an own tag (needs to read all point positions over all frames) and then work with this self-programmed cache. After modifications, the tag needs to overwrite the actual point positions with the cached and modified ones. The trick may be to change the tag's priority dynamically so it will run earlier than the Cloth Nurbs in playback mode.
Let's see how big that project becomes...
(...and of course it's necessary to find what criteria define a point as "flickering", and how to correct the flicker...)