If you need to move them you will need their original vertices and their 'working' vertices.
Code:
void Menu::TransformMenu(const D3DXVECTOR3 &pos,float rotation,float scale)
{
// Translate to origin
D3DXMATRIX matToOrigin;
D3DXMatrixTranslation(&matToOrigin,-m_vecMenuPos.x,-m_vecMenuPos.y,1.0f);
// Translation
D3DXMATRIX matTrans;
D3DXMatrixTranslation(&matTrans,&pos.x,&pos.y,1,0f);
// Rotation - z rotation for 2D
D3DXMATRIX matRot;
D3DXMaxtrixRotationZ(&matRot,rotation);
// Scaling matrix
D3DXMATRIX matScale;
D3DXMatrixScaling(&matScale,scale,scale,1.0f);
// Final world matrix - local to world transform
D3DXMATRIX matWorld = matToOrigin * matRot * matScale * matTrans;
// Transform vertices by matWorld
for (unsigned int i = 0;i < 4; ++i)
{
D3DXVec3TransformCoord(&m_workingVerts[i],&m_originalVerts[i],&matWorld);
}
m_vecMenuPos = pos;
}
I included scaling and rotation just in case you might need them later. Even though pos.z and m_vecMenuPos.z are not used I chose D3DXVECTOR3 to make it simpler.
You could also use D3DXVec3TransformCoordArray() instead of doing the manual for loop.
At creation time you will need to do this:
Code:
memcpy(&m_workingVerts,&m_originalVerts,4 * sizeof(ScreenVertex));
Where screen vertex is your vertex structure.