Skip to content

Instantly share code, notes, and snippets.

@simogasp
Created August 1, 2016 13:57
Show Gist options
  • Save simogasp/9761e0e324426f45a7e4748f0271558d to your computer and use it in GitHub Desktop.
Save simogasp/9761e0e324426f45a7e4748f0271558d to your computer and use it in GitHub Desktop.
Script to color and resize the point cloud according to the point visibility
# color points and their size (if spehere) according to their visibility
# create color attribute per particle
# create general attribute radiusPP
import maya.cmds as mc
import colorsys
name = 'mvgPointCloud'
radiusBase = 0.005
## Count the number of particules
totalParticle = mc.particle(name, query=True, count=True)
print(totalParticle)
visibilitySizePerPoint = mc.getAttr(name+'.mvg_visibilitySize')
maxVisibility = float(max(visibilitySizePerPoint))
for (id) in range(totalParticle):
# Query and print Particle position
# myPos = mc.xform('mvgPointCloud.pt[{id}]'.format(id=id), query=True, translation=True)
# Query and print Particle Color RGBPP
# myColor = mc.particle('mvgPointCloud', query=True, attribute='rgbPP', id=id)
#print 'Particle ID', id, 'Position:', myPos, 'Color:', myColor, 'visibilitySize:', visibilitySizePerPoint[id]
v = visibilitySizePerPoint[id] / maxVisibility
myColor = colorsys.hsv_to_rgb(v*.75, 1.0, 1.0)
radius = radiusBase+0.01*v
mySize = radius
if visibilitySizePerPoint[id] < 3:
myColor = [0.7, 0.7, 0.7]
mySize = radiusBase
#print(id)
mc.particle(name, edit=True, attribute='rgbPP', order=id, vectorValue=myColor)
mc.particle(name, edit=True, attribute='radiusPP', order=id, floatValue=mySize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment