Gallery details
“”” CREATES KEYFRAMES AND ANIMATION OF BOTH THE NCLOTH SHAPE AND THE MESH VERTEX COLORS. NDYNAMICS SIM MUST BE CACHED BEFORE THIS IS RUN”””
[Maya NDynamics Sim Deformation viz via Mesh Vertex Colors]
CODE
import maya.cmds as mc
import math
from pymel.core import *
#CODE CREATES PAINTS MESH VERTEX COLORS OF A MESH BASED ON DISTANCE DEFORMATION TO THE DRIVER MESH
#CREATES KEYFRAMES AND ANIMATION OF BOTH THE NCLOTH SHAPE AND THE MESH VERTEX COLORS.
#WRITTEN BY LUIS QUINONES
#COMPLICITMATTER.COM // COMPUTATIONALMATTER.COM
#/////////////////////////////////////////////////////////////////////////////////////////////////////
#get the timeslider startFrame
startFrame = mc.playbackOptions(q = True, minTime = True)
#get the timeslider endFrame
endFrame = mc.playbackOptions(q = True, maxTime = True)
#set the current frame to the start frame
currentFrame = startFrame
#/////////////////////////////////////////////////////////////////////////////////////////////////////
#BaseGeom Selection
Meshes = mc.ls(sl=True, long=True)
#Get Vertex Count as INT
verts = mc.polyEvaluate(Meshes[0],v=True)
prevLoc = []
for x in range(verts):
prevLoc.append(mc.pointPosition(Meshes[0]+'.vtx[{x}]'.format(x=x)))
count = 1
count2 = 2
#mc.setKeyframe('pPlane1', v = 1, at = "visibility")
while(currentFrame < endFrame):
if currentFrame == startFrame:
print 'plane 1 hidden'
mc.setKeyframe('pPlane1', v = 0, at = "visibility")
mc.setKeyframe('Base', v = 0, at = "visibility")
#print "the Frame is currently at %d" % currentFrame
unSel = mc.select(cl=True)
sel = mc.select('pPlane1',r=True)
Meshes2 = mc.ls(sl=True, long=True)
verts3 = mc.polyEvaluate(Meshes2,v=True)
arrVertLoc = []
for i in range(verts3):
arrVertLoc.append(mc.pointPosition(Meshes2[0]+'.vtx[{i}]'.format(i=i)))
dist = ( (prevLoc[i][0]-arrVertLoc[i][0])**2 + (prevLoc[i][1]-arrVertLoc[i][1])**2 + (prevLoc[i][2]-arrVertLoc[i][2])**2 )**0.5
print dist
color = mc.polyColorPerVertex(Meshes2[0]+'.vtx[{i}]'.format(i=i), rgb=(0,0,1))
if dist < 0.3:
print "Ziiiiing"
R = 0
R = 0
R = 0
elif dist >= 0.3:
R = dist + .75
#print 'R = %f' % R
G = 1/dist * 0.5
#print 'G = %f' % G
B = 0
#print 'R %f ' % R
#print 'G %f ' % G
#print 'B %f ' % B
color = mc.polyColorPerVertex(Meshes2[0]+'.vtx[{i}]'.format(i=i), rgb=(R,G,B))
#color = mc.polyColorPerVertex(Meshes2[0]+'.vtx[{i}]'.format(i=i), rgb=(arrVertColor,arrVertColor,arrVertColor))
nnewMesh = mc.duplicate( Meshes2[0], ic=False)
mc.constructionHistory( Meshes2[0], tgl = False)
#mc.setAttr('pPlane %d'%count+".visibility", 1)
mc.setKeyframe('pPlane %d'%count2, v = 0, at = "visibility")
if currentFrame == endFrame:
mc.setKeyframe('pPlane1', v = 1, at = "visibility")
mc.currentTime(currentFrame)
currentFrame += 1
mc.setKeyframe('pPlane %d'%count2, v = 1, at = "visibility")
if currentFrame != startFrame:
mc.setKeyframe('pPlane %d'%count, v = 0, at = "visibility")
count += 1
count2 += 1
Update
Recently in Portfolio
- [K]ernels

- Nike A.I.R Prototypes

- [A]nisochromatic Meshing

- Nike After Dark Tour

- PARAPRAXIS

- [001.HRR] CONCEPT BIKE

- 2040:LUNAR.OUTPOST[a]

- HE.6 2020 Prototype

- CULEBRA.NET

- PYTORCH-CLASSIFIER

- Nike Zoom Superfly Elite

- BENGBU CITY OPERA

- Nike Footscape Flyknit DM

- Jordan Hyperdunk React

- KA-HELMET

- [C]ucarachas

- [S]eeker

- [O]h Baby

- [E]l Papa

- [S]hatter.Brain

- [S]tigmergy

- [F]orces

- CULEBRA.JAVA

- [C]ulebra.MultiBehaviors

- [S]ticky Stuff

- [S]entinels

- [G]allopingTopiary

- RELUXOED

- [SRC] . Semi Rigid Car

- [P]erlin

- [E]ternal Wanderers

- [W]heelie

- [S]labacube

- [M]esh Crawlers

- [L]a Silla

- [3]D BabyMaking Trackstars

- [3]D Trackers

- [2]D BabyMaking Trackers

- [T]rackers

- CULEBRA GRASSHOPPER

- culebra.[M]eshCrawlers.3D

- culebra.[H]ybrid.3D

- culebra.[F]lorgy

- culebra.[F]ockers.3D

- culebra.[F]ockers.2D

- culebra.[N]oisey.3D

- [E]l Nino

- culebra.[S]elfOrg

- [D]rippin

- culebra.[N]oisey.2D

- [C]reepyCrawlers

- [J]eepresesCreepers

- [T]2000

- PUFFER PLEATNESS

- EMERGEN[CY]

- [L]iquified

- [S]uckedComp

- [X]plosion

- MR. EW

- [H]airGoo

- [B]alled

- [n]injaStars

- [b]loomer

- [t]rip city

- TAPE GUNNED

- [B]oom

- [M]iller Time

- [D]elamjam

- [B]rain Zapper

- [B]ig Bird

- [E]gg Tube Pavillion

- [A]llice’s Easter Tree

- [S]weet Honey

- [U]M.Urgent

- [t]oo.urgent

- [B]onnie..+..Clyde

- [B]io Mess

- [EL]Mojado.Virus

- [W]HAT the …!

- [H]ot Lava

- [P]leat Diddy

- [t]erminator easter egg

- Mr. BB

- [B]less You

- [F]antastic + Interactive

- [S]oo_Minimally_Pathed

- [P]uffer Fish.Fab

- [M]an Eater

- [AHH] Alien House Hunters

- [W]eave Machine

- Sportbike Racing

- Grappling

- Kart Racing


Leave a reply