Holy Grail...? Bake Mograph objects to keyframes


#6

Hi there,

It would also be great to be able to import mograph-based motion into game-engines, like Unity3d. Here you also need keyframes and the FBX format.


#7

I have done this before to render mograph clones in 3DS Max - no holy grail at all, but a small bit of work.

You link a duplicate set of objects to the mograph clones via Xpresso. Let’s say you have a system with 300 cloned cubes… Create 300 cubes and put them in a null. Use iteration + link list nodes (+ mograph data node) to make the non-mograph cubes bind to the mograph cubes. Then, select all the non mograph cubes and turn on record for all PRS, then press the keyframe button. Advance the time slider one unit and press keyframe again, etc. I have a script that automatically does this, but I can’t find it right now…

You can then export via FBX, and all PRS data should work correctly.


#8

That script sounds very useful if you manage to find it again… a potential way to avoid RSI when doing something like this :wink:

I don’t know that much about Coffee but I guess the guts of it would a For loop that repeats for the duration of the number of frames in the scene, then inside this loop you put a Record Active Objects command followed by a Next Frame command.

Hmmm maybe I’ll have to try and figure this out for myself as a learning exercise… I’ll post my results if I get it working.

Cheers,
Brian


#9

Hey I just found another way to do it, a little slow as you’d have to do one object at a time but it works.

Set up the xpresso as before, cache the mograph object using a mograph cache tag. Then select an object you want to bake and choose the Mocca Cappucino tool. Click on Start Realtime and then click on any of the translate arrows of the object to be baked, hold the mouse button down but don’t move the mouse. The animation will play through and the object gets baked properly. Repeat for the other objects.

A bit of a hack but it does work… the script to bake would definitely be neater.

Cheers,
Brian


#10

Man why did I ever read this thread? :slight_smile:

I have a really simple script now that cycles through the timeline for 50 frames and records a key on each one… but the result is the same as baking with the PSR constraint… I tried adding in a Redraw command but still the same…

var count = 1;
 	while (count<50) {
 
 		CallCommand(12410);//Record Active Objects
 	CallCommand(12414);//Next Frame
 	count++;
 	}

Cheers,
Brian


#11

Here it is…

         No fancy controls or GUI here - all parameters are accessed through the script editor.  You need to select the objects to bake and make sure to enable all Position, Rotation, and Scale keyframe options before running this script:

 var userStartTime = 0;
 var userEndTime = 90;
 
 var fps = doc->GetFps();
 var bakeStartTime = GetActiveDocument()->GetTime(); //needed to initialize a BaseTime object
 bakeStartTime->SetFrame(userStartTime, fps);
 
 doc->SetTime(bakeStartTime); //set the time slider to the user's start time
 var currentFrame = GetActiveDocument()->GetTime()->GetFrame(fps);
 
 while(currentFrame <= userEndTime)
 {
 	StopAllThreads();
 	CallCommand(12410);//record
 	userStartTime++;
 	bakeStartTime->SetFrame(userStartTime, fps); //needed to convert frame to BaseTime
 	doc->SetTime(bakeStartTime);//SendPlayhead to next frame
 	var redraw = DrawViews(DA_STATICBREAK);
 	EventAdd(EVENT_ANIMATE);
 	if(redraw == TRUE) currentFrame = GetActiveDocument()->GetTime()->GetFrame(fps);
 }
        

#12

Here is also a .c4d file that shows how to link objects to mograph clones:
Link


#13

Works perfectly… many thanks… now I can get on with my life :slight_smile:

Cheers,
Brian


#14

Here it is indeed - works perfectly, huge thanks this has opened a whole load of doors for me, I owe you one :beer: guess I need to start looking into scripting, that’s some pretty useful stuff in there.


#15

Thanks to you Brian too for the time, hope you’ll find this as useful as I will!

Cheers - Chris


#16

Someone ought to stick this into the Scripts section with a huge bullet, right next to Per’s clones-to-nulls script.


#17

Thanks Chris, I’m sure I will!

Cheers,
Brian


#18

Nice solution


#19

That’s really great, thanks a lot!


#20

Hello,
I’m trying to get this .c4d file but the link does not seem to work, please could someone re-upload it or send it by email?

Thanks in advance

Diego


#21

I just switched web hosts, so that link may have been removed when I cleaned out my old folders. I’ll see if I can find it and re-upload.


#22

Yes please.


#23

Link is back up.


#24

Thank you very much Baldini, here trying to export Mograph animations to EIAS (Electric Image).

Cheers

Diego


#25

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.