3D场景点到2D屏幕点 坐标转换时间:2023-01-25 19:25:53BOOL CScreenMouseTrack::GetScreenCoordinates(const Vector3& vWorldPos, Vector2& _point) { assert(mCamera); Vector3 hcsPosition = mCamera->getProjectionMatrix() * (mCamera->getViewMatrix() * vWorldPos); // if((hcsPosition.x < -1.0f) || (hcsPosition.x > 1.0f) || // (hcsPosition.y < -1.0f) || (hcsPosition.y > 1.0f)) // { // return FALSE; // } //////应该将-1-1之间变为0-1之间吧 _point.x = hcsPosition.x/2.0f + 0.5; _point.y = 0.5f - hcsPosition.y/2.0f;//y值方向相反 // x = m_nWidth / 2 + (m_nWidth * hcsPosition.x / 2); // y = m_nHeight / 2 - (m_nHeight * hcsPosition.y / 2); return TRUE; }