/*****************************************************************************
 * $Id: mod_pony_world.hh,v 1.1 2006/11/24 21:56:58 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Module World.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#ifndef MOD_PONY_WORLD_HH
#define MOD_PONY_WORLD_HH 1

#include "eng_world.hh"

enum eWorldSize { eWorldSize_NORMAL, eWorldSize_LARGE, eWorldSize_HUGE };

////////////////////////////////////////////////////////////////////////////////
/// @class ModulePonyWorld
class ModulePonyWorld : public World
{
private:
	PREVENT_COPYING(ModulePonyWorld)
	typedef World Parent;

public:
					ModulePonyWorld( void ) { }	// substituted by Make()
					~ModulePonyWorld() { }		// substituted by Destroy()
	void			Make( void );
	void			PopulateQuadrant( QuadrantPtrConst q );
	bool			IfSmallObject( const Object& obj ) const { return obj.GetRadius() < WORLD(150.0); }
    fp              GroundLevel( void ) const;
	bool			TooCloseToInitialViewpoint( const Posrad& posrad ) const;
	void			LodUserChange( void );
};

//------------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief Super-struct for the parameters of the simulated world.
class ModulePonyWorldParm
{
	PREVENT_COPYING(ModulePonyWorldParm)
public:

//------------------------------------------
// World parameters.
// Defines the size of the simulated world.
//------------------------------------------
	ModulePonyWorldParm( void )
	{
        mObjRatio           = 0.5;          ///< order-dependent
		mWorldDim[XX]		= 12;			///< in quadrants
		mWorldDim[YY]		= 2;
		mWorldDim[ZZ]		= 12;
		mQuadrantEdge		= WORLD(mObjRatio * 70*1000);
		mMargin				= WORLD(200.0);
		mWorldSize			= eWorldSize_NORMAL;
	}
    // mObjRatio helps to populate quadrants when quadrant scale is changed.
    // If populating objects in a quadrant is tuned for arbitrary ratio of 1.0,
    // then if the quadrant size is scaled down 50%, change the ratio to 0.5.
    fp          mObjRatio;
	Array<3>	mWorldDim;
	fp			mQuadrantEdge;		///< length in world coord
	fp			mMargin;			///< for when Fence() wraps a Dyna
	eWorldSize	mWorldSize;

//------------------------------------------
// Terrain parameters.
//------------------------------------------
	struct TerrainParm
	{
		bool	mDesert;
		int		mMountains;
	};
	TerrainParm mTerrain;

	struct HillParm
	{
		HillParm( void ) : mDensity(1.0) { }
		fp		mDensity;
		fp		mTallest;
		fp		mHeight;
		int		mWidth1Rand;
		int		mWidth1Base;
		int		mWidth2Rand;
		int		mWidth2Base;
		int		mHillsQuadrantRand;
		int		mHillsQuadrantBase;
	};
	HillParm mHill;

	struct TreeParm
	{
		TreeParm( void ) : mDensity(1.0) { }
		bool	mDisable;
		fp		mDensity;
	};
	TreeParm mTree;

//------------------------------------------
// Water parameters.
//------------------------------------------
	struct WaterParm
	{
		WaterParm( void ) : mDensity(0.5), mIslandDensity(0.4) { }
		fp		mDensity;			///< {0,..,1}
		fp		mIslandDensity;		///< {0,..,1}
	};
	WaterParm mWater;

//------------------------------------------
// Cloud parameters.
//------------------------------------------
	struct CloudParm
	{
		CloudParm( void ) : mDensity(1.0) { }
		fp		mDensity;
	};
	CloudParm mCloud;
};
// public (but hidden to code outside this Module)
#if COMPILING_MODULE_PONY // set by makefile
#	ifdef MOD_PONY_WORLD_CC
       ModulePonyWorldParm	gWorldParm;
#	else
extern ModulePonyWorldParm	gWorldParm;
#	endif // MOD_PONY_WORLD_CC
#endif // COMPILE_MODULE_PONY

//------------------------------------------------------------------------------

#endif // MOD_PONY_WORLD_HH
