#!/usr/bin/env omake
#----------------------------------------------------------------------------
# Project:  NintendoWare
# File:     OMakefile
#
# Copyright (C)2009-2012 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.
#
# $Revision: $
#----------------------------------------------------------------------------

GFX_CONVERTER = $(NW4C_ROOT)/tools/CreativeStudio/NW4C_CreativeStudioConsole.exe
H3D_CONVERTER = $(NW4C_ROOT)/tools/H3dTools/x86/NW4C_bcres2bch.exe

H3dBinaryObject(ofile, files, skeletalAnims, option) =
    
    bcres = $(absname bcres/$(ofile).bcres)
    bch   = $(absname bch/$(ofile).bch)
    
    $(bch): $(files) $(skeletalAnims) $(GFX_CONVERTER) $(H3D_CONVERTER) :effects: $(bcres)
        mkdir -p $(dirname $(bcres))
        $(GFX_CONVERTER) --auto_create_shader=off -o=$(bcres) $(filter-out %.exe, $^)
        
        mkdir -p $(dirname $(bch))
        $(H3D_CONVERTER) $(bcres) -o $(bch) $(option) $(addprefix --im-file=, $(skeletalAnims))
    return $(bch)

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

BASE_OPTION   = -s --strip-shader --disable-scale-anim-fully

###########################
# Actor0

ACTOR0_BASE_PATH = $(NW4C_ROOT)/SampleData/Graphics/Intermediate/H3dResource/Male

ACTOR0_FILES[] = 
                $(ACTOR0_BASE_PATH)/Male.cmdl
                $(ACTOR0_BASE_PATH)/Male.clts
                $(ACTOR0_BASE_PATH)/Male.ctex

ACTOR0_SKELETAL_ANIMS[] =
                $(ACTOR0_BASE_PATH)/Walk.cskla

ACTOR0_OPTION = $(BASE_OPTION)


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

SHAREDDATA_FILES[] =
                $(NW4C_ROOT)/shaders/nwh3d_DefaultShader.csdr

SHAREDDATA_SKELETAL_ANIMS[] =

SHAREDDATA_OPTION = --data-size-level 2


###########################
# sprite

SPRITE_BASE_PATH = $(NW4C_ROOT)/SampleData/Graphics/Intermediate/H3dResource/Sprite

SPRITE_FILES[] = 
                $(SPRITE_BASE_PATH)/DebugFont.ctex
                $(SPRITE_BASE_PATH)/DebugHud.ctex

SPRITE_SKELETAL_ANIMS[] =

SPRITE_OPTION = $(BASE_OPTION)


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

H3D_FILES[]   =
                $(H3dBinaryObject Actor0, $(ACTOR0_FILES), $(ACTOR0_SKELETAL_ANIMS), $(ACTOR0_OPTION))
                $(H3dBinaryObject SharedData, $(SHAREDDATA_FILES), $(SHAREDDATA_SKELETAL_ANIMS), $(SHAREDDATA_OPTION))
                $(H3dBinaryObject DemoResource, $(SPRITE_FILES), $(SPRITE_SKELETAL_ANIMS), $(SPRITE_OPTION))

build:  $(H3D_FILES)

DefineDefaultRules()
