get mograph matrix clones final matrix

  • On 17/04/2018 at 01:47, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   16+ 
    Language(s) :     C++  ;

    here is what I do to get the matrices of the particles in matrix object.

    BaseTag *mographTag = op->GetTag(ID_MOTAGDATA);
    if (mographTag != nullptr)
        GetMoDataMessage moMsg;
        mographTag->Message(MSG_GET_MODATA, &moMsg);
        if (moMsg.modata != nullptr)
            Int32 particleCount = moMsg.modata->GetCount();  
            MDArray<Matrix> mdmat = moMsg.modata->GetMatrixArray(MODATA_MATRIX);

    the problem: the matrices don't take into account any deformers affecting the matrix object particles.
    and getting the GetDeformCache() returns a polygon object (cube for example) at the required location it is kinda overkill, and I don't know how to extract the data from a single poly object!! (don't tell me to quantize the point count and divide then send it as multiple separate objects, this is a bad design).

    that cube object can be 27 cubes in 1 polygon object, its matrices are wrong (but the points local position matches the position of the matrix object particles), yet it is overkill as I mentioned before (to extract a matrix from 8 points... (this is only if I know they are cubes, what if they are spheres or any other shape..).

  • On 19/04/2018 at 14:24, xxxxxxxx wrote:

    Hi Mohamed, thanks for writing us.

    With regard to your request, please consider that the data retrieved through MoData::GetMatrixArray(MODATA_MATRIX) retains only PSR information whilst any deformation applied to the instanced object can't be stored there since almost all the applicable deformations can't actually be described by a matrix (scale, shear, rotation and their combinations represent just an exception).

    On top of this I see your frustration because accessing the MoGraph generator's cache via   BaseObject::GetDeformCache() results in having the geometrical data for all the clones of the generator which is, as you said, "overkill".
    As workaround I suggest to use a "Cloner" object referring to your deformed object and use it as child of the MoGraph generator of your choice. By doing this you can easily retrieve the shape of the "original" deformed object an decouple this information from the position of the clones generated by the MoGraph generator.

    Hope this few hints can pave the way to a usable solution, give best.

  • On 19/04/2018 at 17:44, xxxxxxxx wrote:

    well this is not a real solution.
    this is a render engine, how does Cinema4D viewport got these data (the final matrix result), it must be stored somewhere as they draw on the fly (not recalculated every time with a cloner object).
    and Matrix object in general is so fast due to the "no geometry" part, why should I use Cloner object and lose the only advantage of Matrix object?
    there should be a way to get this data, it must be fast as it is in real time preview for the renderer and inserting a Cloner object in complex hierarchy will blow up performance.

Log in to reply