VDF常见问题整理(四十六):如何使用方向键模拟VROT?

VectorDraw Developer Framework试用版下载


问:

    在VDF中,如果我想使用诸如UP,DOWN,LEFT RIGHT之类的方向键来模拟CommandAction.View3D( VROT)。然后在每次单击方向按钮时,呈现的结果是按照预定的方向沿该方向旋转场景。想要请问怎么样才能实现/p>

答:

    很简单,只需要以表单形式添加vdFramed或vdScrollable控件和五个按钮,然后尝试执行以下代码:

  private void buttonCreateScene_Click(object sender, EventArgs e)       {           //doc is the vdFramed.BaseControl.ActiveDocument           doc.New(); // just create some 3D objects for testing           doc.CommandAction.CmdBox3d(new gPoint(2000, 1000), 3.0d, 4.0d, 5.0d, 0.0d);           doc.CommandAction.CmdSphere(new gPoint(2008, 1003), 2.0d, 6, 7);           doc.CommandAction.View3D("SHADEON");           doc.CommandAction.View3D("VISE");           doc.CommandAction.Zoom("S", 0.5, 0);       }       // this is the step you need to set       double step =  VectorDraw.Geometry.Globals.DegreesToRadians(5.0d); // 5 degrees step          private void buttonUP_Click(object sender, EventArgs e)       {           gPoint ptV = doc.ActiveLayOut.Render.ProjectionMatrix.GetInvertion().projectTransform(0, 0, 0);           Matrix mat = new Matrix();           mat.Multiply(doc.ActiveLayOut.World2ViewMatrix);           mat.TranslateMatrix(ptV * -1.0d);           mat.RotateXMatrix(step * -1.0d);           mat.TranslateMatrix(ptV);           doc.World2ViewMatrix = mat;           doc.Redraw(true);       }       private void buttonDOWN_Click(object sender, EventArgs e)       {           gPoint ptV = doc.ActiveLayOut.Render.ProjectionMatrix.GetInvertion().projectTransform(0, 0, 0);           Matrix mat = new Matrix();           mat.Multiply(doc.ActiveLayOut.World2ViewMatrix);           mat.TranslateMatrix(ptV * -1.0d);           mat.RotateXMatrix(step);           mat.TranslateMatrix(ptV);           doc.World2ViewMatrix = mat;           doc.Redraw(true);       }       private void buttonRIGHT_Click(object sender, EventArgs e)       {           gPoint ptV = doc.ActiveLayOut.Render.ProjectionMatrix.GetInvertion().projectTransform(0, 0, 0);           Matrix mat = new Matrix();           mat.Multiply(doc.ActiveLayOut.World2ViewMatrix);           mat.TranslateMatrix(ptV * -1.0d);           mat.RotateYMatrix(step * -1.0d);           mat.TranslateMatrix(ptV);           doc.World2ViewMatrix = mat;           doc.Redraw(true);       }       private void buttonLEFT_Click(object sender, EventArgs e)       {           gPoint ptV = doc.ActiveLayOut.Render.ProjectionMatrix.GetInvertion().projectTransform(0, 0, 0);           Matrix mat = new Matrix();           mat.Multiply(doc.ActiveLayOut.World2ViewMatrix);           mat.TranslateMatrix(ptV * -1.0d);           mat.RotateYMatrix(step);           mat.TranslateMatrix(ptV);           doc.World2ViewMatrix = mat;           doc.Redraw(true);       }


    以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。

热门文章推荐:

  • 如何排除GroundSurface对象的三角形区域/strong>

  • 复杂自定义对象的入门指南

=======================================================

如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年11月12日
下一篇 2019年11月13日

相关推荐

发表回复

登录后才能评论