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
    • Recent
    • Tags
    • Users
    • Login

    Execute once per frame

    Scheduled Pinned Locked Moved SDK Help
    9 Posts 0 Posters 674 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 20/05/2011 at 08:29, xxxxxxxx wrote:

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

      ---------
      I don't like asking silly questions here, but I've been puzzling over this for two days and still can't figure it out, so here goes.

      I'm writing an ObjectData plugin. I want an action to be carried out once per frame - just once, on each frame. I tried using GetVirtualObjects (it's a generator plugin) but that seems to be called multiple times per frame, which is no good.

      Am I: a) missing something obvious, b) trying to force Cinema to work in a way it's not supposed to, or c) just thick as a plank?

      Can anyone offer any hints on what I should be doing?

      Many thanks,

      Steve

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 20/05/2011 at 09:17, xxxxxxxx wrote:

        I don't know if you missed something obvious, because I don't program in C++.
        But if a is not the point, then you may try this (pseudo)code

        class Object() {  
          bool lastTimeExecuted;  
          //and everything else  
        }  
        Object::GetVirtualObjects(doc, op, etc) {  
          time                    = doc->GetTime()->GetSecond();  
          if (time != this.lastTimeExecuted) {  
              //Do your stuff  
          }  
          this.lastTimeExecuted   = time;  
          return EXECUTIONRESULT_OK;  
        }
        

        Cheers, Niklas

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 20/05/2011 at 09:57, xxxxxxxx wrote:

          I wouldn't use GetSecond() as you may be processing 30 fps (where s = Second).  Use doc->GetTime()->GetFrame(doc->GetFps()) instead.

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 21/05/2011 at 02:53, xxxxxxxx wrote:

            Thanks guys, that works perfectly.

            See, it was option c) after all 😞

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 21/05/2011 at 10:19, xxxxxxxx wrote:

              Np 🙂

              Robert, I do not understand what you mean. Comparing Integers may
              be more safe, but why wouldn't comparing the seconds won't work if the Framerate is 30 ?

              Cheers, Niklas

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 21/05/2011 at 11:48, xxxxxxxx wrote:

                He wants to check once per frame.  If he used seconds then he would only be checking once per every 30 frames instead.

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 21/05/2011 at 12:06, xxxxxxxx wrote:

                  Uhm... Since when does GetSecond only return the Second as an Integer ?

                  Frame 15 with 30 Fps would return 0.5 and not 0. That's my experience using GetSecond(); (Coffee) or Get() (Python).

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 21/05/2011 at 13:44, xxxxxxxx wrote:

                    I wouldn't trust comparing floating point numbers when integer representation is available though.  Floating point is not an exact representation and is subject to drift and error (such as 1.0 sometimes ending up as 0.999999999999999).  Integers are exact and will never fail in comparison - and they are significantly faster in comparisons.  That's all I'm saying.

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 22/05/2011 at 00:17, xxxxxxxx wrote:

                      Ah Ok, of course.
                      You are right.

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