![](/img/trans.png)
[英]My update query is not working. I'm using Visual Studio 2015, and am trying to update an access database
[英]My Direct3D scene update is not working. What am I missing out?
我有一個 winform 並在其上設置了 direct3d 以顯示藍屏。 Render
正在運行每一幀。 以下(以及上面的一些頂點聲明)向屏幕輸出一個三角形......到目前為止一切都很酷。
public void UpdateScene()
{
Vector3 translation = new Vector3 { X = whatever.X, Y = whatever.Y, Z = whatever.Z };
Matrix matrix = new Matrix();
matrix.Translate(translation);
device.Transform.World = matrix;
}
public void Render()
{
if (device == null)
return;
//Clear the backbuffer to a blue color
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
//Begin the scene
UpdateScene();
device.BeginScene();
// Rendering of scene objects can happen here
device.SetStreamSource(0, vertexBuffer, 0);
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
//End the scene
device.EndScene();
device.Present();
}
cameraPosition.XY 和 Z 在每次通過時都正確更新......有什么想法為什么我的對象似乎沒有前后移動(或者相機圍繞它移動)?
也試過這個:
Vector3 translation = new Vector3 { X = whatever.X, Y = whatever.Y, Z = whatever.Z };
device.Transform.World.Translate(translation);
和這個:
Vector3 translation = new Vector3 { X = whatever.X, Y = whatever.Y, Z = whatever.Z };
device.Transform.World = Matrix.Translation(translation);
我認為相關的代碼: http : //pastebin.com/rgfJGxk0
最好不要用相機將三角形變換到相同的位置。 Direct3D 變換和投影算法基於真實世界的示例,就像您用相機捕捉圖像一樣。 所以試想一下,如果你把一些東西放在你相機的同一位置,你能捕捉到它嗎? 他們之間需要一些距離。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.