【发布时间】:2023-03-22 08:32:01
【问题描述】:
我不太明白“相机”如何与 D3D9 配合使用
首先,我如何设置我的相机:
public Camera()
{
this.eye = new Vector3(0.0f, 0.0f, 0.0f);
this.lookAt = new Vector3(0.0f, 0.0f, 1.0f);
this.up = new Vector3(0.0f, 1.0f, 0.0f);
viewMatrix = Matrix.LookAtLH(eye, lookAt, up);
projectionMatrix = Matrix.OrthoLH(1 * zoomLevel, 1 * zoomLevel, 0.0f, 1.0f);
}
还有我的顶点:
vertices = new VertexTexture[]
{
new VertexTexture()
{
Position = new Vector4(0.0f, 0.0f, 0.0f, 1.0f),
TextureCoord = new Vector2(0.0f, 1.0f)
},
new VertexTexture()
{
Position = new Vector4(0.0f, model.Height, 0.0f, 1.0f),
TextureCoord = new Vector2(0.0f, 0.0f)
},
new VertexTexture()
{
Position = new Vector4(model.Width, model.Height, 0.0f, 1.0f),
TextureCoord = new Vector2(1.0f, 0.0f)
},
new VertexTexture()
{
Position = new Vector4(model.Width, 0.0f, 0.0f, 1.0f),
TextureCoord = new Vector2(1.0f, 1.0f)
}
};
它有效。我可以移动相机、缩放等。
但相机属性对我来说似乎很奇怪!我以为会是这样的:
public Camera()
{
this.eye = new Vector3(0.0f, 0.0f, 1.0f);
this.lookAt = new Vector3(0.0f, 0.0f, 0.0f);
this.up = new Vector3(0.0f, 1.0f, 0.0f);
viewMatrix = Matrix.LookAtLH(eye, lookAt, up);
projectionMatrix = Matrix.OrthoLH(1 * zoomLevel, 1 * zoomLevel, 0.1f, 100.0f);
}
但是使用该参数它不起作用。如果我为我的计划更改 Z 坐标也是一样(需要将其设置为 0 才能工作)。
现在,我尝试渲染其他对象。我为一个球体生成顶点(它在 D3D 10 上工作正常,在 (0;0;0) 周围生成一个半径为 1 的球体)但屏幕上什么也没有出现
我使用了 eye 和 lookat 参数,但我知道如何让它发挥作用,那么,我做错了什么?
【问题讨论】:
标签: camera directx direct3d slimdx