Search the Community
Showing results for tags 'realflow bin format'.
-
I want to export particles or points using the realflow format. My code is almost working, I am probably just missing a character that makes the file readable, as the realflow plug in reads the file but just display the last particle. I am using version 9 of the realflow bin format. Does anyone have an idea what could be missing? Please find the code below: version = 9 node = hou.pwd() geo = node.geometry() fileIn = open( fileName, 'wb') fileIn.write( struct.pack('H', 0xBADA)) fileIn.write( struct.pack('H', 0xFA)) name = "exportParticles" name = name.replace( "\n", "") print( len(name)) fileIn.write( struct.pack( '250s', name.ljust( 250 , '\0'))) fileIn.write( struct.pack('h', version)) fileIn.write( struct.pack('f', 1.0)) #scale scene fileIn.write( struct.pack('l', 5)) #fluid type fileIn.write( struct.pack('f', (frame*getFramesPerSecond()))) #ellapsed time fileIn.write( struct.pack('l', frame)) #frameNumber fileIn.write( struct.pack('l', getFramesPerSecond())) #frames per second) points = geo.points() fileIn.write( struct.pack( 'l', len(points))) fileIn.write( struct.pack( 'f', 1.0)) #radius fileIn.write( struct.pack( '3f', 1., 1., 1.)) #pressure fileIn.write( struct.pack( '3f', 1., 1., 1.)) #speed fileIn.write( struct.pack( '3f', 1., 1., 1.)) #temperature fileIn.write( struct.pack( '3f', 1., 1., 1.)) #emitter position fileIn.write( struct.pack( '3f', 1., 1., 1.)) #emitter rotation fileIn.write( struct.pack( '3f', 1., 1., 1.)) #emitter scale for p in points: fileIn.write( struct.pack('f', p.position()[2])) fileIn.write( struct.pack('f', p.position()[1])) fileIn.write( struct.pack('f', p.position()[0])) #velocity fileIn.write( struct.pack('3f', 0., 0., 0.)) #force fileIn.write( struct.pack('3f', 0., 0., 0.)) #vorticity fileIn.write( struct.pack('3f', 0., 0., 0.)) #normal fileIn.write( struct.pack('3f', 0., 0., 0.)) #neighbours fileIn.write( struct.pack('l', 0)) #uvs fileIn.write( struct.pack('3f', 0., 0., 0.)) #info fileIn.write( struct.pack('h', 0)) #age fileIn.write( struct.pack('f', 10.)) #isolated fileIn.write( struct.pack('f', 0.)) #viscosity fileIn.write( struct.pack('f', 0.)) #density fileIn.write( struct.pack('f', 0.)) #pres fileIn.write( struct.pack('f', 0.)) #mass fileIn.write( struct.pack('f', 1.)) #temperature fileIn.write( struct.pack('f', 1.)) #id fileIn.write( struct.pack('l', 0)) #additionnal datas fileIn.write( struct.pack('l', 0)) # additionnal datas RF4 fileIn.write( struct.pack('?', False)) fileIn.close()