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

    CustomDataType animation via Motion Systems

    SDK Help
    0
    2
    214
    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 24/04/2014 at 05:58, xxxxxxxx wrote:

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

      ---------
      Hi everyone!

      I am trying to create a custom data type plugin, then animate it using the Motion Systems of c4d. Naturally, there's an actual data structure, really dumb, and the actual plugin, which inherits from CustomDataTypeClass. I'll dump the source code here, stripped to a minimum: :

      struct MyCustomDataType : public CustomDataType {
          MyCustomDataType ( void ) : modeling(0), runtime(0) {}
          ~MyCustomDataType() {}
          LONG modeling, runtime;
      };
      class MyCustomDataTypePlugin : public CustomDataTypeClass {
      public:
          virtual CustomDataType*	AllocData() ;
          virtual void FreeData(CustomDataType *data) ;
          virtual Bool CopyData(const CustomDataType *src,CustomDataType *dest,AliasTrans *aliastrans) ;
          virtual LONG Compare(const CustomDataType *d1,const CustomDataType *d2) ;
          virtual Bool WriteData(const CustomDataType *d,HyperFile *hf) ;
          virtual Bool ReadData(CustomDataType *d,HyperFile *hf,LONG level) ;
          virtual const CHAR *GetResourceSym() ;
          virtual Bool InterpolateKeys(GeData &res, const GeData &t_data1,const GeData &t_data2,Real mix,LONG flags) {
              const MyCustomDataType  *d1(static_cast<const MyCustomDataType*>(t_data1.GetCustomDataType(GetId()))), 
                                      *d2(static_cast<const MyCustomDataType*>(t_data2.GetCustomDataType(GetId())));
              MyCustomDataType resulting;
              if ( !d1 || !d2 ) return FALSE;
              resulting.runtime = d2->modeling * mix + d1->modeling * ( 1.0 - mix ); 
              resulting.modeling = d1->modeling;
              res.SetCustomDataType(GetId(), resulting);
              return CustomDataTypeClass::InterpolateKeys(res, t_data1,t_data2, mix, flags) || TRUE; 
          }
      };
      

      On demand, I will provide more context. There's also a custom gui used with this datatype, and an object plugin which uses the data type.

      So, animating an attribute of this type using simple key frame animations works as a charm. Add some keyframes, then change the current frame, values are updated just fine. The trouble begins only when I try to convert the animation to a Motion System. My first guess was that I had to implement another interface of the CustomDataTypeClass, so to find out which one, I traced all of them. Only the methods from my code sample are ever called, so it doesn't look like this is the reason.

      The next step was to trace the  MSG_DESCRIPTION_POSTSETPARAMETER Message on my custom object. I found out that my attribute value is updated when moving the frame slider, but not on the object I have in my scene. Instead, on some copy of it, which can be seen in the Animation Timeline dialog. I tried the same with a simple LONG attribute. The same thing happens. The values is first updated on a copy of the object, then copied to the actual object. With my custom data type, the value is updated on the copy, but never copied to the actual object.

      Any hints that could help me track it down are very welcome, and if my explanation makes no sense at all, please ask! 🙂

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

        On 29/04/2014 at 01:13, xxxxxxxx wrote:

        I'm afraid this can't work. The motion system only works for Float/Int and PLA tracks.

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