|05 May 2013|
BSc 3D Computer Animation
Swansea, United Kingdom
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)
count = cmds.getAttr('ParticleFlowShape.count')
#sp is the special counter
sp = 0
k = 0
# list_Length is the total number of objects
while k < list_Length:
#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 > boxie-1.5 and part > boxie-1.5 and part > boxie-1.5 and part < boxie+1.5 and part < boxie+1.5 and part < boxie+1.5):
sp += 1
if sp >= 50 and sp <=70:
#alt_List are a the set of objects having the nCloth applied
#shard_List are already active passive colliders that need to be removed
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|
Searching for Job T_T.
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
|05 May 2013|
Thread automatically closed
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|