【翻译】Managed DirectX(第九章)[4]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

         把摄像机的深度位置作为变量,可以方便以后的修改。接下来更新view transform,让他使用正确的位置信息。在SetupCamera方法中,添加更新如下代码:

device.Transform.View = Matrix.LookAtLH(new Vector3(0,0,cameraPos), new Vector3(), new Vector3(0,1,0));

显然,由于每一帧都会调用SetupCamera方法,因此任何对camera变量的改变都会马上得到更新,这正是我们想要的效果。SimplifiycationMesh中储存了我们将用于简化的mesh。注意到没,我们没有创建任何额外的Mesh对象。每次简化之后,只需用他代替原来的mesh就可以了。

修改LoadMesh方法确保mesh是经过了clean的,并且正确创建了simplifycationMesh对象。如下修改代码:

private void LoadMesh(string file)

{

     ExtendedMaterial[] mtrl;

     // Load our mesh

     mesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);

本文关键:【翻译】Managed DirectX(第九章)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top