#ifndef _CASEMODEL_H_
#define _CASEMODEL_H_

#include "../App/EngineH.h"
#include "../TextureManager/CTextureManager.h"

struct TMaterial
{
	std::string name;			// jmeno materialu
	std::string patch;			// cesta k texture
	uint		texture_id;
	uint		tm_id;
	int			flag;
};

struct T3DSpecPoint
{
	CVector3 pos;
	std::string name;
};

struct T_OBJECT_0
{
	std::string					name;
	int							iNumVertex;
	std::vector<CVector3>		vertex;
	std::vector<CVector2>		texture;
	std::vector<CVector3>		normal;				// kazdej vertex ma jednu normalu, face ma tri normaly
	uint						material;
	bool						ren_coord, ren_normals;
};

class C_ASEMODEL_0
{
private :
	void(C_ASEMODEL_0::*pRender)();
	int							_renMode;
	bool						_bVBO;
	int							_num_object;
	std::string					_sError;
	std::vector<T_OBJECT_0>		_vObject;	
	std::vector<TMaterial>		_vMaterial;
	std::vector<T3DSpecPoint>	_dataPoint;
	bool						_enableAlpha;

	_SetError(std::string name_er);
	
	bool _LoadVersion1(ifstream &is);
	bool _LoadVersion2(ifstream &is);
	bool _LoadVersion3(ifstream &is);
	
	bool _LoadTextVersion1(ifstream &is);
	bool _LoadTextVersion11(ifstream &is);
	
	void _RenderObject();
	void _RenderVA();

public :
	C_ASEMODEL_0();
	~C_ASEMODEL_0();
	
public :
	void LoadModel(std::string name);
	bool LoadModelText(std::string name);
	bool LoadModelBinar(std::string name);
	void Render();
	void SetRenMode(int renMode)
	{
		_renMode = renMode;
	}
	void Translate(float x, float y, float z);
	void ReloadTexture(C_TEXTURE_MANAGER_0 &tm);
	void DeleteTexture( C_TEXTURE_MANAGER_0 &tm );
	void Delete();
	CVector3 GetPosPoint( std::string name );
	TBBox GetBBox();
	void SetAlpha( bool a ) {_enableAlpha = a;}
	
};

#define CWfoModel C_ASEMODEL_0

#endif //_CASEMODEL_H_