Iterate over PRT Loader points

Discussion and Support of Krakatoa Volumetric Particle Rendering, Manipulation and Management Toolkit
User avatar
oatz
Posts: 398
Joined: Wed Oct 31, 2007 7:27 pm

Iterate over PRT Loader points

Postby oatz » Fri Jan 12, 2018 6:26 pm

Can't believe I've never had to do this before--Is there maxscript access to iterate over the particles in a PRT Loader and get pos? or do I have to access the .prt file itself?

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

Re: Iterate over PRT Loader points

Postby Bobo » Fri Jan 12, 2018 6:34 pm

Here you go:

http://www.thinkboxsoftware.com/krak-pa ... xscpt-val/

It works with any PRT stream, so all PRT objects will return particle data, not just the PRT Loader. In fact, the Particle Data Viewer of Krakatoa was implemented using this interface, in case you want a scarily complex example. :twisted:

However, you have to get the channels layout first, find out where Position is located relative to the other channels, and then read the data from each particle (or skip a bunch to get directly to the millionth particle), and get the i-th component of the result array corresponding to the Position channel's index within the channel layout list.

For example

Code: Select all

(
theStream = FranticParticles.GetPRTObjectIStream $ true false --2nd arg. True for world space Positions!
theChannels = theStream.getChannels()
thePosIndex = 0
for i = 1 to theChannels.count where matchPattern theChannels[i] pattern:"Position *" do thePosIndex = i
if thePosIndex > 0 do
   for p = 1 to 100 do
   (
      theData = theStream.readParticle()
      format "Particle % Position: %\n" p theData[thePosIndex]
   )
theStream.close()
)
Borislav "Bobo" Petrov
Product Specialist
Thinkbox Software Inc.

User avatar
oatz
Posts: 398
Joined: Wed Oct 31, 2007 7:27 pm

Re: Iterate over PRT Loader points

Postby oatz » Fri Jan 12, 2018 7:06 pm

Gracias!


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

Who is online

Users browsing this forum: No registered users and 3 guests