文档半岛外围网上直营>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(四十七):如何在vdPolyface的特定面上应用映射的图像?
VDF常见问题整理(四十七):如何在vdPolyface的特定面上应用映射的图像?
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
问:
如何在vdPolyface的特定面上应用映射的图像? 如果vdPolyface的面不在X / Y平面中,最后就会得到一些奇怪的结果。怎么才能解决这个问题?
答:
对于此代码,可以使用以下图像:

(点击可下载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 + 结果显示:

请注意:图像将应用于整个多面体,而不是应用于特定的一个或多个面,因此,如果图像投影中有面(如该三次多面体的底部),则图像也将应用于它们。
以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
热门文章推荐:
=======================================================
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线