//-- Cube ---------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void Renderer::Cube( float nx, float ny, float nz, float x, float y, float z )
{
	//    4-------5
	//   /|      /|
	//  0-------1 |
	//  | 7-----|-6
	//  |/      |/
	//  3-------2

	PushMatrix();

	Translate(  ( nx + x ) * 0.5f,
				( ny + y ) * 0.5f,
				( nz + z ) * 0.5f );

	DiffuseUVCubeVertexShader* pShader = NULL;
	if ( g_envMapSet )
	{
		pShader = &DiffuseUVEnvCubeVertexShader::StaticType;
	}
	else
	{
		pShader = &DiffuseUVCubeVertexShader::StaticType;
	}

	CommitTransforms( pShader );
	CommitTextureState();

	PopMatrix();

	D3DXVECTOR4 vScale( ( x - nx ) * 0.5f, ( y - ny ) * 0.5f, ( z - nz ) * 0.5f, 1.0f );

	pShader->SetScale( &vScale );
	pShader->SetColour( &g_fColour );

	m_pD3DDevice->SetVertexShader( pShader->GetVertexShader() );
	m_pD3DDevice->SetVertexDeclaration( g_pPosNormalColUVDeclaration );

	m_pD3DDevice->SetStreamSource( 0,
								   g_pCubeVbuffer,
								   0,
								   sizeof( PosColNormalUVVertex ) );

	m_pD3DDevice->SetIndices( g_pCubeIbuffer );

	m_pD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 24, 0, 12 );

	m_pD3DDevice->SetStreamSource( 0,
								   NULL,
								   0,
								   sizeof( PosColNormalUVVertex ) );

	m_pD3DDevice->SetIndices( NULL );

} // Cube
//-- Cube ---------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void Renderer::Cube( float nx, float ny, float nz, float x, float y, float z )
{
	//    4-------5
	//   /|      /|
	//  0-------1 |
	//  | 7-----|-6
	//  |/      |/
	//  3-------2

	PushMatrix();

	Translate( ( nx + x ) * 0.5f,
				     ( ny + y ) * 0.5f,
				     ( nz + z ) * 0.5f );

  DiffuseUVCubeVertexShader* pShader = g_envMapSet 
                                     ? &DiffuseUVEnvCubeVertexShader::StaticType
                                     : &DiffuseUVCubeVertexShader::StaticType;

  XMVECTOR vScale = XMVectorSet((x - nx) * 0.5f, (y - ny) * 0.5f, (z - nz) * 0.5f, 1.0f);

  pShader->SetScale(&vScale);
  pShader->SetColour(&g_fColour);

  SetShader( pShader );
  CommitTransforms(pShader);
	CommitTextureState();

	PopMatrix();

  unsigned int strides = sizeof(PosColNormalUVVertex), offsets = 0;
  m_pD3D11Contex->IASetVertexBuffers(0, 1, &g_pCubeVbuffer, &strides, &offsets);
  m_pD3D11Contex->IASetIndexBuffer( g_pCubeIbuffer, DXGI_FORMAT_R16_UINT, 0 );
  m_pD3D11Contex->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
  m_pD3D11Contex->IASetInputLayout( g_pPosNormalColUVDeclaration );

  m_pD3D11Contex->DrawIndexed(36, 0, 0);

} // Cube