Notifications
Clear all

[Closed] Export one Max fiel into seperate FBX sequences

I want to split a single .max file into seperate FBX sequences.

Currently I am doing this by setting the animationrange.start and animationrange.end for each part and exporting. But the result is FBX files with timelines equal to the original total length, but only keyframes for the current sequence.

for example sperating a 100 frame animation into a start, loop, and end sequence.
‘start’ is frames 1-20
‘loop’ is frames 21-60
‘end’ is frames 61-100

What I get is 3 Fbx files that are 100 frames long, with lots of ‘dead space’, except for those frames I wanted to export. I need to clear that dead space!
What I want is each FBX to contain only the frames I care about.

how can I control this better?

6 Replies

Well, as this is the scripting forum, why not write a little script ?

  • change animationrange.start and animationrange.end
  • export
  • restore original animationrange.start and animationrange.end

sounds quite a simple script to create ?

A better aproach in general would be making use of animation takes ( a feature of FBX )
This stores seperate animation time spans inside one FBX
In Max you have to script this yourself though, the exporter dialog does not provide it.
Or make use of an already existing, wonderfull FBX script
http://www.scriptspot.com/3ds-max/scripts/time-range-manager

or a simple one
http://www.scriptspot.com/3ds-max/scripts/fbx-multitakes-exporter

I did script it, basically doing exactly as your first suggestion describes.
The flaw is that the resulting FBX contains the full timeline range reguardless of where I set animationrange.start / end before export. I just sets the same playback range in the fbx, and excludes animation outside of that range…its doesn’t “crop” so to speak.

for example If I export my “loop” animation of frames 21-60 above
re-Importing the resulting FBX show a 100 frame FBX whose playback range is set 21-60
In Unity (our game engine) this results in a lot of dead space in the imported FBX (frames 0-20, 61-100)

I’ve switched to a script that builds FBX takes as you further suggested, but I need to see if our furthur FBX processing can retain the info.

IMHO Using multiple takes in one FBX is the better solution for Unity
I too use Unity and wrote a script exactly for that purpose:
export to multiple takes in one FBX which transport quite nicely over to Unity as multiple animation clips correctly named, but all sitting in one FBX file. No more need to juggle with multiple FBX files or with the legacy “@” animation naming scheme Unity used in the past …
In Max this allows me to keep all the different animations on one timeline ( i use a custom Animation/TimeRange managing script in Max to create/name the animation ranges )

And Unity’s assetimporter is easily scriptable too, so i really think even if the current pipeline does’nt support multi-takes per FBX, implementing that would be the best option ( and not too much effort )

Our animators work in separate files for the most part. Do you have any solutions for combining multiple Max files using the same rig into a single FBX export?

1 Reply
(@spacefrog)
Joined: 10 months ago

Posts: 0

Not really…
Rereading your post about the deadspaced frame ranges in Unity it looks like you have two options: either use Max’s trackview’s time manipulation features to shift your animation range to frame 0/1 prio export ( given that they are fully exposed to MXS, which i don’t know exactly currently ), or do the same in Unity via an FBX assetimporter callback Editor script.

If you use xrefs with animation and what not, the 3ds Max way might give you some problems to solve, because until recently xref animation exposure was more limited…

Logan,

If you are exporting ranges into Unity you need to set the FBX accumulator before you export. This way you can have a single FBX file, with the animation clips already split into their correct ranges. One caveat is there is no way of removing the default “take001” as this is created by the FBX exporter (you can in Unity though)

here is my exporter code to do this. You’ll need to key the animated objects at the start and end of the range otherwise FBX doesnt always write the take correctly.

	
/*
	[NAME]: exportFBXToUnity
	[FUNCTION]:
		Exports multiple takes to FBX for loading into unity
	[ARGUMENTS]:
		<STRING> exportFileName: the FBX output file
	[OPTIONAL ARGUMENTS]:
		<ARRAY> takeArray: a multidimensional array, of which each element is an array with the takwe name, and the time as an interval 
		<BOOLEAN> saveAnim:
		<BOOLEAN> bakeAnim:
		<INTEGER> start:
		<INTEGER> end:
		<STRING> prefix:
	*/	
	fn exportFBXToUnity exportFileName takeArray:#() saveAnim:true bakeAnim:false start:animationrange.start end:animationrange.end prefix:"" =
	(
		-- set some default parameters (FBX 2012 seems to be more reliable)

		FBXExporterSetParam "FileVersion" "FBX201200"		
		FBXExporterSetParam "UpAxis" "Y"
		FBXExporterSetParam "Cameras" True
		FBXExporterSetParam "Lights" True
		
		-- find out 
		--"AxisConversionMethod"	"None", "Animation", or "Fbx_Root".
		-- converts to new axis system (should be okay if animation had a root control)
		
		if selection.count > 0 then
		(
			if saveAnim then 
			(	
			-- clear the FBX accumulator 
			FBXExporterSetParam "SplitAnimationIntoTakes" "-c"	

			currentRange = animationrange			
			theRange = interval start end	
			if animationrange != theRange then animationrange = theRange
							
			FbxExporterSetParam "Animation" true	
			
			if bakeAnim then
			(				
				FbxExporterSetParam "BakeResampleAnimation" true	
				FbxExporterSetParam "BakeFrameStart" start
				FbxExporterSetParam "BakeFrameEnd" end
				FbxExporterSetParam "BakeFrameStep" 1
			)
			else
			(
				FbxExporterSetParam "BakeResampleAnimation" false					
			)
				
			--Setup the takes for FBX						
			--NoteTake001 exists regardless of how many splits are defined. 
			--Do not set a "frameEnd" < "frameStart". If "frameStart" and "frameEnd" do not define an interval 
			--with keys the split function will not validate it. 
			--If no animation keys are in the range, a take is created with no keys. 
			if takeArray.count > 0 then	
			(				
				for take = 1 to takeArray.count do 
					FBXExporterSetParam "SplitAnimationIntoTakes" (prefix + takeArray[take][1] + "_") \
									takeArray[take][2].start takeArray[take][2].end
			)
			else
			(
				messagebox "Please add a take name for the animated objects" title:"FBX to Unity Export" beep:False
				return false
			)			
			animationrange = currentrange			
			)
			else
			(			
			FbxExporterSetParam "Animation" false	
			FbxExporterSetParam	"BakeResampleAnimation" false	
			)
			-- Export without Dialog
			exportFile exportFileName #noPrompt selectedOnly:true using:FBXEXP		
		)
		else messagebox "Please select some objects to export" title:"FBX to Unity Export" beep:False
	)