Accessing Objects Pivot


At work, when something like trees need to get scattered and have motion added, we make a layout of the trees using a proxy version and then instance point caches or alembics to these proxies inheriting the transforms also. In order to scatter though, we need to create points at the pivots of each of these proxy trees and then instance in Frost. It is very easy to create the points in Thinking Particles or PFlow, and it’s possible to instance without caching by using a PRT Source, but is there a way to do something like this without going through a different particle system first?


Here is a quick and dirty MacroScript. Feel free to add a UI…

macroScript ObjectTM2PRT category:"Krakatoa Particle Stream" 
	on isEnabled return selection.count > 0

	on execute do
		local theFile = getSaveFileName filename:"ObjectTMs_" types:"Frantic Films Particle File (*.PRT)|*.prt|Comma Separated Values File (*.CSV)|*.csv" 
		if theFile != undefined do
			progressStart "Saving Objects To PRT..."
			local startTime = animationrange.start.frame
			local endTime = animationrange.end.frame 
			if not (querybox "Click [Yes] to save the current Animation Segment.\nClick [No] to save only the current frame." title:"ObjectTM2PRT - Save Animation?") do 
				startTime = endTime = currentTime.frame
			local theObjects = selection as array
			for t = startTime to endTime do
				at time t
					local theFrameFile = FranticParticles.ReplaceSequenceNumber theFile t
					local theStream =  FranticParticles.CreateParticleOStream theFrameFile #("Position float32[3]", "Orientation float16[4]")
					for o in theObjects do
						local theQuat = o.rotation
						theStream.writeParticle #(o.position, (Point4 theQuat.x theQuat.y theQuat.z theQuat.w) ) 
					if not (progressUpdate (100.0*t/(endTime-startTime))) do exit
			if (querybox "Create a PRT Loader and load the saved file?" title:"ObjectTM2PRT - PRT Loader?") do
				local newPRTLoader = KrakatoaPRTLoader name:(uniquename "PRT_Loader_ObjectPositions_")
				newPRTLoader.fileList = #(FranticParticles.ReplaceSequenceNumber theFile startTime)
				newPRTLoader.fileListFlags = #(3)
				newPRTLoader.percentViewport = 100
				newPRTLoader.viewportParticleDisplayMode = 2
				select newPRTLoader
				max modify mode
  • Run the script and assign to a toolbar, menu, QuadMenu or keyboard shortcut.
  • Select one or more scene objects.
  • Launch the script.
  • Answer with Yes for animation range saving, No for current frame only.
  • Wait for the saving to finish, or cancel the progress.
  • Answer with Yes to create a PRT Loader, No for no PRT Loader (e.g. when updating a file where the PRT Loader already exists).
  • Note that Frost uses Uniform Scaling only, so I have not added Scale export yet, just Position and Orientation.