EffectorData: Set Fracture Object Clone Weight?



  • On 09/02/2015 at 21:27, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R16 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hello Forum,

    I am having trouble setting the weight values of Fracture object clones with an EffectorData plugin.  The plugin is able to set the weights of Cloner clones and Matrix matrices.  It is also able to set the matrix of Fracture clones.

    Here is the relevant code:

    // effectordatatest.cpp
      
    #include "c4d.h"
    #include "c4d_baseeffectordata.h"
    #include "oeffectordatatest.h"
      
    class EffectorDataTest : public EffectorData
    {
    public:
        virtual Bool InitEffector( GeListNode* node );
        virtual void ModifyPoints( BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread );
        static NodeData* Alloc( void )
        {
            return NewObjClear( EffectorDataTest );
        }
    };
      
    Bool EffectorDataTest::InitEffector( GeListNode* node )
    {
        Bool ret = node->SetParameter( DescID( NEW_WEIGHT_VALUE ), GeData( 0.5 ), DESCFLAGS_SET_0 ) ;
        GeData d;
        node->GetParameter( DescID( NEW_WEIGHT_VALUE ), d, DESCFLAGS_GET_0 );
        GePrint( String::FloatToString( d.GetFloat() ) );
        return ret;
    }
      
    void EffectorDataTest::ModifyPoints( BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread )
    {
        // not evaluating falloff for simplicity
        Int32 md_cnt = md->GetCount();
        // put clones in a line and proove that we can set the Matrix array.
        MDArray<Matrix> md_matrix_array = md->GetMatrixArray( MODATA_MATRIX );
        Float x = 0.0;
        for( Int32 i = 0; i < md_cnt; i++ )
        {
            Matrix matrix = Matrix();
            matrix.off.x = x;
            md_matrix_array[i] = matrix;
            x += 225.0;
        }
        // Set weight value of all clones.
        // This works for Cloner and Matrix objects.
        // Does not work for Fracture objects.
        MDArray<Float> md_weight_array = md->GetRealArray( MODATA_WEIGHT );
        GeData weight_value;
        op->GetParameter( DescID( NEW_WEIGHT_VALUE ), weight_value, DESCFLAGS_GET_0 );
        for( Int32 i = 0; i < md_cnt; i++ )
        {
            md_weight_array[i] = weight_value.GetFloat();
        }
    }
      
    #define PID_EFFECTORDATATEST 1034621 // unique from plugincafe.com
      
    Bool RegisterEffectorDataTest( void )
    {
        return RegisterEffectorPlugin( PID_EFFECTORDATATEST, "EffectorData Test", OBJECT_CALL_ADDEXECUTION, EffectorDataTest::Alloc, "Oeffectordatatest", nullptr, 0 );
    }
    

    Here is a link to download the Visual Studio project and a scene file for quick testing:
    https://s3-us-west-1.amazonaws.com/jbplugincafeimageuploads/020915/plugincafe_effectordatatest_020915.zip

    The scene file should demonstrate my situation.

    The built in MoGraph effectors can set the weight values of a Fracture object clones.  How can I set the weight value of Fracture object clones with an EffectorData plugin?

    Thank you,

    Joe Buck



  • On 13/02/2015 at 10:41, xxxxxxxx wrote:

    Hi Joe,

    time is running through my fingers. I just wanted to let you know, I'm working on your issue. I just need more time... 😕



  • On 13/02/2015 at 11:26, xxxxxxxx wrote:

    Hi Andreas,

    No need to rush on this one.

    Here is some more info that I have discovered that might help in troubleshooting:

    Add a Plane Effector to the scene.
    Make the Plane Effector's "Weight Transform" value 100%.
    Add it to the top of the Fracture Objects effector stack and make sure the effectordatatest effector is below.
    Now the effectordatattest effector has control over clone weights.

    Here is a link to a scene file that demonstrates and the plugin folder with the debug compiled plugin:
    https://s3-us-west-1.amazonaws.com/jbplugincafeimageuploads/021315/plugincafe_effectordatatest_021315.zip

    Thanks for the update.

    Joe Buck



  • On 13/02/2015 at 14:26, xxxxxxxx wrote:

    Hi Joe,

    thanks for the additional input. That's an interesting finding.


Log in to reply