#ifndef __XOBJECT__
#define __XOBJECT__


// Forward declarations
class RTEffectsCommon;


class XObject 
{
	private:

		//--------------------------------------------------------------------------------------
		// Class data (geometry, textures, materials...)
		//--------------------------------------------------------------------------------------
		LPD3DXMESH m_pXMesh;							// The D3DX Mesh loaded from X
		D3DMATERIAL9 * m_pMeshMaterials;				// Materials for our mesh
		DWORD m_dwNumMaterials;							// Number of mesh materials
		LPDIRECT3DTEXTURE9 * m_pMeshTextures;			// Textures for our mesh
		LPDIRECT3DVERTEXDECLARATION9 m_pMeshVertDecl;	// The mesh vertex declaration

	public:

		// Construction / destruction
		XObject(LPCWSTR sFileName);
		~XObject();

		// Getters / Setters
		LPDIRECT3DVERTEXDECLARATION9 getMeshVertDecl(){ return m_pMeshVertDecl; }

		// Mesh setups
		HRESULT ComputeBoundingSphere(D3DXVECTOR3 * pSphereCenter, FLOAT * pSphereRadius); // Compute the mesh bounding sphere
		HRESULT UniformizeMeshDeclaration();	// Adapt the loaded mesh to our needed vertex declaration if needed
		
		// Rendering
		HRESULT RenderMesh(RTEffectsCommon * pRTEffect) const;	// Render the mesh
		HRESULT ZPassRender(RTEffectsCommon * pRTEffect) const;	// Render the mesh geometry (for Z-PrePass)
		HRESULT DrawMeshWithCurrenttechnique(const D3DXVECTOR3 * pEyePt);
		HRESULT RenderMeshOrbitalLight(const D3DXMATRIXA16 * pMatView, const D3DXMATRIXA16 * pMatProj, const D3DXVECTOR3 * pEyePt);	// Render the light arrow
};

#endif