我正在用 XNA 中的图元绘制一个矩形。宽度为:
width = GraphicsDevice.Viewport.Width
高度是
height = GraphicsDevice.Viewport.Height
我正在尝试将这个矩形放入屏幕中(使用不同的屏幕和设备),但我不确定将相机放在 Z 轴的哪个位置。有时相机太近,有时太远。
这是我用来获取相机距离的方法:
//Height of piramid
float alpha = 0;
float beta = 0;
float gamma = 0;
alpha = (float)Math.Sqrt((width / 2 * width/2) + (height / 2 * height / 2));
beta = height / ((float)Math.Cos(MathHelper.ToRadians(67.5f)) * 2);
gamma = (float)Math.Sqrt(beta*beta - alpha*alpha);
position = new Vector3(0, 0, gamma);
知道将相机放在 Z 轴的哪个位置吗?