hya people,
i have a sequence with a grid displaying a animated water sequence.
sorta like this, but much bigger
-999 0 -999 0.02
-999 0.1 -999 0.02
-999 0.2 -999 0.02
-999 0 0 0.02
-999 0 -999 0.02
i have written a python script that converts this into a other format (x,y,z):
1,2,0
1,3,0.02
2,2,0.1
2,4,0.02
3,2,0
3,3,0
etc
i want to get this into 3D, so i thought particles will help me out.
I’m trying to read particles from this file sequence.
on ChannelsUsed pCont do
(
pCont.useTime = true
pCont.useAge = true
pCont.usePosition = true
pCont.useSpeed = true
)
on Init pCont do
(
global partArray = #()
frameNumber = substring (currenttime.frame as string) 1 1
spath = @"C:\data\"
filename = spath + "ex_dm1d000" + (frameNumber) +".csv"
fs = openFile filename
counter=1
while not eof fs do (
tmp = readline fs
ss = tmp as StringStream
x = (readDelimitedString ss ",") as float
y = (readDelimitedString ss ",") as float
z = (readDelimitedString ss ",") as float
partArray[counter]= #(x,y,z)
counter = counter + 1
)
print ("Data read frome file : " + filename)
close fs
)
on Proceed pCont do
(
st = timestamp()
--if (pCont.NumParticles() <= 0) then (
t1 = pCont.getTimeStart() as float
t2 = pCont.getTimeEnd() as float
if (t1 < 0) then (t1 = 0)
for t=1 to partArray.count do (
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTime = 0
pCont.particleSpeed = [0, 0, 0]
pCont.particlePosition = [partArray[t][1], partArray[t][2], partArray[t][3]]
-- )
)
format "Number of particles : % took:%secs
" (partArray.count) (timestamp()-st)
)
on Release pCont do
(
)
problem with this is that the array is loaded one time (when i press ctrl-e). then the current frame is read into the array and displayed (and may i say not that fast…)
i also tried putting the reading of the file into the On Proceed but that gets Very slow
Sow, perhaps any1 of you people can help me out here…
Many thanks in advance! if needed i can upload a sequence somewhere!
It will directly import .csv format through a PRT loader