Proximity detection over Timeline [Python]

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  05 May 2013
Proximity detection over Timeline [Python]

Ok so my code get the bounding box information from a series of mesh objects, then it runs through the timeline one frame at a time. On each frame it get the positions of a particle simulation. If enough of the particles are within the bounding box area for an object it becomes an nCloth object. However when the code runs the nParticles fall through the floor plane so only the closer mesh becomes nClothed mesh. However if I reset the timeline after running the code and hit play the particles hit the floor plane and move the nCloth objects. Not sure why and I need to know cause I want all of the interaction when I run the code, not afterwards. This is my code:

time = cmds.playbackOptions(q=True, maxTime=True)

i = 0

while i < time:

now = cmds.currentTime(q=True)
cmds.currentTime(now+1, update=True)

count = cmds.getAttr('ParticleFlowShape.count')

#sp is the special counter
sp = 0

k = 0

# list_Length[0] is the total number of objects
while k < list_Length[0]:
#boundingBox is a list with all the bounding box information
boxie = boundingBox[k]


#using the particle count to get all the particle positions
while j < count:

if count >=1:

part = cmds.nParticle('ParticleFlowShape', q=True, attribute='position', id=j)
#work out if the particles are within the activation area
if (part[0] > boxie[0]-1.5 and part[0] > boxie[1]-1.5 and part[1] > boxie[2]-1.5 and part[1] < boxie[3]+1.5 and part[2] < boxie[4]+1.5 and part[2] < boxie[5]+1.5):

sp += 1


if sp >= 50 and sp <=70:
#alt_List are a the set of objects having the nCloth applied[k])
#shard_List are already active passive colliders that need to be removed
if cmds.objExists(shard_List[0][k]):

mel.eval('createNCloth 0;')
cmds.connectDynamic(alt_List[k], f='Gravity11')



Don't want to post the full code cause it's around the 1000 line mark. Any help is appreciated, also thinking of using expressions instead but they could be quite heavy. Cheers guys
  05 May 2013
could be wrong but this is what I think its happening. You code (probably) work ok however when you create an nCloth object the simulation starts at frame 1 onwards thats why when you rewind your sim the particles are interacting with the new nCloth. Also I presume that you are applying everything to just one nucleus which mean that all the newly created nCloth objects will behave under the same nucleus option. If you want them to behave separately you need to create individual nucleus for each object.

Hope this helps if not sry for wasting your time T_T.
Maya Fluids own xD.
Graduate xD
  05 May 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 05:12 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.