Пример #1
0
 def __init__(self, db):
     platform = tools.get_platform()
     if (platform == "Windows"):
         self.db = 'C:\\Ubuntu\\Shared\\data\\' + db
     elif (platform == "linux" or platform == 'Linux'):
         self.db = '/media/sf_Shared/data/' + db
     else:
         print("Platform " + platform +
               " not recognized in sqldb::DB. Exiting.")
         exit(-1)
     self.conn = sqlite3.connect(self.db)
     self.cursor = self.conn.cursor()
Пример #2
0
def reimport_file(file):
    # first detect if it's a descriptor file
    _, pure_filename = ntpath.split(file)
    extension = tools.path_leaf(pure_filename.split('.')[1])

    if pure_filename == tools.settings_file:
        print(f'   reimporting settings...')
        renderer_changed, renderer = tools.import_settings()

        if renderer_changed:
            print(f'   renderer type changed, reimporting everything...')
            asset_tools.build_assets(
                tools.get_platform(),
                tools.get_shadermodel_by_renderer(renderer), True)

        return

    if extension == 'toml':
        file, extension = get_original_file(file)

    asset = pure_filename.split('.')[0] + "." + extension

    ext = extension.lower()

    # now find what time of asset that is
    if ext in tools.shader_types:
        print(f'   reimporting shader...')
        if ext == 'sh':
            # TODO: find all the shaders that import the library and only recompile them
            print(
                f'   {bcolors.WARNING}shader library type modified, so building all shaders{bcolors.ENDC}'
            )
            shader.build_all('auto', 'auto', True)
        else:
            shader._build_shader(asset, {}, 'auto', 'auto', True)
    elif ext in tools.mesh_types:
        print(f'   reimporting mesh...')
        mesh._build_mesh(asset, {}, True)
    elif ext in tools.texture_types:
        print(f'   reimporting texture...')
        texture._build_texture(asset, {}, True)
    elif ext in tools.font_types:
        print(f'   reimporting font...')
        font._build_font(asset, {}, True)
    elif ext in tools.cubemap_types:
        print(f'   reimporting cubemap...')
        cubemap._build_cubemap(asset, {}, True)
    else:
        print(f'   file {asset} not reimported.')
Пример #3
0
def build_assets(platform, shader_model, force=False):
    p = tools.get_platform() if platform == 'auto' else platform
    print(
        f'\n{tools.bcolors.OKBLUE}BUILDING FOR PLATFORM: "{p}" AND SHADER MODEL "{shader_model}"{tools.bcolors.BOLD}{tools.bcolors.ENDC}\n'
    )

    build_shaders(platform, shader_model, force)
    build_textures(platform, force)
    build_meshes(platform, force)
    build_cubemaps(platform, force)
    build_fonts(platform, force)

    descriptor_path = tools.save_descriptor(asset_descriptor)
    print(
        f'\n{tools.bcolors.OKBLUE}ASSET DESCRIPTOR WRITTEN AT: {tools.bcolors.ENDC}{tools.bcolors.BOLD}{descriptor_path}{tools.bcolors.ENDC}'
    )
Пример #4
0
def build_shader(shaderfile, dest, options, platform, model, force=False):
    print(f" - Compiling {bcolors.UNDERLINE}'{shaderfile}'{bcolors.ENDC}")
    output_file = os.path.join(dest, tools.path_leaf(shaderfile))

    descriptor_filename, descriptor = tools.load_asset_descriptor(
        shaderfile, tools.shader_descriptor_schema)

    if not force and not tools.check_should_build(output_file, shaderfile):
        print(f" {bcolors.WARNING}- SKIPPED{bcolors.ENDC}")
        return True, tools.path_leaf(shaderfile), output_file

    shadertype = "vertex" if shaderfile.split('.')[1] == 'vs' else "fragment"

    current_path_varying = os.path.join(
        ntpath.split(shaderfile)[0], varying_def)
    varying_def_path = current_path_varying if os.path.isfile(
        current_path_varying) else default_varying_def

    platform = tools.get_platform() if platform == 'auto' else platform

    if model == 'auto':
        renderer_changed, renderer = tools.import_settings()
        model = tools.get_shadermodel_by_renderer(renderer)

    if model.find('s_') > -1:
        model = ('p' if shadertype == 'fragment' else 'v') + model
    model_command = '--profile 410' if model == 'auto' else f'--profile {model}'

    command = "%s -f %s -o %s -i %s --varyingdef %s --platform %s %s --type %s" % (
        bgfx_shaderc, shaderfile, output_file, bgfx_source_folder,
        varying_def_path, platform, model_command, shadertype)

    success = False
    if not os.system(command):
        success = True
        print(
            f" {bcolors.SUCCESS}- Shader compiled for `{model}`: {output_file}{bcolors.ENDC}"
        )
        tools.save_built_asset_descriptor(output_file, descriptor)

    if not success:
        raise Exception(
            f"Shader '{shaderfile}' was not built due to a compilation error.")

    return success, tools.path_leaf(shaderfile), output_file
Пример #5
0
import os
import argparse
import glob
import ntpath
from shutil import copyfile
from functools import reduce

import tools
from tools import bcolors

models_path = os.path.join(os.getcwd(), tools.root_dir, tools.dirs['models'])
models_build_path = os.path.join(os.getcwd(), tools.build_dir,
                                 tools.dirs['models'])

tools_dir = os.path.dirname(os.path.realpath(__file__))
bgfx_tools_dir = os.path.join(tools_dir, 'bgfx-tools', tools.get_platform())
bgfx_geometryc = os.path.join(bgfx_tools_dir, 'geometryc')
bgfx_geometryv = os.path.join(bgfx_tools_dir, 'geometryv')


def build_mesh(meshfile, dest, options, force=False):
    print(f" - Compiling {bcolors.UNDERLINE}'{meshfile}'{bcolors.ENDC}")
    output_file = os.path.join(
        dest,
        tools.path_leaf(meshfile.split('.')[0]) + '.obj')

    descriptor_filename, descriptor = tools.load_asset_descriptor(
        meshfile, tools.mesh_descriptor_schema)

    if not force and not tools.check_should_build(output_file, meshfile):
        print(f" {bcolors.WARNING}- SKIPPED{bcolors.ENDC}")
Пример #6
0
import tools

platform = tools.get_platform()
print(platform)

exit(0)