//
// Tools_PC_Export.h
//
// Created by KJL - 12/04/2003 13:16:26
//
// Copyright (C) 2003 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#ifndef __TOOLS_PC_EXPORT_H__
#define __TOOLS_PC_EXPORT_H__

#include "Core/Asura_MemoryManagement_DebugOff.h"
#include <d3dx9.h>
#include "Core/Asura_MemoryManagement_DebugOn.h"

#include <windows.h>

class Asura_Direct3D_Effect;
class Asura_HashTree;
class Asura_Hierarchy_Skin;
class Asura_Mesh;
class Asura_SaveBlock;
class Asura_String;
class Asura_Vector_3;

struct ID3DXBuffer;

class Tools_PC_Export
{
	public:
		
		static void ExportEnvironment( HANDLE hOutput );
#ifdef ASURA_TARGET_SM3
		static void ExportEnvironment_SM3( HANDLE hOutput );
#endif
#if !defined(ASURA_PC_DISABLE_PRESM3_SMOOTH_SKIN_RENDERER) || !ASURA_PC_DISABLE_PRESM3_SMOOTH_SKIN_RENDERER
		static bool ExportCharacter( HANDLE hOutput, const Asura_Hierarchy_Skin* pxSkin );
#endif
		static bool ExportObjectHierarchy(HANDLE hOutput, const Asura_Hierarchy_Skin* pxSkin);
		static bool ExportObject(HANDLE hOutput, Asura_Mesh* pxMesh, const Asura_Hash_ID uHashID,int iMaterialIndex, const Asura_Hash_ID uMaterialResponseHashID = ASURA_HASH_ID_UNSET);

#if defined(ASURA_PC_USE_SHADER_MODEL_3_SMOOTH_SKIN_RENDERER) && ASURA_PC_USE_SHADER_MODEL_3_SMOOTH_SKIN_RENDERER
		static bool ExportSmoothSkin( HANDLE hOutput, const Asura_Hierarchy_Skin* pxSkin );
#endif
#ifdef ASURA_TARGET_SM3
		static bool ExportSkin( const HANDLE hOutput, Asura_Hierarchy_Skin& xSkin );
#endif

		// some utility functions for compressing values
		static u_int CompressNormalToUByte4(Asura_Vector_3 xNormal);
		static short CompressTexCoordToShort(float fTexCoord, bool& bOutOfRange);

#if defined ASURA_USE_MATERIAL_RESPONSE_SYSTEM
		static bool ExportMaterialResponses( Asura_SaveBlock& xSaveBlock, Asura_HashTree* const pxMaterialsToExport );
		static bool BeginMRPShaderExport();
		static bool EndMRPShaderExport( const HANDLE xExportHandle );

		//Clears the bits from the pixel shader hash which correspond to the second material. RAR 16/06/2008
		static Asura_Hash_ID GetMRPShaderHashWithoutDualPass(const Asura_Hash_ID uPSHash) {return uPSHash & 0xfff55555;}
#endif

#if defined ASURA_USE_STATIC_DECAL_SYSTEM
		static bool ExportStaticDecals( const HANDLE hOutput );
#endif
	private:

		static bool WriteObjectDataToChunk(HANDLE hOutput, const Asura_Mesh* pxMesh,const Asura_String& xName, const Asura_Hash_ID uHashID);
};


#endif//__TOOLS_PC_EXPORT_H__
