/*********************************************************************//**
*	\brief Implementace struktury, ktera obsahuje informace o aktualnim levelu
*       V tomto objektu LevelData jsou obsazeny vsechny struktury
*	jako napriklad body, texturovaci souradnice, roviny, hrany, informace otexturach,
*	polygony, uzly a listy BSP stromu a dalsi.
*                                                                        
*
*	\author Michal Jirous
*	\date 3.2.2009
*	\file level_data.h
**********************************************************************/   

#ifndef __LEVEL_DATA_H__
#define __LEVEL_DATA_H__

#include "level_structs.h"
#include "level_bspfile_def.h"

const int MAX_SCENE_VERTICES = MAX_MAP_SURFEDGES;	/*!< @brief Maximalni pocet vertexu (pocet surfedges = pocet bodu (kazdy Face ma unikatni surfedges, kde 1 edge = jeden bod) ) */
const int MAX_SCENE_TEX_COORDS = MAX_MAP_SURFEDGES;	/*!< @brief Maximalni pocet texturovacich souradnic. */


#include "player.h"
#include <list>

typedef float FogCoord_t;	/*!< @brief Pomocne pojmenovani pro specifikaci formatu souradnice mlhy. */

/** @brief Struktura pro drzeni informaci o scene. */
struct LevelData
{
	//hlavicka souboru
	dheader_t header;	/*!< @brief Hlavicka BSP souboru. */

	//retezec definici entit
	char entitystring[MAX_MAP_ENTSTRING];	/*!< @brief Retezec identifikujici entity. */

	//roviny
	Plane planes[MAX_MAP_PLANES];	/*!< @brief Pole rovin. */
	size_t planes_count;	/*!< @brief Pocet rovin. */

	//data textur (jmeno, sirka, vyska apod. )
	byte textures_data[MAX_MAP_MIPTEX];	/*!< @brief Data textur (informace o velikosti, jmeno). */

	//pole bodu
	//Point vertices[MAX_MAP_VERTS];	//body pak nalezite zkopirujeme do jednoho pole jinych LUMPs, ktery uz nebudeme potrebovat, protoze tu budou taky jen docasne
	
	//zakomprimovana data vzajemne viditelnosti listu (clusteru)
	byte vis_data_compressed[MAX_MAP_VISIBILITY];	/*!< @brief Data vzajemne viditelnosti uzlu. */

	//uzly BSP stromu
	BSPNode nodes[MAX_MAP_NODES];	/*!< @brief Pole uzlu bsp stromu. */
	size_t nodes_count;	/*!< @brief Pocet uzlu BSP stromu. */

	//informace o texture
	texinfo_t textures_info[MAX_MAP_TEXINFO];	/*!< @brief Pole informaci o texture. */
	size_t textures_info_count;	/*!< @brief Pocet informaci o texture. */

	//pole ploch (polygonu)
	Face faces[MAX_MAP_FACES];	/*!< @brief Pole facu (polygonu). *///dokud je Face vetsi nez dface_t, tak je to OK
	size_t faces_count;	/*!< @brief Pocet facu (polygonu). */

	//data lightmap (proste textury)
	byte light_data[MAX_MAP_LIGHTING];	/*!< @brief Pole luxelu pro lightmapy. */

	//uzly BSP stromu (jednoduche)
	dclipnode_t clip_nodes[MAX_MAP_CLIPNODES];	/*!< @brief Pole uzlu (pro clipping hull). */
	size_t clip_nodes_count;	/*!< @brief Pocet uzlu clip. (pro clipping hull). */

	//listy BSP stromu (clustery)
	BSPLeaf leaves[MAX_MAP_LEAFS];	/*!< @brief Pole listu bsp stromu. */
	int leaves_count;	/*!< @brief Pocet listu bsp stromu. */

	//cisla ploch (polygonu), ktere nalezi clusterum (listum BSP stromu)
	unsigned short marked_faces[MAX_MAP_MARKSURFACES];	/*!< @brief Identifikacni cisla facu. */
	size_t marked_faces_count;	/*!< @brief Pocet cisel facu. */

	//hrany ploch (polygonu)
	Edge edges[MAX_MAP_EDGES];	/*!< @brief Pole hran. */
	size_t edges_count;	/*!< @brief Pocet hran. */	

	//cisla hran (zaporne znamena obraceny smer)
	int *surf_edges;	/*!< @brief Pomocny ukazatel. */
	Edge *surf_edges_pointer[MAX_MAP_SURFEDGES];	/*!< @brief indexy do hran. */ //dokud je adresa na 4B je vse ok
	size_t surf_edges_count;	/*!< @brief Pocet indexu do hran. */

	//Modely
	dmodel_t models[MAX_MAP_MODELS];	/*!< @brief Pole modelu. */
	size_t models_count;	/*!< @brief Pocet modelu levelu. */

	//Mlha
	FogCoord_t fog_coords_tmp[MAX_MAP_VERTS];	/*!< @brief Docasne souradnice mlhy. */

	//pole bodu (mohou se opakovat - pouziva se pro vykreslovani
	Point vertices_array[MAX_SCENE_VERTICES];	/*!< @brief Pole vrcholu. */
	size_t elements_count;		/*!< @brief Pocet vrcholu = pocet texturovacich souradnic i pocet souradnic mlhy. */

	//texturovaci souradnice	//vertex : texcoord - 1:1 mapping
	TexCoord2f_t texture_coords_array[MAX_SCENE_TEX_COORDS];	/*!< @brief Texturovaci souradnice primarni textury facu. */
	TexCoord2f_t lightmap_coords_array[MAX_SCENE_TEX_COORDS];	/*!< @brief Texturovaci souradnice lightmapy. */
	FogCoord_t fog_coords_array[MAX_SCENE_VERTICES];		/*!< @brief Pole souradnic mlhy. */
	
	sessionkey_t current_session;		/*!< @brief Cislo pouzivane k zamezeni vicenasobneho uziti stejneho objektu v prubehu nejake operace. */


};	

//typedef std::list<CBaseObject*>




#endif /*__LEVEL_DATA_H__*/
