AWS Thinkbox Discussion Forums

Iterate over PRT Loader points

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?

Here you go:

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. :smiling_imp:

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

(
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()
)

Gracias!

Privacy | Site terms | Cookie preferences