Setting scene time in frames
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2008 at 13:08, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.1
Platform: Windows ; Mac ;
Language(s) : C++ ;---------
Hi,I'm trying to implement a keyframe recording function. To do that, I iterate the frame range that should be recorded, set the scene time and then animate the document. After that, I create keyframes for the objects that should be recorded with a selfmade function (this is called in another part of the plugin).
But something doesn't work with BaseDocument::SetTime().
This is my code:
>
LONG minFrame = doc->GetMinTime().GetFrame(doc->GetFps()); \> LONG maxFrame = doc->GetMaxTime().GetFrame(doc->GetFps()); \> LONG cFrame = minFrame; \> LONG cFPS = doc->GetFps(); \> LONG sVal = C_ZERO; \> \> while (cFrame <= maxFrame) \> { \> sVal = (LONG)((cFrame - minFrame) / (maxFrame - minFrame) \* 100); \> StatusSetBar(sVal); \> StatusSetText("Recording Frame " + LongToString(cFrame)); \> BaseTime cTime = BaseTime::BaseTime(cFrame, cFPS); \> doc->SetTime(cTime); \> doc->AnimateDocument(NULL, TRUE, TRUE); \> EventAdd(EVENT_FORCEREDRAW|EVENT_ANIMATE); \> DrawViews(DA_FORCEFULLREDRAW, NULL); \> cFrame++; \> }
And here's the problem: Keyframes are created fine, but not all frames are created. For example: if I record from Frame 0 to Frame 100, keyframes are missing at Frame 0, Frame 19 and Frame 91.
I guess, I set the scene time wrong with BaseTime cTime = BaseTime::BaseTime(cFrame, cFPS);. Got that method this thread.
Thanks in advance for any help!
Greetings,
JackAlso, will this work in R11, too? I develop using the 10.1 SDK, but of course it should run in R11, too.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/11/2008 at 14:10, xxxxxxxx wrote:
Even more strange is: Everytime this loop is performed, different frames are missing. Sometimes it works out fine at the first try, sometimes I have to do it 2 or three times until all keyframe 'holes' are filled.
Always the frame before a keyframe 'hole' is done twice. So maybe it's some kind of precision error... hm, but that would not explain the randomness... I have no idea.And Frame 0 is never recorded. It seems as setting the Document time to frame 0 and animating the document does not have any effect.
Greetings,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2008 at 07:57, xxxxxxxx wrote:
As far as I can tell, your loop looks fine (see Matthais' post in my recent thread ). The only functional difference is that I'm not passing any arguments to EventAdd() in my most recent version.
My code seems to be working correctly now - some of the later problems I was having were just dumb errors in other parts of the code that made it look like the frame-looping wasn't working.
To be honest, I haven't checked every frame closely to look for duplicates, but animating to frame 0 (or the start frame) is definately working for me. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2008 at 08:19, xxxxxxxx wrote:
Hm, maybe it's because I do the keyframe adding in GetVirtualObjects() ? As I was told, this method is not thread safe. I will think of something else when I got time, for now the recording function is not too important.
Cheers,
Jack