Example #1
0
    def _generate_unityruntime_jar_file(self, force_dont_proguard=False):
        common.LOGI(
            self.TAG,
            "Generating runtime sdk jar file ..., force_dont_proguard:" +
            str(force_dont_proguard))

        common.ensure_folder_exists(self.debug_directory)

        proguard_file_path = "None"
        mapping_file_path = "None"
        if not force_dont_proguard and self.proguard:
            proguard_file_path = os.path.join(self.script_path,
                                              "proguard-unityruntime.txt")
            mapping_file_path = os.path.join(
                self.debug_directory,
                "mapping-libunityruntime-" + self.version + ".txt")

        common.run_command(
            "python " +
            os.path.join(self.script_path, "../jar-maker/JarMaker.py") +
            " -s " + self.proj_unityruntime_dir_src_dir + " -s " +
            self.proj_gplayenginebridge_src_dir + " -o " + self.out_dir_temp +
            " -f " + os.path.split(self.sdk_jar_no_dex_obfuscated_path)[-1] +
            " --ref-lib " + os.path.join(self.script_path, "..", "common",
                                         "lib", "android.jar") + " -p " +
            proguard_file_path + " -m " + mapping_file_path)
    def _generate_cocosruntime_jar_file(self):
        common.ensure_folder_exists(self.debug_directory)

        common.run_command(
            "python " +
            os.path.join(self.script_path, "../jar-maker/JarMaker.py") +
            " -s " + self.proj_gplayenginebridge_src_dir + " -s " +
            self.proj_cocosruntime_src_dir + " -o " + self.out_dir + " -f " +
            os.path.split(self.sdk_jar_no_dex_obfuscated_path)[-1] +
            " --ref-lib " + os.path.join(self.script_path, "..", "common",
                                         "lib", "android.jar") +
            " --ref-lib " + os.path.join(self.script_path, "..", "common",
                                         "lib", "annotations.jar"))
Example #3
0
def batch_test_erosion_dilation(input_models, output_json):
    """
    Batch test erosion vs dilation on various dexel sizes, with 2 different radii.

    Args:
        input_models (list): List of input models to test on.
        output_json (str): Destination file for the result data.
    """
    database = {}
    # Results for different number of dexels and different radii
    for model_path in input_models:
        model_name = os.path.split(model_path)[1]
        model_data = []
        for n in array_num_dexels:
            for r in array_radii:
                # Dilation
                args_dilation = [
                    common.exe_path, '--input', model_path, '--num_dexels',
                    str(n), '--radius',
                    str(r * n), '--padding',
                    str(math.ceil(r * n)), '--num_thread',
                    str(3), '--json', common.tmp_json, '--force'
                ]
                subprocess.check_call(args_dilation)
                with open(common.tmp_json, 'r') as f:
                    entry = json.load(f)
                    entry['radius_relative'] = r
                    model_data.append(entry)
                # Erosion
                args_erosion = [
                    common.exe_path, '--input', model_path, '--num_dexels',
                    str(n), '--radius',
                    str(r), '--padding',
                    str(math.ceil(r * n)), '--num_thread',
                    str(3), '--json', common.tmp_json, '--force', '--apply',
                    'erosion'
                ]
                subprocess.check_call(args_erosion)
                with open(common.tmp_json, 'r') as f:
                    entry = json.load(f)
                    entry['radius_relative'] = r
                    model_data.append(entry)
        database[model_name] = model_data
    # Write results in a file
    json_filename = os.path.join(common.result_folder, output_json)
    common.ensure_folder_exists(json_filename)
    with open(json_filename, 'w') as f:
        f.write(json.dumps(database, indent=4))
Example #4
0
def comparasion_dilation(input_models, output_json):
    """
    Comparasion with the method mentioned in Wang's paper

    Args:
        input_models (list): List of input models to test on.
        output_json (str): Destination file for the result data.
    """
    database = []
    # Results for different number of dexels and different radii
    for model_path in input_models:
        model_name = os.path.split(model_path)[1]
        assert (model_name in map_radii.keys())
        for num_dexels in array_num_dexels:
            for num_threads in array_num_threads:
                for i, r in enumerate(array_radii):
                    r_mm = map_radii[model_name][i]
                    # Dilation
                    args_dilation = [
                        common.exe_path, '--input', model_path, '--num_dexels',
                        str(num_dexels), '--radius',
                        str(r_mm), '--padding',
                        str(math.ceil(r_mm * num_dexels)), '--num_thread',
                        str(num_threads), '--json', common.tmp_json,
                        '--output', 'tmp.ply', '--radius_in_mm', '--force'
                    ]
                    subprocess.check_call(args_dilation)
                    with open(common.tmp_json, 'r') as f:
                        entry = json.load(f)
                        entry['radius_relative'] = r
                        entry['radius_mm'] = r_mm
                        entry['model'] = model_name
                        database.append(entry)
    # Write results in a file
    json_filename = os.path.join(common.result_folder, output_json)
    common.ensure_folder_exists(json_filename)
    with open(json_filename, 'w') as f:
        f.write(json.dumps(database, indent=4))
Example #5
0
def batch_test_radius(input_models, output_json):
    """
    Batch test the effect of varying radii, with a number of dexels of 512.

    Args:
        input_models (list): List of input models to test on.
        output_json (str): Destination file for the result data.
    """
    n = 512  # Number of dexels
    database = {}
    # Results for different radii
    for model_path in input_models:
        model_name = os.path.split(model_path)[1]
        model_data = []
        for r in array_radii:
            for method in array_method:
                for k in array_num_threads:
                    args = [
                        common.exe_path, '--input', model_path, '--num_dexels',
                        str(n), '--radius',
                        str(r * n), '--padding',
                        str(math.ceil(r * n)), '--num_thread',
                        str(k), '--json', common.tmp_json, '--force',
                        '--method', method
                    ]
                    print(' '.join(args))
                    subprocess.check_call(args)
                    with open(common.tmp_json, 'r') as f:
                        entry = json.load(f)
                        entry['radius_relative'] = r
                        model_data.append(entry)
        database[model_name] = model_data
    # Write results in a file
    json_filename = os.path.join(common.result_folder, output_json)
    common.ensure_folder_exists(json_filename)
    with open(json_filename, 'w') as f:
        f.write(json.dumps(database, indent=4))
    def _generate_gplaysdk_jar_file(self):
        common.ensure_folder_exists(self.debug_directory)

        proguard_file_path = "None"
        mapping_file_path = "None"
        if self.proguard:
            proguard_file_path = os.path.join(self.script_path,
                                              "proguard-gplaysdk.txt")
            mapping_file_path = os.path.join(
                self.debug_directory,
                "mapping-gplaysdk-" + self.version + ".txt")

        common.run_command(
            "python " +
            os.path.join(self.script_path, "../jar-maker/JarMaker.py") +
            " -s " + self.proj_gplayunitsdkplugin_src_dir + " -s " +
            self.proj_gplayruntimebridge_src_dir + " -s " +
            self.proj_gplaysdk_src_dir + " -o " + self.out_dir + " -f " +
            os.path.split(self.sdk_jar_no_dex_obfuscated_path)[-1] +
            " --ref-lib " + os.path.join(self.script_path, "..", "common",
                                         "lib", "android.jar") +
            " --ref-lib " + os.path.join(self.script_path, "..", "common",
                                         "lib", "annotations.jar") + " -p " +
            proguard_file_path + " -m " + mapping_file_path)