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

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

本文简介:

}

(注:新版的MDX中应为Mesh tempMesh = Mesh.Clean(CleanType. Simplification,mesh,adj,adj); 另外,在使用了mesh.Dispose();之后程序有可能会出现异常。)

如你所见,在clean方法和simplificationMesh方法中都要用到邻接信息。在加载了mesh创建了纹理之后,我们就对mesh进行clean,准备简化。接下来,用clean过的mesh创建simplificationMesh对象。

事实上,现在不需要做任何修改,也能正确绘制mesh。但是,我们想添加一些代码让摄像机慢慢远离mesh,同时,减少mesh的细节。使用键盘来控制摄像机的移动,添加代码:

protected override void OnKeyPress(KeyPressEventArgs e)

{

     if(e.KeyChar == '+')

     {

         cameraPos += (MoveAmount * 2);

         simplifiedMesh.ReduceFaces(mesh.NumberFaces - MoveAmount);

         simplifiedMesh.ReduceVertices(mesh.NumberVertices - MoveAmount);

         mesh.Dispose();

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

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

go top