////////////////////////////////////////////////////////////////////////////////////////////////////// protected void SetupDevice() { if (mm.vexbuf == null) { mm.CreateVertexBuffer(device); } if (MeshCenter) { axises.CreateAllBuffer(device, mm.center, mm.radius); //坐标轴以Mesh中心为原心 } else { axises.CreateAllBuffer(device, new Vector3(), mm.radius); //坐标轴以(0,0,0)为原心 } if (mm.texture == null) { mm.CreateAllTextures(device); } }
////////////////////////////////////////////////////////////////////////////////////////////////////// private void Game_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.C: MeshCenter = !MeshCenter; //切换原点位置标志 axises.DisposeAllBuffer(); //删除原有的坐标轴 axises = new CoordAxies(); //彻底重建坐标轴 Vector3 center = MeshCenter ? mm.center : (new Vector3()); axises.CreateAllBuffer(device, center, mm.radius); break; case Keys.X: DrawCoordinateAxies = !DrawCoordinateAxies; break; case Keys.E: mbi.ExportToObjFile(null, null, null); Debug.WriteLine("[导出功能] OBJ/MTL文件和所有贴图导出完成."); Text += "[*]"; break; case Keys.A: //开启或者关闭FSAA FSAA = !FSAA; CreatePresentParameters(FSAA); device.Reset(present_params); break; case Keys.Escape: case Keys.Q: Close(); break; case Keys.K: //距离 camera.IncreaseRadius(20f); break; case Keys.J: //距离 camera.DecreaseRadius(20f); break; case Keys.R: //复位旋转阵 camera.Reset(); break; case Keys.F: //区域线框 DisplayWireFrame++; DisplayWireFrame %= 3; break; case Keys.O: string fn = Program.SelectSecFile(); if (fn != null) { //从头创建所有的一切! Cleanup(); GC.Collect(); ResetAll(fn); InitializeGraphics(); } break; case Keys.B: DrawBackground = !DrawBackground; if (DrawBackground) { BackColor = Color.FromArgb(0xff, 0x0, 0xff); } else { BackColor = Color.Black; } break; default: Debug.WriteLine(e.KeyCode); break; } }