Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

EffectorData: Set Fracture Object Clone Weight?

Author
Message
  Topic Search Topic Search
joebuck View Drop Down
Member
Member


Joined: 2011 Oct 26
Location: Burbank, CA
Online Status: Offline
Posts: 81
Direct Link To This Post Topic: EffectorData: Set Fracture Object Clone Weight?
    Posted: 2015 Feb 09 at 9:27pm

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:

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  

Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2015 Feb 13 at 10:41am
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... Ermm
Cheers,
Andreas
SDK Support Engineer
Back to Top
joebuck View Drop Down
Member
Member


Joined: 2011 Oct 26
Location: Burbank, CA
Online Status: Offline
Posts: 81
Direct Link To This Post Posted: 2015 Feb 13 at 11:26am
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
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2015 Feb 13 at 2:26pm
Hi Joe,

thanks for the additional input. That's an interesting finding.
Cheers,
Andreas
SDK Support Engineer
Back to Top
Donovan Keith View Drop Down
Member
Member


Joined: 2002 Oct 30
Location: United States
Online Status: Offline
Posts: 199
Direct Link To This Post Posted: 2018 Mar 01 at 6:04pm
I'm running into the same issue w/ a Python effector trying to set weights on a Fracture object. Thanks for the workaround @joebuck.
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.