Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    function on frame change

    SDK Help
    0
    20
    2.1k
    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 22/08/2014 at 18:27, xxxxxxxx wrote:

      there are some things that i don't understand.

      1. if i override the execute funtion nothing happen.. cinema don't call it. i also overrided the addtoexecution but cinema don't call it neither.

      2. if i check the frame changes in the GVO all is fine (in the viewport).. the structure is this:
      the frame is changed? yes, modify and return obj.
      No, return obj as is

      so the system can cal it whenever he want  but it will modify the object only when the frame change.

      3. the pictures viewer ignore all the data changed by the users and the time value from doc->GetTime().Get() he render always the frame 0. all the data are stored in a basecontainer exept 3 pointers.

      whats wrong? thank you all for all by the way

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

        On 27/08/2014 at 13:25, xxxxxxxx wrote:

        someone please! i can't really make the Execute() method work.. i don't know how to make cinema call it. the picture viewer don't see any changes to the data in the base container and i have another problem.. when i disable the object and then re-enable it cinema crash. it might be because i have some array as member variable? here some code:

        HEADER:

        class sea : public ObjectData
        {
          INSTANCEOF(Sea, ObjectData);

        public:
          Vector* grid;
          waveD* wave;
          String* debug = NewObj(String);
          PolygonObject* obj;
          BaseContainer* data;

        void Updatesea();
          void Buildwavedata();
          void Buildgeo();

        Bool Init(GeListNode* node);
          virtual void Free(GeListNode* node);

        virtual BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp *hh);
          static NodeData* Alloc(void) { return NewObjClear(sea); }
        };

        INIT method

        Bool sea::Init(GeListNode* node)
        {
          BaseObject* op = (BaseObject* )node;
          data = op->GetDataInstance();
          if (!data)
              return false;
          data->SetInt32(RES, 150);
          data->SetInt32(ANGLE, 89);
          data->SetFloat(FREQ_MIN, 0.02);
          data->SetFloat(FREQ_MAX, 20);
          data->SetFloat(DIRECTION, 0);
          data->SetFloat(DIR_TOLLERANCE, 90);
          data->SetFloat(STATE, 1);
          data->SetFloat(Q, 4);
          data->SetInt32(WAVE_NUM, 100);
          obj = PolygonObject::Alloc(pcount(), polycount());
          grid = NewMem(Vector, pcount());
          Buildwavedata();
          Buildgeo();
          Updatesea();
          return true;
        }

        GVO method

        BaseObject* sea::GetVirtualObjects(BaseObject* op, HierarchyHelp *hh)
        {
          BaseDocument* doc = GetActiveDocument();
          Int32 oldFrame = data->GetInt32(FRAME);
          Int32 fps = doc->GetFps();
          Int32 curFrame = doc->GetTime().GetFrame(fps);

        if (oldFrame != curFrame)
          {
              clock_t startTime = clock();

        Updatesea();

        Float elaps = Float(clock() - startTime) / (Float)CLOCKS_PER_SEC;
              GePrint(debug->FloatToString(elaps));

        data->SetInt32(FRAME, curFrame);

        }

        return obj;
        }

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

          On 27/08/2014 at 21:30, xxxxxxxx wrote:

          Try this:

          1. I think you need to get the document using hh to get the current frame to update:

          BaseDocument *doc = hh->GetDocument();
          

          2. Define the curFrame and oldFrame as class level variables.
          In GVO, update the curFrame as such:

          curFrame  = doc->GetTime().GetFrame(doc->GetFps());   
          data->SetInt32(FRAME, curFrame);
          oldFrame = curFrame;
          

          This will animate the document.

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

            On 28/08/2014 at 04:28, xxxxxxxx wrote:

            Howdy,

            Originally posted by xxxxxxxx

            ...someone please! i can't really make the Execute() method work.. i don't know how to make cinema call it...

            The Execute() function of an ObjectData() is not called by default by Cinema 4D. You have to use the AddToExecution() function to tell Cinema 4D to call the Execute() function.

            Bool MyObject::AddToExecution(BaseObject *op, PriorityLIst *list)
            {
            	list->Add(op, EXECUTIONPRIORITY_EXPRESSION, EXECUTIONFLAGS_0);
            	return true;
            }
            

            Adios,
            Cactus Dan

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

              On 29/08/2014 at 07:05, xxxxxxxx wrote:

              Howdy,_<_t_>_
              Originally posted by aerydna

              ...someone please! i can't really make the Execute() method work.. i don't know how to make cinema call it... _/tr>
              The Execute() function of an ObjectData() is not called by default by Cinema 4D. You have to use the AddToExecution() function to tell Cinema 4D to call the Execute() function.
              _h="99%">|

              Bool MyObject::AddToExecution(BaseObject \*op, PriorityLIst \*list)
              
              {
              
              	list->Add(op, EXECUTIONPRIORITY_EXPRESSION, EXECUTIONFLAGS_0);
              
              	return true;
              
              }
              
              <\_<\_t\_>\_>  
              ---  
                
                
              
              
              Adios,
              
              Cactus Dan
              
              
              
              
               \_<\_t\_>\_div>  
                
                
              as i wrote a couple of message ago.. i tried that way using different flag and priority and nothing happened.  thankyou anyway  
               
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 29/08/2014 at 07:06, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                Try this:

                1. I think you need to get the document using hh to get the current frame to update:

                BaseDocument *doc = hh->GetDocument();
                

                2. Define the curFrame and oldFrame as class level variables.
                In GVO, update the curFrame as such:

                curFrame  = doc->GetTime().GetFrame(doc->GetFps());   
                data->SetInt32(FRAME, curFrame);
                oldFrame = curFrame;
                

                This will animate the document.

                thank you i'll try it

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

                  On 29/08/2014 at 07:07, xxxxxxxx wrote:

                  Howdy,

                  Well, then you must've done something wrong in your code. Can you post the code you used?

                  Adios,
                  Cactus Dan

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

                    On 29/08/2014 at 13:36, xxxxxxxx wrote:

                    Originally posted by xxxxxxxx

                    Howdy,

                    Well, then you must've done something wrong in your code. Can you post the code you used?

                    Adios,
                    Cactus Dan

                    Bool sea::AddToExecution(BaseObject* op, PriorityList* list)
                    {
                      list->Add(op, EXECUTIONPRIORITY_ANIMATION, EXECUTIONFLAGS_0);
                      return true;
                    }

                    EXECUTIONRESULT sea::Execute(BaseObject* op, BaseDocument* doc, BaseThread* bt, Int32 priority, EXECUTIONFLAGS flags)
                    {
                      GePrint("ciao");
                      return EXECUTIONRESULT_OK;
                    }

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

                      On 30/08/2014 at 04:28, xxxxxxxx wrote:

                      In the function registering the plugin you also have to set the OBJECT_CALLADDEXECUTION flag so that AddToExecution() is called.

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

                        On 31/08/2014 at 05:31, xxxxxxxx wrote:

                        Howdy,

                        Originally posted by xxxxxxxx

                        In the function registering the plugin you also have to set the OBJECT_CALLADDEXECUTION flag so that AddToExecution() is called.

                        Yep, that would certainly explain why it wasn't working for you. 😉

                        Adios,
                        Cactus Dan

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