3d좌표 2d좌표로 변환

반응형
 
POINT  CAppForm::CONVERT_3DTO2D_POINT ( const D3DVIEWPORT9& vp, const D3DXMATRIX& matView, const D3DXMATRIX& matProj, D3DXVECTOR3 v )
{
  D3DXMATRIXA16 matCombine = matView * matProj;
  D3DXVec3TransformCoord ( &v, &v, &matCombine );

  v.x += 1.0f;
  v.y += 1.0f;
 
  v.x = ( vp.Width * (v.x  ) ) / 2.0f + vp.X;
  v.y = ( vp.Height * (2.0f-v.y) ) / 2.0f + vp.Y;

  POINT pt;

  pt.x = (long)v.x;
  pt.y = (long)v.y; 

  return pt;
}

//--------------------------------------------------------------------------------------
//Note: 3D 좌표를 2D 좌표로 바꿔서 글씨 써주기

D3DVIEWPORT9 vp;
m_pd3dDevice->GetViewport ( &vp );

D3DXVECTOR3 vPos ( 1000.0f, 0.0f, 0.0f );

POINT pt = CONVERT_3DTO2D_POINT ( vp, m_matView, m_matProj, vPos );
m_pFont->DrawText( pt.x, pt.y, fontColor, "ss222" );

TAGS.

Comments