我认为没有OGRE函数可以直接执行此操作,但您可以轻松获得相同的结果.
您在世界空间中有一个3D点,并且您希望将您的点投射到屏幕空间中.因此,您需要将投影矩阵和视图矩阵的点相乘,然后您需要将结果点从坐标空间[-1 1]映射到[0 1].
例如:
Vector2 GetScreenspaceCoords(const Vector3& iPoint, const Camera& iCamera)
{
Vector3 point = iCamera.getProjectionMatrix() * (iCamera.getViewMatrix() * iPoint);
Vector2 screenSpacePoint = Vector2::ZERO;
screenSpacePoint.x = (point.x / 2.f) + 0.5f;
screenSpacePoint.y = (point.y / 2.f) + 0.5f;
return screenSpacePoint;
}
Run Code Online (Sandbox Code Playgroud)
当然,如果您想要相对于屏幕大小的坐标,则必须将视口宽度和高度的点相乘.