-
Автор темы
- #1
C#:
private static ScreenVector WorldToScreen(float x, float y, float z)
{
float w;
float sx;
float sy;
sx = VMatrix.M11 * x +
VMatrix.M12 * y +
VMatrix.M13 * z +
VMatrix.M14;
sy = VMatrix.M21 * x +
VMatrix.M22 * y +
VMatrix.M23 * z +
VMatrix.M24;
w = VMatrix.M41 * x +
VMatrix.M42 * y +
VMatrix.M43 * z +
VMatrix.M44;
if (w < 0.01f)
return new ScreenVector()
{
Result = false,
X = 0,
Y = 0
};
float invw = 1f / w;
sx *= invw;
sy *= invw;
int width = window.Width;
int height = window.Height;
float xt = width / 2;
float yt = height / 2;
xt += 0.5f * sx * width + 0.5f;
yt -= 0.5f * sy * height + 0.5f;
sx = xt;
sy = yt;
return new ScreenVector()
{
Result = true,
X = sx,
Y = sy
};
}
Последнее редактирование: