def main(): core.MY_PRINT_FUNC("Specify a VMD file to attempt parsing") core.MY_PRINT_FUNC( "Because MikuMikuDance pads with garbage, but I pad with zeros, the binary file I write back will not be exactly bitwise identical" ) core.MY_PRINT_FUNC( "But I can read the version I wrote and verify that the internal representation matches" ) input_filename = core.prompt_user_filename(".vmd") # input_filename = "vmdtest.vmd" Z = read_vmd(input_filename) write_vmd("____vmdparser_selftest_DELETEME.vmd", Z) ZZ = read_vmd("____vmdparser_selftest_DELETEME.vmd") core.MY_PRINT_FUNC("") bb = core.read_binfile_to_bytes(input_filename) bb2 = core.read_binfile_to_bytes("____vmdparser_selftest_DELETEME.vmd") core.MY_PRINT_FUNC("Is the binary EXACTLY identical to original?", bb == bb2) exact_result = Z == ZZ core.MY_PRINT_FUNC("Is the readback EXACTLY identical to original?", exact_result) if not exact_result: # boneframelist is different!!! but its just floating-point wibblyness caused by the quaternion transform math fuzzy_result = core.recursively_compare(Z, ZZ) core.MY_PRINT_FUNC("Is the readback ALMOST identical to the original?", not fuzzy_result) core.MY_PRINT_FUNC("Max difference between two floats:", core.MAXDIFFERENCE) core.MY_PRINT_FUNC( "Number of floats that exceed reasonable threshold 0.0005:", fuzzy_result) core.pause_and_quit("Parsed without error")
def main(): core.MY_PRINT_FUNC("Specify a vpd file to attempt parsing") input_filename = core.prompt_user_filename(".vpd") # input_filename = "vpdtest.vpd" Z = read_vpd(input_filename) write_vpd("____vpdparser_selftest_DELETEME.vpd", Z) ZZ = read_vpd("____vpdparser_selftest_DELETEME.vpd") core.MY_PRINT_FUNC("") bb = core.read_binfile_to_bytes(input_filename) bb2 = core.read_binfile_to_bytes("____vpdparser_selftest_DELETEME.vpd") # now compare bb (original binary) with bb2 (read-write) # now compare Z (first read) wtih ZZ (read-write-read) core.MY_PRINT_FUNC("Is the binary EXACTLY identical to original?", bb == bb2) exact_result = Z == ZZ core.MY_PRINT_FUNC("Is the readback EXACTLY identical to original?", exact_result) if not exact_result: # boneframelist is different!!! but its just floating-point wibblyness caused by the quaternion transform math fuzzy_result = core.recursively_compare(Z, ZZ) core.MY_PRINT_FUNC("Is the readback ALMOST identical to the original?", not fuzzy_result) core.MY_PRINT_FUNC("Max difference between two floats:", core.MAXDIFFERENCE) core.MY_PRINT_FUNC( "Number of floats that exceed reasonable threshold 0.0005:", fuzzy_result) core.pause_and_quit("Parsed without error")
def showprompt(): # print info to explain what inputs/outputs it needs/creates core.MY_PRINT_FUNC(iotext) # prompt PMX name core.MY_PRINT_FUNC("Please enter name of PMX model file:") input_filename_pmx = core.prompt_user_filename(".pmx") pmx = pmxlib.read_pmx(input_filename_pmx, moreinfo=True) return pmx, input_filename_pmx