/** 
 * \file Forest.h
 * \brief This file defines 2D and 3D forest classes. 
 * 
 * \author Petar Bajic, MPE (C) All Rights Reserved, Homepage: www.mystic-peanut.com
 * \date January, 16 2007.
 */

#include "d3dx9.h"

#ifndef MPE_FOREST
#define MPE_FOREST

/**
 * \brief Class for loading and presenting static bilboards of trees (2D trees)
 * \author Petar Bajic \date January, 16 2007.
 */
class CForest
{
public:
	CForest();
	~CForest();
	bool Load(LPDIRECT3DDEVICE9 pd3dDevice, WCHAR* strFilePath, WCHAR* strFileName);
	void OnRender(LPDIRECT3DDEVICE9 pd3dDevice);
	void OnFrameMove(LPDIRECT3DDEVICE9 pd3dDevice, float rotation, D3DXVECTOR3 position);

	DWORD m_numMaterials;
	LPD3DXMESH m_pMesh;
	D3DMATERIAL9* m_pMaterial;
	LPDIRECT3DTEXTURE9* m_pTexture;
};

/**
 * \brief Class for loading and presenting static 3D models of trees
 * \author Petar Bajic \date January, 16 2007.
 */
class C3DForest
{
public:
	C3DForest();
	~C3DForest();
	bool Load(LPDIRECT3DDEVICE9 pd3dDevice, WCHAR* strFilePath, WCHAR* strFileName);
	void OnRender(LPDIRECT3DDEVICE9 pd3dDevice);
	void OnFrameMove(LPDIRECT3DDEVICE9 pd3dDevice, float rotation, D3DXVECTOR3 position);

	DWORD m_3DTreeNumMaterials;
	LPD3DXMESH m_p3DTreeMesh;
	D3DMATERIAL9* m_p3DTreeMaterial;
	LPDIRECT3DTEXTURE9* m_p3DTreeTexture;
};

#ifndef V
#define V(x)           { hr = x; }
#endif
#ifndef V_RETURN
#define V_RETURN(x)    { hr = x; if( FAILED(hr) ) { return hr; } }
#endif

#ifndef SAFE_DELETE
#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
#endif    
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
#endif    
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
#endif

#endif//MPE_MODELSTATIC