Deforming objects [SOLVED]
-
On 06/12/2016 at 19:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 18
Platform: Mac ; Mac OSX ;
Language(s) : C++ ;---------
Is there some way to know if an object has changed between frames i.e.: it has deformed? The way we're currently handling this is to create a hash based on a RayObject's padr and pcnt member variables. If the hash for the object for the current frame is different than the previous, then we re-evaluate the object.However, it seems that just key-framing something like the object's P.x coordinates causes the hash to be different between frames, even thought the object itself isn't actually changing (just moving in space). Is there something better we could do?
Thanks,
Ian -
On 07/12/2016 at 06:28, xxxxxxxx wrote:
Hi Ian, thanks for writing us.
With reference to your question, please consider that the points accessed through the RayObject are actually stored in world space which means that even transforming the object using an affine matrix (like translation) will result in a new hash.
Under this scenario, you could transform the points from world to local coordinates by using the mg_inverse data member provided for convenience with the RayObject and then compute the hashing on the local points array or alternative, you can get to the related BaseObject via the link member and, from there, properly accessing the points vector belonging to the object cache or deformed cache compute your hash.
Another alternative is available through the VolumeData class which provides for such a purpose the TranslatePolygon() method which, once provided with a RayObject, the local index of the polygon and a pointer to an array of 4 Vectors, returns the position of the points related to that polygon in the previous frame thus giving you some means to check if the polygon has been deformed between the current and previous frame.Hoping any of the above alternatives helps you to gets properly advised about object deformation feel free to ask if anything is unclear.
Best, Riccardo
-
On 07/12/2016 at 09:22, xxxxxxxx wrote:
Hi Riccardo,
Using the link member and accessing the point vector from there seems to be working for us, so thanks for that suggestion!
Just in case we need to use it, for the TranslatePolygon() suggestion, what's the second parameter (local_ index) referring to?
Thanks!
Ian -
On 15/12/2016 at 02:13, xxxxxxxx wrote:
Good morning Ian, glad to hear it worked out for you and I also apologize for the long delay in getting back here.
The local_index parameter is the index of the polygon you want to process to check if it changes its space position from the current frame to the previous one.
Best, R