I've been trying to write out particles cache files from Houdini to Blender.
I successfully exported a sequence of bphys file, which Blender loads fine. the code is roughly ( in python ):
dataType = 1 nParticles = npoints data = struct.pack("8c","B","P","H","Y","S","I","C","S") data += struct.pack("III",dataType,nParticles,31) # I don't understand that 31 ... for i in range(nParticles): #index data += struct.pack('I',idList[i]) #Location data += struct.pack('fff',positionList[i], positionList[i]*-1, positionList[i]) #Velocity data += struct.pack('fff',velocityList[i], velocityList[i]*-1, velocityList[i]) #Rotation data += struct.pack('ffff',0.0,0.0,0.0,0.0) ## no values for now #Avelocity data += struct.pack('fff',5.0,10.0,0.5) ## no values for now
This code runs for every frame in the animation. Lastly, I write the very first bphys file ( with 6 padded zeros) "filename_000000_00.bphys" , containing a list of all the particles 'times' in the simulation, with the good header data.
dataType = 1 nParticles = len(particlesList) data = struct.pack("8c","B","P","H","Y","S","I","C","S") data += struct.pack("III",dataType,nParticles,64) for particle in particlesList: data += struct.pack('fff', particle['birth'], particle['death'], particle['lifetime'])
Now, that's a good first step. Althought I haven't been able to see any Angular velocity in blender; Location and Velocity are read fine.
One of the key parameters I would love to export from Houdini, is the scale parameter. But I have no idea how to add this value to the bphys file. I tried to add a float to the "collection" , of course it doesn't work. I must have to change something in the header. This "31" value seems to correspond to the amount of data per particles. There seems to be a lot of different possible values for this parameter. How can I find some informations about that ? ( if possible without having to dive into C++ source code, which I tried )
I feel like I'm almost there
I need some light ^^