我正在尝试为我的XNA游戏创建一个splitScreen。我有一个相机类,我用作相机,当我需要绘制时,我调用包含下面代码的函数。 cameraViewport是一个vector4,所有值都在0,1之间。 对于我使用的第一台相机
camera1.viewport = new vector4(0,0,1,.5f); // this works perfect
我正在使用的第二台相机
camera2.viewport = new vector4(0,.5f,1,.5f); // this is drawling the same view as camera1
但是当我为相机二拍摄时
camera2.viewport = new vector3(.5f,0,.5f,.5f);
事实证明,好像我正在将它分成4种方式并且它在右下方,但它应该在右上方。所以看起来它根本没有使用y值而只是使用x值。那是为什么?
int x = (int)(defaultViewport.Width * CameraViewport.X);
int y = (int)(defaultViewport.Height * CameraViewport.Y);
int w = (int)(defaultViewport.Width * CameraViewport.Z);
int h = (int)(defaultViewport.Height * CameraViewport.W);
Viewport viewport = new Viewport(x, y, w, h);
graphics.Viewport = viewport;
this.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), viewport.AspectRatio, .1f, 5000);
答案 0 :(得分:0)
实际上这是我的不好,错误在于我如何设置视口。
Vector4 cameraViewport;
public Vecor4 viewport
{
Vector4 newviewport = value;
cameraViewport = new Vector4(mathhelper.clamp(newviewport.x,0,1),... //here was my problem i was setting the y value the same as the x value i didnt even think to check here sorry for this kinda point less question unless someone else has the same problem.
}