//
// Asura_GX_Shape.h
//
// Created by KOR - 09 October 2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_GX_SHAPE_H__
#define __ASURA_GX_SHAPE_H__

#include "Core/Asura_HashTree.h"
#include "Core/Asura_Maths.h"

struct Asura_GX_Shape_Vertex
{
	Asura_Vector_3	m_xPosition;	// 12
	Asura_Vector_3	m_xNormal;		// 12
	float			m_fU;			// 4
	float			m_fV;			// 4
									// 32
};

class Asura_GX_Shape
{
public:
	Asura_GX_Shape();
	~Asura_GX_Shape();
	void LoadFromChunk(Asura_Handle iFileHandle);
	void RenderSetup(float fAlpha) const;
	void Render() const;
	u_int GetMaterialID() const { return m_iMaterialID; }
private:
	u_int m_iMaterialID;
	u_int m_uNumberOfIndices;
	u_int m_uNumberOfVertices;
	Asura_GX_Shape_Vertex* m_pxVertices;
	unsigned short* m_pusIndices;
};

class Asura_GX_ShapeRenderer
{
public:
	static void Initialise();
	static void Update();
	static void Reset();
	static void Shutdown();
	static bool AddShape(Asura_Handle iFileHandle);
	static void RenderShape(Asura_Hash_ID uHashID, u_int uCamVisFlags, const Asura_Vector_3& xPos, const Asura_Matrix_3x3& xOri, float fAlpha);
	static const Asura_GX_Shape* GetShape(Asura_Hash_ID uHashID);
	static int GetShapeMaterial(Asura_Hash_ID uHashID);
private:
	static Asura_TemplateHashTree<Asura_GX_Shape> s_xHashTree;
};

#endif//__ASURA_GX_SHAPE_H__