//
// Asura_Xbox360_ObjectRenderer.h
//
// Created by KJFL - 09 November 2005
//
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#if !defined __ASURA_XBOX360_OBJECTRENDERER_H__
#define __ASURA_XBOX360_OBJECTRENDERER_H__

/******************************************************************************/
/* Included Files                                                             */
/******************************************************************************/

// Asura Platform-independent
#include "Core/Asura_HashTree.h"

// Asura Xbox 360
#include "Rendering/Asura_Xbox360_IndexBuffer.h"
#include "Rendering/Asura_Xbox360_VertexBuffer.h"

/******************************************************************************/
/* Classes                                                                    */
/******************************************************************************/

class Asura_Shadow;
class Asura_Shape;
class Asura_Shape_Instance;

////////////////////////////////////////////////////////////////////////////////
//
// Asura_Xbox360_ObjectRenderer
//
// Manages rendering of objects on Xbox 360
//
////////////////////////////////////////////////////////////////////////////////

class Asura_Xbox360_ObjectRenderer
{
	friend class Asura_Chunk_ResourceFile_Xbox360_Object;

public:

	static void Initialise();
	static void Reset();
	static void Shutdown();

	static int GetMaterialIndex( const Asura_Shape& xShape );
	static void RenderObject( const Asura_Shape& xShape, const Asura_Shape_Instance& xShapeInstance, const u_int uAmbientARGB );
	static void RenderShadow( const Asura_Shape& xShape, const Asura_Shape_Instance& xShapeInstance, const Asura_Shadow& xShadow );

protected:

	// Types

	struct Strip
	{
		Asura_Hash_ID	m_auMaterialResponseHashIDs[2];
		u_int			m_uStartIndex;
		u_int			m_uNumberOfIndices;
		u_int			m_uNumberOfTriangles;
	};

	class Object
	{
		friend class Asura_Chunk_ResourceFile_Xbox360_Object;
		friend class Asura_Xbox360_ObjectRenderer;

	public:

		// Constructor / destructor
		Object();
		~Object();

	protected:

		// Data

		Asura_Xbox360_IndexBuffer	m_xIndexBuffer;
		Asura_Xbox360_VertexBuffer	m_xVertexBuffer;

		u_int						m_uNumberOfStrips;
		Strip*						m_pxStrips;
	};

	// Static functions
	static Object* CreateObject( const Asura_Hash_ID uHashID );

	// Static data
	static Asura_TemplateHashTree<Object> s_xObjectTree;
};

#endif // !defined __ASURA_XBOX360_OBJECTRENDERER_H__
