#ifndef CLIENT_SYNCHRONIZER_H
#define CLIENT_SYNCHRONIZER_H

#include "./../../../lib/glee/glee.h"
#include <iostream>

#include <qmutex.h>
#include "./cgSupport/CgShaderManager.h"
#include "./configurator/CALreader.h"
#include "./renderer/Render2D.h"
#include "./apps/AbstractAPP.h"
#include "./console/Environment.h"
#include "./exception/Exception.h"
#include "./renderer/softProjRender.h"
#include "./geometry/OBJsupport.h"
#include "./geometry/OBJmodel.h"
#include "./exception/Exception.h"
#include "./console/StrException.h"
#include "./math/Matrix.h"
#include "./math/SupportFunctions.h"
#include "./illumination/LightPrinter.h"
#include <cassert>
#include "./softProj/Render/SpaceStructures.h"

#include "./softProj/Render/SpaceMap.h"
#include "./softProj/Render/SpaceSky.h"

#include "./ModelViewer/ModelViewer.h"
#include "./heightMap/heightMap.h"
#include "./softProj/Render/SpaceMapGameInterface.h"
#include "./softProj/Render/SpacePlanetGameInterface.h"
#include "./softProj/Render/ItemViewer.h"
#include "./softProj/clientServer/sharedStructures.h"
#include "./effects/animationEffect.h"
#include "./softProj/selectionWidget/selectionWidget.h"
#include "./softProj/selectionWidget/otherviewWidget.h"
#include "./softProj/Render/oglSharedData.h"
#include "./softProj/GameApp/MapViewerApp.h"
#include "./softProj/GameApp/ModelViewerApp.h"
#include "./softProj/GameApp/PlanetViewerApp.h"

#include "texture\TextureComposer.h"
#include "mathParser\mathParser.h"
#include "mathParser\mathStringParser.h"
#include "mathParser\textureOperationParser.h"


/// Recieve processed graphic game data from server and send them on.
/**
*	Recieve processed graphic game data from server and send them to 
*	coresponding classes - ModelViewerApp, MapViewerApp, PlanetViewerApp and SelectionLogic.
*/
struct ClientSynchronizer : public SynchronisationInterface
{
private:
	void shipSynchronizeCorrector( const ShipDataDetails &serverShipData, SpaceShip& clientShipData );

public:
	ClientSynchronizer( ModelViewerApp &modelViewer, MapViewerApp &mapViewer, PlanetViewerApp &planetViewer, SelectionLogic &otherviewLogic ):
	  modelViewer( modelViewer ), mapViewer( mapViewer ), otherviewLogic( otherviewLogic ), planetViewer( planetViewer )
	  /* MAX_POSTION_DISTANCE_DIFFERENCE( 200 ), ATTENUATION_FACTOR( 0.8 ) */ {}

	ModelViewerApp &modelViewer;
	MapViewerApp &mapViewer;
	PlanetViewerApp &planetViewer;
	SelectionLogic &otherviewLogic;

	/// send recieved ship data to RadarMapGame class contained in MapViewerApp 
	virtual void shipSynchronizeMacro(const ShipDataBasic &shipData, bool useAlphaOffset = false );

	/// send recieved ship data to GalaxyPart class contained in MapViewerApp 
	virtual void shipSynchronizeMicro(const ShipDataDetails &shipData );

	/// send recieved ship data to RadarMapGame and SpaceMapGame classed contained in MapViewerApp 
	virtual void shipSynchronize(const ShipDataDetails &shipData );

	/// send recieved ship warp data to RadarMapGame and SpaceMapGame classed contained in MapViewerApp 
	void warpSynchronize( const ShipWarpInfo &shipWarpInfo  );

	/// send recieved planet data to GalaxyPart class contained in MapViewerApp 
	virtual void planetSynchronize( const GenericPlanetData &planetData);

	/// send recieved star data to RadarMapGame class contained in MapViewerApp 
	virtual void starSynchronize(  const StarData &starData );

	/// loads graphic according to the revieved baseline data and send it to PlanetViewerApp to render it
	virtual void baselineSynchronize( const BaselineData &baselineData);

	/// send recieved spaceship data to ModelViewerApp class to render it
	virtual void spaceshipSynchronize( const ShipType shipType );
	//------------------------------------------------------------------------
};

#endif