import sys,random,math,re,random def genRiPointBlock(currentFrame,seed,p,rotationAxis,vel,numOfDots,radius,pointSize,motionBlur): outStr = 'TransformBegin\n' outStr+= ' Translate %s %s %s\n'%(p[0],p[1],p[2]) outStr+= ' Rotate %s %s %s %s\n'%(currentFrame,rotationAxis[0],rotationAxis[1],rotationAxis[2]) if(motionBlur): outStr += genRiMotionPoints(vel) #main seed numOfDots radius dotScale params = (int(random.random()*1000),numOfDots,radius,pointSize) #params = (1) #outStr += 'Procedural "DynamicLoad" ["main" "%s %s %s %s" ] ' % params outStr += 'Procedural "DynamicLoad" ["main" "%s" ] ' % seed boundingBox = "[ -%s %s -%s %s -%s %s]" % (radius,radius,radius,radius,radius,radius) outStr += boundingBox+'\n' outStr+= 'TransformEnd\n' return outStr def genRiMotionPoints(vel): x = vel[0]*3 y = vel[1]*3 z = vel[2]*3 outStr = '' outStr += "MotionBegin [0 1]\n" outStr += " ConcatTransform [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ]\n" outStr += " ConcatTransform [ 1 0 0 0 0 1 0 0 0 0 1 0 %s %s %s 1 ]\n" % (x,y,z) outStr += "MotionEnd\n" return outStr def ho_riPointGen(currentFrame,seed,smokeFilePath,velocityFile,numOfDots,radius,pointSize,motionBlur): #rib = open(outputRib,'w') velFile = open(velocityFile,'r') smokeFile = open(smokeFilePath,'r') numOfSkip = 11 for e in range(0,numOfSkip): skip = velFile.readline() varType = (smokeFile.readline()) varName = (smokeFile.readline()) resX = int(smokeFile.readline()) resY = int(smokeFile.readline()) resZ = int(smokeFile.readline()) bbxMin = float(smokeFile.readline()) bbyMin = float(smokeFile.readline()) bbzMin = float(smokeFile.readline()) bbxMax = float(smokeFile.readline()) bbyMax = float(smokeFile.readline()) bbzMax = float(smokeFile.readline()) incX = (bbxMax -bbxMin)/float(resX) incY = (bbyMax -bbyMin)/float(resY) incZ = (bbzMax -bbzMin)/float(resZ) tmpX = bbxMin tmpY = bbyMin tmpZ = bbzMin for i in range(0,resX): for j in range(resY): for k in range(resZ): density = float(smokeFile.readline()) line = velFile.readline() tmp = re.split(" ",line,0) vel = tmp tmp2 = re.split("\n",tmp[2],0) vel[2] = float(tmp2[0]) #vel = (0,0,0) vel[0] = float(vel[0]) vel[1] = float(vel[1]) vel[2] = float(vel[2]) tmpX = bbxMin + incX *i tmpY = bbyMin + incY *j tmpZ = bbzMin + incZ *k p = [tmpX,tmpZ,tmpY] seed += 1 random.seed(seed) rotationAxis = (random.random(),random.random(),random.random()) if(density > 0.0001): riPoints = genRiPointBlock(currentFrame,seed,p,rotationAxis,vel,numOfDots,radius,pointSize,motionBlur) #print 'Hider "stochastic" "int sigma" 1 "float sigmablur" 1\n' #print 'Attribute "stochastic" "int sigma" 1\n' #print 'Attribute "stochastic" "int pointfalloff" 1\n' print riPoints #rib.write(riPoints) #rib.close() velFile.close() smokeFile.close() """ #setting seed = int(1) currentFrame = int(2) dataDir = "/tmp/render/cloud_Project/data/" dataDir = '/home/hchang21/Desktop/SFDM-PROJECT/VSFX/caveman/cloud/data/fume_02/' smokeFile = dataDir + 'e_smoke.%s.txt' % (currentFrame-1) velFile = dataDir + 'e_vel.%s.txt' % (currentFrame-1) motionBlur = 1 boundingboxScale = 2 #for now not used... dotScale = 0.5 numOfDots = 5 pointSize = 1 ho_riPointGen(currentFrame,seed,smokeFile,velFile,numOfDots,boundingboxScale,pointSize,motionBlur) """ args = sys.stdin.readline() while args: values = args.split() pixels = float(values[0]) seed = int(values[1]) currentFrame = int(values[2]) #setting dataDir = "/tmp/render/cloud_Project/data/" #dataDir = '/home/hchang21/Desktop/SFDM-PROJECT/VSFX/caveman/cloud/data/fume_02/' smokeFile = dataDir + 'e_smoke.%s.txt' % (currentFrame-1) velFile = dataDir + 'e_vel.%s.txt' % (currentFrame-1) motionBlur = 1 boundingboxScale = 2 #for now not used... dotScale = 0.5 numOfDots = 5 pointSize = 1 ho_riPointGen(currentFrame,seed,smokeFile,velFile,numOfDots,boundingboxScale,pointSize,motionBlur) sys.stdout.write('\377') sys.stdout.flush() # read the next set of inputs args = sys.stdin.readline()