#!/usr/bin/env omake
#----------------------------------------------------------------------------
# Project:  NintendoWare
#
# Copyright (C)Nintendo/HAL Laboratory, Inc.  All rights reserved.
#
# These coded instructions, statements, and computer programs contain proprietary
# information of Nintendo and/or its licensed developers and are protected by
# national and international copyright laws. They may not be disclosed to third
# parties or copied or duplicated in any form, in whole or in part, without the
# prior written consent of Nintendo.
#
# The content herein is highly confidential and should be handled accordingly.
#----------------------------------------------------------------------------

GFX_CONVERTER     = $(NW4C_ROOT)/h3d/tool/bin/CreativeStudio/NW4C_CreativeStudioConsole.exe
H3D_CONVERTER_OLD = $(NW4C_ROOT)/h3d/tool/bin/NW4C_bcres2bch.exe
H3D_CONVERTER     = $(NW4C_ROOT)/h3d/tool/bin/NW4C_h3dbincvtr.exe

H3dBinaryObjectOld(ofile, files, skeletalAnims, option) =
    private.bcres = $(absname bcres/$(ofile).bcres)
    private.bch   = $(absname bch/$(ofile).bch)

    $(bch): $(files) $(skeletalAnims) $(GFX_CONVERTER) $(H3D_CONVERTER_OLD) :effects: $(bcres)
        mkdir -p $(dirname $(bcres))
        $(GFX_CONVERTER) --auto_create_shader=off -o=$(bcres) $(filter-out %.exe, $^)

        mkdir -p $(dirname $(bch))
        $(H3D_CONVERTER_OLD) $(bcres) -o $(bch) $(option) $(addprefix --im-file=, $(skeletalAnims))
    return $(bch)


H3dBinaryObject(ofile, files, option) =
    private.bch   = $(absname bch/$(ofile).bch)
    $(bch): $(files) $(H3D_CONVERTER)
        mkdir -p $(dirname $(bch))
        $(H3D_CONVERTER) --output=$(bch) $(option) $(files)
    return $(bch)


SetupScript(script, outputDir, files) =
    private.ofiles = $(addprefix $(outputDir)$(DIRSEP), $(files))
    $(ofiles): $(COMMON_RESOURCES)
        $(script)
    return $(ofiles)

############################################################################

BASE_OPTION_OLD   = -s 2 --strip-shader
BASE_OPTION   = -so -ss

BCH_FILES =

SAMPLE_RESOURCE_BASE = $(NW4C_ROOT)/h3d/demo/data


###########################
# ToyPierrot

BCH_FILES +=
    private.bch       = ToyPierrot
    private.base_path = $(SAMPLE_RESOURCE_BASE)/ToyPierrot
    private.sources[] =
                        $(base_path)/ToyPierrot.cmdl
                        $(base_path)/ToyPierrotAllNmap.ctex
                        $(base_path)/ToyPierrotAll.ctex
                        $(base_path)/ToyPierrotEye.0.ctex
                        $(base_path)/ToyPierrotEye.1.ctex
                        $(base_path)/ToyPierrotEye.2.ctex
                        $(base_path)/ToyPierrotStickRed.ctex
                        $(base_path)/ToyRoomCube.ctex
                        $(base_path)/ToyAllLut.clts
                        $(base_path)/ToyPierrotAnimDance.cskla
    private.options   = $(BASE_OPTION)

    value $(H3dBinaryObject $(bch), $(sources), $(options))

###########################
# shared data ( shader )

BCH_FILES +=
    private.bch       = SharedData
    private.base_path =
    private.sources[] =
                        $(NW4C_ROOT)/h3d/$(SUBDIR_SHADER)/nwh3d_DefaultShader2.csdr
                        $(NW4C_ROOT)/h3d/$(SUBDIR_SHADER)/nwh3d_SilhouetteShader.csdr
    private.options   =

    value $(H3dBinaryObject $(bch), $(sources), $(options))
    
###########################
# sprite

BCH_FILES +=
    private.bch       = DemoResource
    private.base_path = $(SAMPLE_RESOURCE_BASE)/Sprite
    private.sources[] =
                        $(base_path)/DebugFont.ctex
                        $(base_path)/DebugHud.ctex
    private.options   = $(BASE_OPTION)

    value $(H3dBinaryObject $(bch), $(sources), $(options))    

############################################################################

build: $(BCH_FILES) 

DefineDefaultRules()
