
/**************************************************************************************************************************************
///																																  ///
///		FICHIER :	ZooScene.h																								  ///
///																																  ///
///		NATURE	:	Define the class of visualization																			  ///
///																																  ///
******************************************************************************************************************************************/

#ifndef __ZOOSCENE_H__
#define __ZOOSCENE_H__


#include	"..\Basic\ZooWorld.h"
#include	"..\Datas\ZooFont.h"


//$BLG
class ZBLG_ObjSpr;

class	ZWorld;


/**************************************************************************************************************************************
/// ZScene Class
///
///		- Classe de la scene 'globale' - peut contenir plusieurs ZWorld
///		- méthodes d'init graphique de la scene et d'affichage du monde 3D
///		- chargement des scenes 3D
/**************************************************************************************************************************************/
class ZScene
{

public:
	// --- Collectors --- 
	ZWorld		*World;							// The basic scene

	// --- Listes ---
	ZArray<ZMaterial*>		MatList;			// list of all the materials
	ZArray<ZTexture*>		TexList;			// list of all the textures
	ZArray<ZMesh*>			MshList;
	ZArray<ZFont*>			FntList;			// The font collector
	ZArray<ZEmitter*>		pclList;			// Global list of emitters
	ZArray<ZParticle*>		PclDef;				// The particle's ppties and effects collector
	ZArray<ZEffect*>		PclEff;				// The particle's ppties and effects collector
	ZArray<ZMesh*>			cbObj;				// List of object that have a render callback
	ZArray<ZBone*>			boneList;
	ZArray<ZSkelet*>		sklList;


	// --- Active objects --- 
	ZCamera		*activeCam;
	ZSound		*activeListener;


	// --- Screen ppties --- 
	int			WW, HH;							// define our window width and height variables

	/* $MS : Calculation of scene FPS */
	/*
	float frameRate ;
	float oldTime ;
	float newTime ;
	float passedTime ;
  */
	DWORD frameRate ;
	DWORD oldTime ;
	DWORD newTime ;
	DWORD passedTime ;


#ifdef _INFO_SCREEN_
	// --- Time computing --- 
	int			frameCount;
	float		FPS;
	DWORD		lastTime;
	float		totalTime[256];
#endif



	// --- Flags ---
	bool		updateGraphList;				// flag de re-creation de la liste des ZNodeGraph
	ZNode		*lastBaseNodeList;				// dernier BaseNode utilisé comme racine du graphe

	bool		textureModified;				// flag de modification d'une ou plusieurs textures
	bool		materialModified;				// flag de modification d'un ou plusieurs materiaux
	bool		meshModified;					// flag de modification d'une ou plusieurs textures
	bool		skinModified;

	bool		orthoGraphic;					// type de projection orthographique

	bool		depthEvent;
	
	bool		fog_ENABLED;

	int			generalTextureFilter;

	bool		generalRealLighting;

	// --- ACCELERATION ---
	bool		accelerated;

	//---Multisampling-----
	bool MultiActivation ;



	///////////////////////////////////////////////////////////////////////////
	/// CONSTRUCTOR	& DESTRUCTOR											///
	///////////////////////////////////////////////////////////////////////////
	ZScene(bool accel);
	~ZScene();

	
	///////////////////////////////////////////////////////////////////////////
	/// Reset all the Scene components										///
	///////////////////////////////////////////////////////////////////////////
	void Reset();

	
	///////////////////////////////////////////////////////////////////////////
	/// Initialisation du monde (objets, lights, cameras)					///
	///////////////////////////////////////////////////////////////////////////
	void InitWorld();

	

	///////////////////////////////////////////////////////////////////////////
	/// Traitement et affichage de la scene									///
	///////////////////////////////////////////////////////////////////////////
	void Display(float r, float g, float b, ZNode *baseNode, bool wired, bool ortho, bool clear);
	void DisplaySOFT(RenderBuffer *buffer, float r, float g, float b, ZNode *baseNode, bool wired, bool ortho, bool clear);


	///////////////////////////////////////////////////////////////////////////
	/// Reception des infos à partir d'un point sur l'écran					///
	///////////////////////////////////////////////////////////////////////////
	//$BLG
	//ZObject* Getinfo(int xplot, int yplot, float * u, float * v, float * z, int *handmat, int *faceNb, float *distance);
	ZBLG_ObjSpr* Getinfo(int xplot, int yplot, float * u, float * v, float * z, int *handmat, int *faceNb, float *distance);
	

	///////////////////////////////////////////////////////////////////////////
	/// Update the meshes topology and viewing options & material managing	///
	///////////////////////////////////////////////////////////////////////////
	void UpdateMaterialByTextures();
	
	void UpdateMeshByMaterials();
	void UpdateMeshes();

	void SetMaterialMeshForNext();

	
	///////////////////////////////////////////////////////////////////////////
	/// Set the active camera												///
	///////////////////////////////////////////////////////////////////////////
	void SetActiveCam(ZCamera* curCam);
	void SetActiveListener(ZSound* listener);

#ifdef	_INFO_SCREEN_
	void BuildTreeGraph(ZNode* node, HTREEITEM parent);
	void BuildTreeDatas();
	void DisplayInfos(float r, float g, float b, ZNode *baseNode, bool wired, bool ortho, bool clear);
#endif
};

extern float GetTimePassed(DWORD *lastTime);

#endif

