private float rota = 0;//旋转 private void Tick(object sender, ElapsedEventArgs e) { lock (_frameBuff) { clearBuff(); rota += 0.05f; //获取旋转矩阵 Matrix4x4 rotaX = MathUntil.GetRotateX(rota); Matrix4x4 rotaY = MathUntil.GetRotateY(rota); Matrix4x4 translate = MathUntil.GetTranslate(0, 0, 10); Matrix4x4 m = rotaX * rotaY * translate; //计算相机视矩阵 Matrix4x4 v = MathUntil.GetView(_camera.pos, _camera.lookAt, _camera.up); //投影矩阵 Matrix4x4 p = MathUntil.GetProjection(_camera.fov, _camera.aspect, _camera.zn, _camera.zf); Draw(m, v, p); if (_frameG2 == null) { _frameG2 = CreateGraphics(); } _frameG2.Clear(System.Drawing.Color.Black); _frameG2.DrawImage(_frameBuff, 0, 0); } }
private void Tick(object sender, EventArgs e) { lock (_frameBuff) { ClearBuff(); rot += 0.05f; Matrix4x4 m = MathUntil.GetRotateX(rot) * MathUntil.GetRotateY(rot) * MathUntil.GetTranslate(0, 0, 10); Matrix4x4 v = MathUntil.GetView(_camera.pos, _camera.lookAt, _camera.up); Matrix4x4 p = MathUntil.GetProjection(_camera.fov, _camera.aspect, _camera.zn, _camera.zf); // Draw(m, v, p); if (g == null) { g = this.CreateGraphics(); } g.Clear(System.Drawing.Color.Black); g.DrawImage(_frameBuff, 0, 0); } }