/******************************************************************************//**
*	@brief Abstaktni trida modelu, ktera definuje zakladni funkce a promenne
*		pro operace s modelem.
*
*
*		Abstract base class for a model. The specific extended class will render the given model. 
*
*	
*	Email: brettporter@yahoo.com \n
*	Website: http://www.geocities.com/brettporter/ \n
*	Copyright (C)2000, Brett Porter. All Rights Reserved. \n
*
*	This file may be used only as long as this copyright notice remains intact.
*
*	@file model.h
*	@author	Brett Porter
*/

#include <string>
#include <vector>

#ifndef MODEL_H
#define MODEL_H

/** @brief Abstraktni trida modelu, ktera definuje spolecne vlastnosti. */
class Model
{
	public:

		float mins[3],maxs[3];


		/** @brief	Mesh. */
		struct Mesh
		{
			int m_materialIndex;		/*!< @brief Index materialu. */
			int m_numTriangles;		/*!< @brief Pocet trojuhelniku. */
			int *m_pTriangleIndices;	/*!< @brief Pole indexu trojuhelniku. */
		};

		/** @brief	Material properties. */
		struct Material
		{
			float 	m_ambient[4],		/*!< @brief Ambient parametr. */
				 m_diffuse[4],		/*!< @brief Diffuse parametr. */
				 m_specular[4],		/*!< @brief Specular parametr. */
				 m_emissive[4];		/*!< @brief Emissive parametr. */
			float m_shininess;		/*!< @brief Shininess parametr. */
			unsigned int m_texture;		/*!< @brief Index textury. */
			std::string m_sTextureFilename;	/*!< @brief Cesta k souboru textury. */
		};

		/** @brief	Triangle structure. */
		struct Triangle
		{
			float m_vertexNormals[3][3];	/*!< @brief Normaly trojuhelniku. */
			float 	m_s[3],			/*!< @brief Texturovaci souradnice 'S' bodu trojuhelniku. */
				 m_t[3];		/*!< @brief Texturovaci souradnice 'T' bodu trojuhelniku. */
			int m_vertexIndices[3];		/*!< @brief Indexy bodu do pole vertexu. */
		};

		/** @brief	Vertex structure. */
		struct Vertex
		{
			char m_boneID;			/*!< @brief Pro skeletalni animaci. */
			float m_location[3];		/*!< @brief Souradnice bodu. */
		};

	public:
		/** @brief	Constructor. */
		Model();

		/** @brief	Destructor. */
		virtual ~Model();

		/**	@brief Load the model data into the private variables. 
		*	@param filename Cesta k souboru modelu.
		*	@return True v pripade uspesneho nacteni a false v opacnem pripade.
		*/
		virtual bool loadModelData( const char *filename ) = 0;

		/** @brief Draw the model.
		*/
		void draw();

		/** @brief Called if OpenGL context was lost and we need to reload textures, display lists, etc.
		*/
		void reloadTextures();

		/** @brief Naplni pole indexy pouzivanych textur
		*/
		void getTextureIDs( std::vector<unsigned int> &textures );
	protected:
		//	Meshes used
		int m_numMeshes;	/*!< @brief Pocet meshu. */
		Mesh *m_pMeshes;	/*!< @brief Pole meshu. */

		//	Materials used
		int m_numMaterials;	/*!< @brief Pocet materialu. */
		Material *m_pMaterials;	/*!< @brief Pole materialu. */

		//	Triangles used
		int m_numTriangles;	/*!< @brief Pocet trojuhelniku. */
		Triangle *m_pTriangles;	/*!< @brief Pole trojuhelniku. */

		//	Vertices Used
		int m_numVertices;	/*!< @brief Pocet vertexu. */
		Vertex *m_pVertices;	/*!< @brief Pole vertexu. */
};

#endif // ndef MODEL_H

