BaseTime and doc->SetTime()
-
On 09/09/2017 at 19:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi folks,Edit: same thing happens in the main thread too.
I'm running a threaded operation where I'm playing back a scene in memory. Nothing fancy, just trying to make the document increment one frame at a time. I'm doing this by:
//psuedo code, doc is in memory only BaseTime tm; tm.SetDenominator(1.0); // for the purposes of here, lets assume we're wanting frame 23 tm.SetNumerator(1.0/doc->GetFps()*23); doc->SetTime(tm); // does not set to frame 23 doc->ExecutePasses(this->Get(),TRUE,TRUE,TRUE,BUILDFLAGS_0); // always returns TRUE // this always returns RENDERESULT_OK REDERESULT render = RenderDocument(doc,rdata,nullptr,nullptr,Multipass,RENDERFLAGS_EXTERNAL|RENDERFLAGS_NODOCUMENTCLONE|RENDERFLAGS_PREVIEWRENDER,this->Get()); // if I print the frames from the basetime and the doc, this is what I get GePrint("Time frame = " + RealToString(tm.GetFrame(..)); // CORRECT 23 GePrint("doc frame = " + RealToString(doc->GetTime().GetFrame(doc->GetFps()))); // INCORRECT 0
The problem I'm having is that the document is not animated to the correct frame. What I have noticed, is that the document changes time based on the frame rate. So if the frame rate is 30fps, then when I set the document time with any frame from 0-29, it only executes frame 0, and when the frame count reaches frame 30 the document is then set to the correct frame. The same thing happens from frames 30-59, the doc doesn't change until it gets to frame 60. It seems to go in multiples of the frame rate.
Is there something about BaseTime I'm not understanding, or doc->SetTime()? Is there something about doing this in a threaded environment means it won't animate correctly? Or, is this another issue, some function call I've missed? An incorrect flag? Something in my math? Something else?
WP.
-
On 10/09/2017 at 00:36, xxxxxxxx wrote:
Set the numerator to the desired frame (23) and the denominator to the document frame rate (e.g 30). This will set the time to 23/30ths of a second.
Steve
-
On 10/09/2017 at 02:14, xxxxxxxx wrote:
Hi Steve,
that's what I originally had, which is why I changed it to the above, to try something different (loosely based off some code I saw here somewhere). I was under the impression BaseTime worked as a fraction, e.g. 3 over 25, or 0.25 over 1.0, and that it didn't matter so much the values you set it with but the fraction value it's worth (if that makes sense!).
I changed it back, and the issue is still there, although I can see that the doc time is now showing the correct frame. But it's still not drawing the correct frame.
WP.
-
On 11/09/2017 at 02:47, xxxxxxxx wrote:
Don't know if it's RenderDocument() doing something here or not. I can GePrint() the correct frame just before I render it, but the rendered frame is not the correct frame.
// prints correct frame GePrint("Rendering frame " + RealToString(doc->GetTime().GetFrame(Animation->GetFps()))); BaseContainer rdata; Set_RenderData(&rdata,Width,Height); // sets some default render settings rdata.SetTime(RDATA_FRAMEFROM,doc->GetTime()); rdata.SetTime(RDATA_FRAMETO,doc->GetTime()); // renders incorrect frame RENDERRESULT Result = RenderDocument(doc,rdata,nullptr,nullptr,Renderer,RENDERFLAGS_EXTERNAL|RENDERFLAGS_NODOCUMENTCLONE,Thread);
WP.
-
On 11/09/2017 at 03:00, xxxxxxxx wrote:
D'oh! I wasn't setting the frame rate in the render container!
I'll see myself out. !
Tongue
[URL-REMOVED]WP.
[URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
-
On 11/09/2017 at 09:32, xxxxxxxx wrote:
Hi,
I'm glad you found your problem. Don't feel bad about it, we all have these days...
For everybody reading this thread in future:
- As steve pointed out, the code in the first post does not properly set BaseTime.
- The manuals on BaseDocument (Animate) and BaseTime may help on this topic.