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

    FPS counter code problem in R12

    Scheduled Pinned Locked Moved SDK Help
    1 Posts 0 Posters 126 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 18/03/2011 at 20:14, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R12 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      I got this coffee code from a friend that I converted to c++ for use in my plugin.  From what I understand it originally came direct from Maxon (can't find the post that confirms that atm, but I remember it clearly).

      Anyway, the code has worked perfectly in R10-R11.5... but in R12 it gets all funky on me.  In previous versions, with a document frame rate of 30fps, it'll hold steady at 29.9.  In R12 it likes to sporadically spike.  Usually up into the high 30's, but I've seen values in the 40 and even 50's, which doesn't make any sense whatsoever, given the document frame rate is 30fps.  I should also mention that this effect doesn't stabilize at all if I lower the frame rate, nor does it seem to depend on the scene itself; empty scenes and scenes full of tasty stuff that needs calculating all suffer from this.

      Here's the original coffee code:

      var gLastTime = 0;
      var oldfps    = 0;
      var lastframe = 0;
        
      main(doc,op)
      {
        var curTime = time();
        var fps = 0.5+1000.0 / (curTime-gLastTime);
        gLastTime = curTime;
        
        var average = Mix(oldfps , fps ,0.2);
        op#ID_USERDATA:1 = tostring(average,".1f");
        
        var curframe = doc->GetTime()->GetFrame(doc->GetFps());
        
        if(curframe!=lastframe) oldfps = average;
        else oldfps = oldfps;
        
        lastframe = curframe;
        
      }
      

      And my c++ conversion of that code:

      BaseTime time = doc->GetTime();
      LONG currentframe = time.GetFrame(doc->GetFps());
      LONG docFPS = doc->GetFps();
        
      //FPS Counter code
      if(CheckIsRunning(CHECKISRUNNING_ANIMATIONRUNNING)==TRUE)
      {
      	LONG cTime = GeGetTimer();
      	FPS = 0.5+1000/(cTime-lastTime);
      	lastTime = cTime;
      	Real average = Mix(oldFPS, FPS, 0.2);
      	bc->SetString(ID_HFPS,(RealToString(average, 2, 1, FALSE, 0)+"fps"));
      	if (currentframe!=lastFrame) oldFPS = average; else oldFPS = oldFPS;
      }
      lastFrame = currentframe;
      

      So, I'm curious what the problem is?  It's almost like scenes don't calculate at a consistent rate in R12.  If that is the case, it's fairly negligible... but my plugin deals in realtime animation, so it's fairly important;)  It doesn't affect the output of my plugin as far as I can tell, but it looks bad when when my fps counter stutters worse than Porky Pig;)

      thanks for any insight,
      kvb

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