Hi All,
im roughing out something quickly as a vfx test with the vray metaball plugin. The idea being to bind nParticles to locator positions, the end result of which ill probably use an objectSet of sorts and swap out locators, add an extension to query vertex positions if a mesh is in the object set instead of a locator.
anyway, Im not typically required to work much with dynamics/particles but ive managed to get the below working as a prototype. The only issue is that i cant get it to evaluate every frame. At the moment, it only calculated on the first frame.
Ive placed it under a script node ( on demand / time change ), and within the nparticle itself ( positioned within an expression for the attribute ) neither seem to force a recalculation. I’m assuming because its not marking the dependency node as dirty - but then again, im not an expert on DG plugins so i could be off.
If anyone could lead me in the right direction that would be great. below is what ive done in python. Im calling it in the expression editor using “python calcPositions()”; - with the function simply loaded into pythons global space.
def calcPositions():
nParticle_obj = pm.ls(type='nParticle')
if len(nParticle_obj) < 1:
pm.nParticle()
nParticle_obj = pm.ls(type='nParticle')[0]
nParticle_Trans = nParticle_obj.getParent()
nCount = pm.nParticle(nParticle_obj, count=True, query=True)
locCount = len(pm.ls(type='locator'))
nPositions = []
for l in pm.ls(type='locator'):
trans = pm.listRelatives(l, p=True)[0]
nPositions.append(pm.xform(trans, ws=True, q=True, t=True))
for p in range(locCount):
if p > nCount - 1:
pm.emit(o=nParticle_Trans, pos=nPositions[p])
else:
pm.setParticleAttr(nParticle_obj.pt[p], at="position", vv=nPositions[p])