CGTalk > Software Specific Forums > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-08-2013, 12:07 AM   #1
Jamone22
New Member
portfolio
Ben Lane
BSc 3D Computer Animation
Swansea Metropolitan
Swansea, United Kingdom
 
Join Date: Mar 2012
Posts: 13
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:

cmds.playbackOptions(maxTime=75)
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]

j=0

#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

j+=1

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

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


k+=1

i+=1

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
 
Old 05-20-2013, 04:37 PM   #2
kdronez
Frequenter
 
kdronez's Avatar
portfolio
Veselin Gyurov
Noobie xD
Searching for Job T_T.
United Kingdom
 
Join Date: Mar 2009
Posts: 202
Elo,
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 showreel:vimeo.com/64879738 xD
 
Old 05-20-2013, 04:37 PM   #3
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 09:54 PM.


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