VDF常見問(wèn)題整理(四十六):如何使用方向鍵模擬VROT?
VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫(kù)。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
問(wèn):
在VDF中,如果我想使用諸如UP,DOWN,LEFT RIGHT之類的方向鍵來(lái)模擬CommandAction.View3D( VROT)。然后在每次單擊方向按鈕時(shí),呈現(xiàn)的結(jié)果是按照預(yù)定的方向沿該方向旋轉(zhuǎn)場(chǎng)景。想要請(qǐng)問(wèn)怎么樣才能實(shí)現(xiàn)?
答:
很簡(jiǎn)單,只需要以表單形式添加vdFramed或vdScrollable控件和五個(gè)按鈕,然后嘗試執(zhí)行以下代碼:
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); }
以上問(wèn)答,如果您有任何的疑惑都可以在評(píng)論區(qū)留言,我們會(huì)及時(shí)回復(fù)。此系列的問(wèn)答教程我們會(huì)持續(xù)更新,如果您感興趣,可以多多關(guān)注本教程。
熱門文章推薦:
=======================================================
如果您對(duì)想要購(gòu)買正版授權(quán)VectorDraw Developer Framework(VDF),可以聯(lián)系在線客服>>咨詢相關(guān)問(wèn)題。
關(guān)注慧聚IT微信公眾號(hào) ???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。