Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    EffectorData: Set Fracture Object Clone Weight?

    SDK Help
    0
    4
    393
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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... 😕

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            Hi Joe,

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post