DNA Calib 1.1
Project brief
Functions
clear_blend_shapes Namespace Reference

Functions

def loadDNA (path)
 
def saveDNA (reader, path)
 
def calibrateDNA (inputPath, outputPath)
 
def main ()
 

Function Documentation

◆ calibrateDNA()

def clear_blend_shapes.calibrateDNA (   inputPath,
  outputPath 
)
28def calibrateDNA(inputPath, outputPath):
29 dna = loadDNA(inputPath)
30
31 # Copies DNA contents and will serve as input/output parameter to command
32 calibrated = dnac.DNACalibDNAReader(dna)
33
34 mesh_count = calibrated.getMeshCount()
35 print("Number of meshes: {}".format(mesh_count))
36
37 for mesh_index in range(mesh_count):
38 bs_tgt_count = calibrated.getBlendShapeTargetCount(mesh_index)
39 print("Number of blendshape targets for mesh {}({}): {}".format(calibrated.getMeshName(mesh_index), mesh_index, bs_tgt_count))
40 for bs_tgt_index in range(bs_tgt_count):
41 bs_tgt_delta_count = calibrated.getBlendShapeTargetDeltaCount(mesh_index, bs_tgt_index)
42 print("Number of blendshape target deltas for mesh {}({}), blend shape target {}: {}".format(calibrated.getMeshName(mesh_index), mesh_index, bs_tgt_index, bs_tgt_delta_count))
43
44 print("Blend shape channel LODs: {}".format(calibrated.getBlendShapeChannelLODs()))
45 print("Blend shape channel input indices: {}".format(calibrated.getBlendShapeChannelInputIndices()))
46 print("Blend shape channel output indices: {}".format(calibrated.getBlendShapeChannelOutputIndices()))
47
48 # Clears all blend shapes
50
51 print("\n\nClearing blend shape data...\n\n")
52 # Modifies calibrated DNA in-place
53 command.run(calibrated)
54
55 for mesh_index in range(mesh_count):
56 bs_tgt_count = calibrated.getBlendShapeTargetCount(mesh_index)
57 for bs_tgt_index in range(bs_tgt_count):
58 bs_tgt_delta_count = calibrated.getBlendShapeTargetDeltaCount(mesh_index, bs_tgt_index)
59 if bs_tgt_delta_count != 0:
60 raise RuntimeError("Blend shape target deltas not removed properly!")
61
62 bs_channel_lods = calibrated.getBlendShapeChannelLODs()
63 bs_channel_input_indices = calibrated.getBlendShapeChannelInputIndices()
64 bs_channel_output_indices = calibrated.getBlendShapeChannelOutputIndices()
65
66 if (len(bs_channel_lods) != 0) or (len(bs_channel_input_indices) != 0) or (len(bs_channel_output_indices) != 0):
67 raise RuntimeError("Blend shape animation data not removed properly!")
68
69 print("Number of meshes: {}".format(mesh_count))
70
71 for mesh_index in range(mesh_count):
72 bs_tgt_count = calibrated.getBlendShapeTargetCount(mesh_index)
73 print("Number of blendshape targets for mesh {}({}): {}".format(calibrated.getMeshName(mesh_index), mesh_index, bs_tgt_count))
74 for bs_tgt_index in range(bs_tgt_count):
75 bs_tgt_delta_count = calibrated.getBlendShapeTargetDeltaCount(mesh_index, bs_tgt_index)
76 print("Number of blendshape target deltas for mesh {}({}), blend shape target {}: {}".format(calibrated.getMeshName(mesh_index), mesh_index, bs_tgt_index, bs_tgt_delta_count))
77
78 print("Blend shape channel LODs: {}".format(bs_channel_lods))
79 print("Blend shape channel input indices: {}".format(bs_channel_input_indices))
80 print("Blend shape channel output indices: {}".format(bs_channel_output_indices))
81
82 print("\n\nSuccessfully cleared blend shape data.")
83
84 print("Saving DNA...")
85 saveDNA(calibrated, outputPath)
86 print("Done.")
87
ClearBlendShapesCommand is used to clear all blend shapes data from a DNA.
Definition: ClearBlendShapesCommand.h:19
Definition: DNACalibDNAReader.h:12
def saveDNA(reader, path)
Definition: clear_blend_shapes.py:18
def loadDNA(path)
Definition: clear_blend_shapes.py:8
def calibrateDNA(inputPath, outputPath)
Definition: clear_blend_shapes.py:28

References loadDNA(), and saveDNA().

Referenced by main().

◆ loadDNA()

def clear_blend_shapes.loadDNA (   path)
8def loadDNA(path):
9 stream = dna.FileStream(path, dna.FileStream.AccessMode_Read, dna.FileStream.OpenMode_Binary)
10 reader = dna.BinaryStreamReader(stream, dna.DataLayer_All)
11 reader.read()
12 if not dna.Status.isOk():
13 status = dna.Status.get()
14 raise RuntimeError("Error loading DNA: {}".format(status.message))
15 return reader
16
17
Definition: BinaryStreamReader.h:12
Standard file stream.
Definition: FileStream.h:13

Referenced by calibrateDNA().

◆ main()

def clear_blend_shapes.main ( )
88def main():
89 parser = argparse.ArgumentParser(description="DNACalib clear blend shapes example")
90 parser.add_argument('input_dna',
91 metavar='input-dna',
92 help='Path to DNA file to load')
93 parser.add_argument('output_dna',
94 metavar='output-dna',
95 help='Path where to save modified DNA file')
96
97 args = parser.parse_args()
98
99 calibrateDNA(args.input_dna, args.output_dna)
100
101
def main()
Definition: clear_blend_shapes.py:88

References calibrateDNA(), and main().

Referenced by main().

◆ saveDNA()

def clear_blend_shapes.saveDNA (   reader,
  path 
)
18def saveDNA(reader, path):
19 stream = dna.FileStream(path, dna.FileStream.AccessMode_Write, dna.FileStream.OpenMode_Binary)
20 writer = dna.BinaryStreamWriter(stream)
21 writer.setFrom(reader)
22 writer.write()
23
24 if not dna.Status.isOk():
25 status = dna.Status.get()
26 raise RuntimeError("Error saving DNA: {}".format(status.message))
27
Definition: BinaryStreamWriter.h:11

Referenced by calibrateDNA().