Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions data/apfData.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApfData( data.Data ):
'''
Apf data class definition
'''

def __init__(self,apfFile=''):
'''
Apf data class initializer
Expand All @@ -16,14 +16,14 @@ def __init__(self,apfFile=''):
'''
# Execute Super Class Initilizer
super(ApfData, self).__init__()

# Initialize Data Type
self.dataType = 'ApfData'

if apfFile: self.read(apfFile)

self.apfChan = ['tx','ty','tz','rx','ry','rz']

def read(self,apfFile):
'''
@param apfFile: Apf file to load.
Expand All @@ -32,33 +32,33 @@ def read(self,apfFile):
# Check File
if not os.path.isfile(apfFile):
raise Exception('Apf file "'+apfFile+'" is not a valid path!')

# Read File
f = open(apfFile,'r')

# Sort Data
char = ''
for line in f:

# Get Line Data
lineData = line.split()

# Skip Empty Lines
if not lineData: continue

# Check BEGIN
if lineData[0] == 'BEGIN':
char = lineData[1]
self._data[char] = {}
continue

# Check Character
if not char: continue

# Parse Line Data
lineObj = lineData[0]
lineVal = [float(i) for i in lineData[1:]]
self._data[char][lineObj] = lineVal
self._data[char][lineObj] = lineVal

def processDir(srcDir):
'''
Expand All @@ -69,31 +69,31 @@ def processDir(srcDir):
# Check Source Directory
if not os.path.isdir(srcDir):
raise Exception('Source directory "'+srcDir+'" is not a valid path!')

# Start Timer
timer = mc.timerX()

# Find all APF files
apfFiles = [i for i in os.listdir(srcDir) if i.endswith('.apf')]
apfFiles.sort()
bpfFiles = []
for apfFile in apfFiles:

# Check File
srcFile = srcDir+'/'+apfFile
if not os.path.isfile(srcFile):
raise Exception('Apf file "'+srcFile+'" is not a valid path!')

print apfFile

apfData = ApfData(srcFile)
bpfFile = apfData.save(srcFile.replace('.apf','.bpf'))
bpfFiles.append(bpfFile)

# Print Result
totalTime = mc.timerX(st=timer)
print 'Total time: '+str(totalTime)

# Return Result
return bpfFiles

Expand All @@ -108,33 +108,33 @@ def loadAnim(srcDir,agentNS):
# Check Source Directory
if not os.path.isdir(srcDir):
raise Exception('Source directory "'+srcDir+'" is not a valid path!')

# Start Timer
timer = mc.timerX()

# Load Agent Animation
bpfFiles = [i for i in os.listdir(srcDir) if i.endswith('.bpf')]
bpfIndex = [int(i.split('.')[1]) for i in bpfFiles]
bpfIndex.sort()

# For Each File
apfChan = ['tx','ty','tz','rx','ry','rz']
for ind in bpfIndex:
data = ApfData().load(srcDir+'/frame.'+str(ind)+'.bpf')
if data._data.has_key(agentNS):
for item in data._data[agentNS].iterkeys():

# Check Agent:Item Exists
if not mc.objExists(agentNS+':'+item): continue

# Load Anim Channels
if item == 'Hips':
for i in range(3):
mc.setKeyframe(agentNS+':'+item,at=apfChan[i],t=ind,v=data._data[agentNS][item][i])
for i in range(3,6):
mc.setKeyframe(agentNS+':'+item,at=apfChan[i],t=ind,v=data._data[agentNS][item][i])


# Print Result
totalTime = mc.timerX(st=timer)
print 'Total time: '+str(totalTime)
32 changes: 16 additions & 16 deletions data/buildData.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,63 @@ def buildDeformerData(deformer):
# ==========
# - Checks -
# ==========

# Check Deformer
if not glTools.utils.deformer.isDeformer(deformer):
raise Exception('Object "'+deformer+'" is not a valid deformer!')

# Get Deformer Type
deformerType = mc.objectType(deformer)

# ============================
# - Initialize Deformer Data -
# ============================

dData = glTools.data.deformerData.DeformerData()

# Cluster
if deformerType == 'cluster':
dData = glTools.data.clusterData.ClusterData()

# CurveTwist
if deformerType == 'curveTwist':
dData = glTools.data.clusterData.ClusterData()

# DirectionalSmooth
if deformerType == 'directionalSmooth':
dData = glTools.data.deformerData.DirectionalSmoothData()

# SkinCluster
elif deformerType == 'skinCluster':
dData = glTools.data.skinClusterData.SkinClusterData()

# StrainRelaxer
if deformerType == 'strainRelaxer':
dData = glTools.data.deformerData.StrainRelaxerData()

# SurfaceSkin
elif deformerType == 'surfaceSkin':
dData = glTools.data.surfaceSkinData.SurfaceSkinData()

# Wire
elif deformerType == 'wire':
dData = glTools.data.wireData.WireData()

# Unsupported Type !!
else:
print('Using base DeformerData class for "'+deformerType+'" deformer "'+deformer+'"!')

# =======================
# - Build Deformer Data -
# =======================

try:
dData.buildData(deformer)
except:
raise Exception('DeformerData: Error building data object for deformer "'+deformer+'"!')

# =================
# - Return Result -
# =================

return dData
Loading