I am an artist who needs help with the following Python script.
Below is a Maya python script which imports point cloud files into Maya.
Image 1 shows how the point cloud looks when imported into Maya.
The point cloud is not dense enough.
Image 2 is how it needs to look with updated coding.
If anyone could help update the script so the point cloud is dense like image 2,
it would greatly appreciated.
# Maya .PTS to Particles Script
import maya.cmds as cmd
import maya.mel as mel
# set user params
filePath = "D:\\Files\\Misc_Projects\\Projects\\Tractor.pts"
# start from nth particle
start = 1
# set particle limit
limit = 100000
# subsample by a certain factor
factor = 0.001
posDataList = 
colorDataList = 
step = 1/factor
ptc = cmd.particle()
cmd.addAttr(ptc, ln='rgbPP', dt='vectorArray')
cmd.addAttr(ptc, ln='rgbPP0', dt='vectorArray')
cmd.setAttr(ptc + '.isDynamic', 0)
# the following is just to speed up visualization
cmd.setAttr(ptc + '.particleRenderType',3)
print 'error encoutered while setting up'
# lazily read file
with open(filePath) as infile:
count = 0
for line in infile:
count += 1
if count < start: continue
if count%step == 0:
data = re.sub(' +',' ',line).split(' ')
posData = (float(data), float(data), float(data))
colorData = (float(data)/255, float(data)/255, float(data)/255)
if (count - start) * factor > limit: break
# cmd.emit( o=ptc, pos=posDataList, at=('rgbPP'), vv=colorDataList )
# the above should work, according to Maya's Documentation, but it doesn't (Maya crashes)
cmd.emit( o=ptc, pos=posDataList )
ptcs = cmd.particle( ptc, q=1, count=1)
for (id) in xrange(ptcs):
cmd.particle(ptc, e=1, at='rgbPP', vv=colorDataList[id], order=id)