// ============================================================================
// Filename: MESH.cpp
// Description: Mesh Tutorial, Mesh class header. From the 32Bits
//				DirectX Techniques Series 1 Tutorial 4.
// Created by wizard version 0.1 Beta.
//
// Found a bug in this code framework? Need some help? Come to www.32bits.co.uk
// for support, feedback and the best DirectX dev community on the net!
// ============================================================================

#pragma once

#ifndef _CD3DMESH_H
#define _CD3DMESH_H

#include "CD3DObject.h"

// Mesh class inherits from CD3DObject, so it can be managed. For more
// information on the CD3DObject class and why we inherit from it, read
// the 32Bits DirectX Basics Series 2 Tutorial 5 "CD3DObject" tutorial.
//
// This class will easily stand alone from CD3DObject, just remove the
// inheritance, RestoreVolatile & ReleaseVolatile functions, and the
// 2 calls to base class functions in the CD3DMesh constructor.

class CD3DMesh : public CD3DObject
{
public:
	
	CD3DMesh();
	virtual ~CD3DMesh();

	HRESULT Initialise(char* szMeshFile, LPDIRECT3DDEVICE9& pDevice);
	HRESULT Shutdown();

	// Render is a pure virtual in the base class.
	HRESULT Render(LPDIRECT3DDEVICE9& pDevice);

	// These methods are not required but are defined as pure virtual, so must be
	// included.
	HRESULT RestoreVolatile(){return E_FAIL;}
	HRESULT ReleaseVolatile(){return E_FAIL;}
	HRESULT Render(LPDIRECT3DDEVICE9& pDevice, LPDIRECT3DSURFACE9& pRenderSurface){return E_FAIL;}
	

private:

	LPD3DXMESH				m_pMesh;					// The actual mesh object
	
	LPD3DXBUFFER			m_pMaterialsBuffer;			// Receives the materials when the X file is loaded
	D3DMATERIAL9*			m_pMaterials;				// Array of materials extracted from m_pMaterialsBuffer
	LPDIRECT3DTEXTURE9*		m_pTextures;				// Array of textures extracted from m_pMaterialsBuffer

	DWORD					m_dwNumMaterials;			// The number of materials in this mesh
	
};

#endif // _CD3DMESH_H
