#include "InputRegister.h"




void InputSpace::registerInputCAL( Environment &env )
{
	env.registerOption( "terrainResourcesPath", optString );
	env.registerOption( "shadersPath", optString );
	env.registerOption( "CALpath", optString );
	env.registerOption( "texturesPath", optString );
	env.registerOption( "modelsPath", optString );
}

void InputSpace::registerInputDTIT( Environment &env )
{
	env.registerOption( "viewSamplePath", optString );
	env.registerOption( "ambientOcclusionPath", optString, "aopath", "prt_files/aovals.float");
	env.registerOption( "gatherSamplePath", optString );

	env.registerOption( "FGres", optInt, "", "2048" );
	env.registerOption( "FGcoefCount", optInt );
	env.registerOption( "FGpath", optString );

	env.registerOption( "MultiBounceRes", optInt, "", "2048" );
	env.registerOption( "MultiBounceCoefCount", optInt );
	env.registerOption( "MultiBouncePath", optString );

	// number of matrix coefficients to process at once (i.e. number of layers in the 3d texture)
	env.registerOption( "matrixMulBatchSize", optInt, "", "20");

	// compute indirect illumination in the DTIT window
	env.registerOption( "addIndirect", optBool, "ind", "ON" );
	// compute direct illumination in the DTIT window
	env.registerOption( "addDirect", optBool, "dir", "ON" );

	// compute indirect illumination in the DTIT window
	env.registerOption( "gamma", optFloat, "gamma", "1.0" );
	// compute direct illumination in the DTIT window
	env.registerOption( "lumScale", optFloat, "ls", "1.0" );

	/// should we write the resulting DTI image to a HDR image (for debugging)?
	env.registerOption( "writeOutDtiImage", optBool, "wrdti", "OFF" );

	// resolution of shadow map texture
	env.registerOption( "SMres", optInt, "SMres", "1024" );
	// bias for shadow mapping
	env.registerOption( "SMbias", optFloat, "SMbias", ".001f" );
	// Near clipping plane of the projection transformation.
	env.registerOption( "SMnearPlane", optFloat, "SMnearPlane", "1" );
	// Far clipping plane of the projection transformation.
	env.registerOption( "SMfarPlane", optFloat, "SMfarPlane", "100" );
	// render scene from a light source
	env.registerOption( "SMmode", optString, "", "EE_NORMAL" );
}

void InputSpace::registerUi( Environment &env )
{
	env.registerOption( "logPath", optString );
	env.registerOption( "savePath", optString, "", "savePath" );
	env.registerOption( "logScreenShots", optBool, "", "OFF" );
	env.registerOption( "logIntervalMs", optInt, "", "200" );

	env.registerOption( "showGITools", optBool, "", "ON" );
	env.registerOption( "showAOCheckbox", optBool, "", "ON" );

	env.registerOption( "cameraPivot", optVector, "cameraPivot", "0 0 0" );


	env.registerOption( "referenceImage", optString, "referenceImage" );

	env.registerOption( "intensityScale", optFloat, "intensityScale", "0.1");
	env.registerOption( "intensityBase", optFloat, "intensityBase", "1.15");
}

void InputSpace::registerFrustrum(  Environment &env )
{
	env.registerOption( "frustrumNearPlane", optFloat );
	env.registerOption( "frustrumFarPlane", optFloat );
	env.registerOption( "frustrumFOV", optFloat );
}

void InputSpace::registerGameData(  Environment &env )
{
	env.registerOption( "maxGameLoopInterval", optInt );
	env.registerOption( "fullScreen", optBool, "", "OFF" );
	env.registerOption( "initGraphicOnStart", optBool, "", "ON" );
	env.registerOption( "useShaders", optBool, "", "ON" );
	env.registerOption( "hideConsole", optBool, "", "ON" );
}

void InputSpace::registerALL( Environment &env )
{
	InputSpace::registerInputCAL( env );
	InputSpace::registerFrustrum( env );
	InputSpace::registerGameData( env );

	// not needed for this application
	/*
	InputSpace::registerInputDTIT( env );
	InputSpace::registerUi( env );
	*/
	
}

string InputSpace::getResourcePath( const string &envPath )
{
	string fullPath="./";

	size_t  it =envPath.find_last_of("/\\");
	
	if (it != string::npos )
	{
		fullPath= envPath.substr(0, it )+"/";
	}

	return fullPath;
}