// ================================================================
 // Filename: D3DCube.h
 // Description: 3D Cube class, derived from CD3DObject. Enables
 //              quick and easy creation of a texturemapped cube
 //
 //              This source corresponds to 32Bits.co.uk DirectX
 //              Basics Series 3 part 5, DirectX 9 Edition.
 // ================================================================

 #ifndef _D3DCUBE_H
 #define _D3DCUBE_H

 #include "CD3DObject.h"

 // =================================================================================
 // Vertex struct and FVF for our Cube Class
 // =================================================================================

 // Note that we expect this cube to be lit, so there is no diffuse colour in our struct

 typedef struct _tagCubeVertex
 {
     D3DVECTOR   vPos;
     D3DVECTOR   vNormal;
     float       tu, tv;

 } CUBEVERTEX;

 #define D3DFVF_CUBE (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(1))


 // =================================================================================
 // Cube Class
 // =================================================================================

 class CD3DCube : public CD3DObject
 {
 private:

     CUBEVERTEX              m_Vertices[36];     // 36 vertices: 3 verts per tri, 2 tris per face = 6,
                                                 // 6 faces = 36 vertices.
     LPDIRECT3DTEXTURE9      m_pTexture;         // texture surface for texturemapping
     LPDIRECT3DVERTEXBUFFER9 m_pVertexBuffer;    // Vertex buffer for our vertices

 public:

     CD3DCube();
     virtual ~CD3DCube();

     // Initialise method to create the cube's vertices
     HRESULT Initialise(float Width, float Height, float Depth, float x, float y, float z,
                        LPDIRECT3DDEVICE9& pDevice);

     // Overloaded SetTexture() method to allow use of a new texture, or an existing texture
     HRESULT SetTexture(LPDIRECT3DTEXTURE9 pTexture);
     HRESULT SetTexture(char* strTexturePath, LPDIRECT3DDEVICE9& pDevice);

     // Derived Render() method
     HRESULT Render(LPDIRECT3DDEVICE9& pDevice, LPDIRECT3DSURFACE9& pRenderSurface);

     HRESULT RestoreVolatile(){return 0;}
     HRESULT ReleaseVolatile(){return 0;}

 };

 #endif // _D3DCUBE_H