// Mesh.h: interface for the Mesh class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MESH_H__EF6BAAFB_5CB6_436B_9DCA_54DAD86997B5__INCLUDED_)
#define AFX_MESH_H__EF6BAAFB_5CB6_436B_9DCA_54DAD86997B5__INCLUDED_
#include "windows.h"
#include "d3d9.h"
#include "d3dx9.h"
#include "3dutils.h"

class Mesh  
{
public:
	void draw();
	HRESULT loadFromX(char *filename);
	void cleanup();
	Mesh();
	virtual ~Mesh();
	LPD3DXMESH GetD3DXMesh();
	//This function only deletes the mesh, and leaves the materials and textures
	void DeleteD3DXMesh();
	void SetD3DXMesh(LPD3DXMESH NewMesh);

	void nil() {return;}
	
	//Creates a new mesh; it uses the FVF format of XYZ, normal, diffuse, 
	HRESULT CreateMesh(int NumFaces, int NumVertices);
	//Sets the materials for this mesh to those specified in the array
	HRESULT SetMaterials(DWORD NewNumMaterials, D3DMATERIAL9* NewMaterials);
    //Sets the textures for this mesh to those specified in the array
	HRESULT SetTextures(DWORD NewNumTextures, LPDIRECT3DTEXTURE9* NewTextures);

private:
	DWORD dwNumMaterials;
    //DWORD dwNumTextures;
	LPDIRECT3DTEXTURE9*	pMeshTextures;
	D3DMATERIAL9*		pMeshMaterials;
	LPD3DXMESH			pd3dxMesh;
};

#endif // !defined(AFX_MESH_H__EF6BAAFB_5CB6_436B_9DCA_54DAD86997B5__INCLUDED_)
