Getting the Current Render Frame



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

    On 28/11/2012 at 10:08, xxxxxxxx wrote:

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

    ---------
    Hello all,

    I have a tag plugin that moves an object a distance based on the current frame, so the more frames that have passed the farther it will move.  It works fine in regular C4D with the timeline playing, but if I render it the object doesn't move.  Which makes sense since I'm going off of the timeline frame.  So my question is how would I be able to feed the current render frame into the tag so it can correctly move during a render?

    Thanks for any help!
    Dan



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

    On 28/11/2012 at 11:12, xxxxxxxx wrote:

    If you play a number of frames and stop, does the current frame render correctly in the editor? And if so, does it also render correctly in the picture viewer?

    If it doesn't render with the object in the correct position in the editor, then you must be doing something wrong when it comes to calculating the distance which the object should have travelled. If it renders correctly in the editor but not the PV then my guess is that you're using a class-level variable to keep track of the number of frames and you haven't copied this over when rendering to the PV. In that case you will need to override CopyTo() in your tag.

    Steve



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

    On 28/11/2012 at 11:20, xxxxxxxx wrote:

    Hi Steve, thanks for the reply.

    It's correcting working in those cases. Rendering a single frame isn't the problem.  It's when I want to have it render several frames that it doesn't work.  My code moves the object a direction each frame, so frame 0, it's at 0, frame 1 it's moved over to 15, and so on.  But this is just the current frame multiplied by 15.  When I render out several frames it just stays at the same position it's at in the timeline.

    So if I render frame 0-15, but when I render it I'm at frame 5, then it renders the object's position as 75 (5 *15).  Because it's keying off the timeline frame.  Is there a way to give the tag the current frame that's being rendered, so that it would correctly move?

    Dan



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

    On 28/11/2012 at 11:32, xxxxxxxx wrote:

    I'm a bit confused. If you render frames 0-15, then the object should render at position 0, 15, 30, 45, 60, 75... Isn't that correct? I must be misunderstanding what you want it to do.

    The way I would do it is get the current frame and use that value, so:

      
    // in your tag Execute() function   
    LONG fps = doc->GetFps();   
    LONG startFrame = doc->GetMinTime().GetFrame(fps);     // find start frame of document, might not be 0   
    LONG thisFrame = doc->GetTime().GetFrame(fps);   // get current frame   
    LONG elapsedFrames = thisFrame - startFrame;   
    // object position = 15 * elapsedFrames   
    

    Steve



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

    On 28/11/2012 at 11:59, xxxxxxxx wrote:

    Your correct, I'm just explaining it poorly.

    It should render at those positions, but it doesn't, it renders at the posistion for whatever frame I have selected on the timeline.  I had similar code to your's, but in the draw function, I switched it all to the Execute(), but that didn't fix it either.  I'm probably wrong, but it seems like elapsedFrames, from your example doesn't update when it's rendering, just when you play it on the time line.  Which is where I'm stuck.  Is there an equivalent bit of code that gets the current render frame?  Or am I thinking about this completely wrong?

    Dan

    edit: Although with more testing it seems that Execute() isn't even being called at all...Not to sure why.



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

    On 29/11/2012 at 00:49, xxxxxxxx wrote:

    In order for Execute() to be called, you have to set the TAG_EXPRESSION flag in RegisterTagPlugin. Otherwise it will never be called. That's probably why your Execute() function isn't working.



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

    On 29/11/2012 at 11:10, xxxxxxxx wrote:

    Thanks, for all the help so far Steve, I really appreciate it.

    But apparently I already TAG_EXPRESSION, inside of RegisterTagPlugin(), as well as TAG_VISIBLE| TAG_MULTIPLE.  I'm working off of the LookAtCamera SDK example, if that helps.  Looking through the HairGeneratorObject plugin is uses AddToExecution(), and when I added that function  LookAtCamera tag, which get's called all the time.  I've tried come combinations of PriorityList, but nothing is calling Execute() still.

    Reading through this thread  https://plugincafe.maxon.net/topic/5965/6075_execution-order-of-generators   it seems like AddToExecution() effects the order that things are done, but commenting out

    list->Add(op,EXECUTIONPRIORITY_GENERATOR,EXECUTIONFLAGS_0);
    

    in the HairGeneratorObject example, stops Execute() from being called. But adding

    list->Add(tag,EXECUTIONPRIORITY_EXPRESSION,EXECUTIONFLAGS_0);
    

    to my code doesn't  seem to do anything.

    I'm getting confused about how this should work.  Is this the right direction?  If it's not to much trouble I'd appreciate anymore help you could give.

    Thanks,
    Dan



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

    On 29/11/2012 at 12:38, xxxxxxxx wrote:

    Okay, I figured it out.  And now I'm embarrassed. 😊   Apparently I was calling

    LONG Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, LONG flags)  
    

    not

    EXECUTIONRESULT Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags)  
    

    I don't know why it was changed, I don't remember doing it but It wasn't like that in the default example, so I messed up somewhere.  😊

    Thanks for all the help!

    Dan


Log in to reply