Hi, I have a vertexbuffer class that has a OnMouseOver function, and I pass the X, and Y into and compare it to the dimensions of the VertexBuffer. I return TRUE if its within it. But I am having problems. I have tiles in a 800x600 window with 16x12 tiles. It works Ok on the first line but every line after that its off by a little but each row. So by the time I get to the last row I have to mouse over the middle and below to get it to return true? This is my code for positioning things at 0,0
D3DXMATRIX mProjectionMatrix, mViewMatrix, mWorldMatrix, mTextureMatrix;
D3DXMatrixOrthoOffCenterLH(&mProjectionMatrix, 0.0f, m_ScreenWidth, m_ScreenHeight, 0.0f, 0.0f, 1.0f);
D3DXMatrixIdentity(&mViewMatrix);
D3DXMatrixIdentity(&mWorldMatrix);
D3DXMatrixIdentity(&mTextureMatrix);
m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &mProjectionMatrix);
m_pD3DDevice->SetTransform(D3DTS_VIEW, &mViewMatrix );
m_pD3DDevice->SetTransform(D3DTS_WORLDMATRIX(0), &mWorldMatrix );
m_pD3DDevice->SetTransform(D3DTS_TEXTURE0, &mTextureMatrix );
And this is my code for positioning the VertexBuffer
BOOL c2DRect::MoveAbsolute(float x, float y, float z){
m_X = x;
m_Y = y;
m_Z = z;
Move = TRUE;
return TRUE;
}
BOOL c2DRect::Render(){
m_pD3DDevice->SetStreamSource(0, m_pVB, 0, sizeof(s2DVertex));
m_pD3DDevice->SetFVF(VERTEXFVF);
if(Move){
D3DXMatrixTranslation(&m_matPosition, m_X, m_Y, m_Z);
Move = FALSE;
}
m_pD3DDevice->SetTransform(D3DTS_WORLD, &m_matPosition);
m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
return TRUE;
}
And the code for on mouse over
This is to get the mouse cursor.
POINT pt;
GetCursorPos(&pt);
ScreenToClient(m_hWnd, &pt);
m_XPos = pt.x;
m_YPos = pt.y;
BOOL c2DRect::OnMouseOver(float x, float y){
if(x >= m_X && x <= m_X + m_Right && y >= m_Y && y <= m_Y + m_Bottom){
return TRUE;
}
return FALSE;
}
Thank you in advance.