VDF常见问题整理(四十七):如何在vdPolyface的特定面上应用映射的图像?

VectorDraw Developer Framework试用版下载


问:

    如何在vdPolyface的特定面上应用映射的图像如果vdPolyface的面不在X / Y平面中,最后就会得到一些奇怪的结果。怎么才能解决这个问题/p>

答:

    对于此代码,可以使用以下图像:

转换器

点击可下载VectorDraw File Converter

    请参见下面的代码和注释:

   vdDocument doc = framed.BaseControl.ActiveDocument;            doc.New(); // create a new dowcument and add a "box" polyface            bool res = doc.CommandAction.CmdBox3d(new gPoint(10, 10, 3), (double)3.0d, (double)3.0d, (double)3.0d,                         VectorDraw.Geometry.Globals.DegreesToRadians((double)23.5d));            if (!res) return;            vdPolyface pface = doc.ActiveLayOut.Entities.Last as vdPolyface; // this the polyface just created by CmdBox3d            if (pface == null) return;            doc.CommandAction.CmdRotate3d("Y", pface, new gPoint(), (double)62.1d); // rotate it a bit             doc.CommandAction.View3D("VINW"); doc.CommandAction.View3D("SHADEON"); // set the view            vdImageDef imgdef = doc.Images.Add(@"converter_200x200.png"); //add the image definition to be applied            if (imgdef == null) return;             int choosenface = 3; // 0,1,2,..,7   8 faces in total In this face we will apply the material            // get the position of the points that make the specific face            int[] face = new int[] { pface.FaceList[choosenface * 5 ], pface.FaceList[choosenface * 5 + 1], pface.FaceList[choosenface * 5 + 3] };            gPoint origin = new gPoint(pface.VertexList[face[0]]); // set which point will be the origin of the image            gPoint xDir = new gPoint(pface.VertexList[face[1]]); // set which point will be the x direction of the image            gPoint yDir = new gPoint(pface.VertexList[face[2]]); // set which point will be the y direction of the image            Matrix mat = new Matrix(); // need to create the Matrix to be applied            Vector xver = new Vector(origin, xDir); // based on the origin            Vector yver = new Vector(origin, yDir); //xdir and ydir            mat.SetFrom(origin, xver, yver);            gPoint originTrans = mat.Transform(origin); // get the transformed origin            gPoint xDirTrans = mat.Transform(xDir);// get the transformed x direction            //create the mapped image            double border = originTrans.Distance3D(xDirTrans) / 100.0d; // give a bit of a border arround            vdMappedImage mappedimg = new vdMappedImage(imgdef, new gPoint(originTrans.x +

    结果显示:

70001303_1.png

请注意:图像将应用于整个多面体,而不是应用于特定的一个或多个面,因此,如果图像投影中有面(如该三次多面体的底部),则图像也将应用于它们。


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

热门文章推荐:

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

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

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

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

标签:

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

上一篇 2019年11月19日
下一篇 2019年11月19日

相关推荐

发表回复

登录后才能评论