Accessing Objects Pivot

Discussion and Support of Krakatoa Volumetric Particle Rendering, Manipulation and Management Toolkit
Posts: 18
Joined: Sat Feb 08, 2014 1:31 pm

Accessing Objects Pivot

Postby pfunkifized » Mon Feb 19, 2018 2:16 pm

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?

User avatar
Posts: 6062
Joined: Tue Nov 15, 2005 10:26 am
Location: Vancouver, Canada

Re: Accessing Objects Pivot

Postby Bobo » Tue Feb 20, 2018 2:07 am

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

Code: Select all

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.
Borislav "Bobo" Petrov
Product Specialist
Thinkbox Software Inc.

Return to “Thinkbox Software - Krakatoa for 3ds Max”

Who is online

Users browsing this forum: No registered users and 1 guest