Geometry 对象浅析
Multipatch
Multipatch用于描述3D面状几何类型,由一系列的矢量三角形构成,如果其中的part是一个ring,那么它必须是封闭的,第一个节点和最后一个节点相同,另外每个part所包含节点的顺序非常重要,Inner Rings在Outer Rings之后,代表单个表面patch的一系列rings必须由第一个ring开始。
在9.0以后的开发包中,使用IGeneralMultiPatchCreator创建新的Multipatch,IGeometryMaterial进行材质贴图。
public IMultiPatch CreateMultipatch()
...{
//Prepare the geometry material list.
IGeometryMaterial texture = new GeometryMaterialClass();
texture.TextureImage = "C:\\Temp\\MyImage.bmp";
![]()
IGeometryMaterialList materialList = new GeometryMaterialListClass();
materialList.AddMaterial(texture);
![]()
//Create the multipatch.
IGeneralMultiPatchCreator multiPatchCreator = new GeneralMultiPatchCreatorClass();
multiPatchCreator.Init(4, 1, false, false, false, 4, materialList);
![]()
//Set up part.
![]()
//Could also use a Ring or a TriangleFan.
multiPatchCreator.SetPatchType(0, esriPatchType.esriPatchTypeTriangleStrip);
multiPatchCreator.SetMaterialIndex(0, 0);
multiPatchCreator.SetPatchPointIndex(0, 0);
multiPatchCreator.SetPatchTexturePointIndex(0, 0);
![]()
//Set real-world points.
WKSPointZ upperLeft = new WKSPointZ();
WKSPointZ lowerLeft = new WKSPointZ();
WKSPointZ upperRight = new WKSPointZ();
WKSPointZ lowerRight = new WKSPointZ();
![]()
upperLeft.X = 0;
upperLeft.Y = 0;
upperLeft.Z = 0;
upperRight.X = 300;
upperRight.Y = 0;
upperRight.Z = 0;
lowerLeft.X = 0;
lowerLeft.Y = 0;
lowerLeft.Z = -100;
lowerRight.X = 300;
lowerRight.Y = 1;
lowerRight.Z = -100;
![]()
multiPatchCreator.SetWKSPointZ(0, ref upperRight);
multiPatchCreator.SetWKSPointZ(1, ref lowerRight);
multiPatchCreator.SetWKSPointZ(2, ref upperLeft);
multiPatchCreator.SetWKSPointZ(3, ref lowerLeft);
![]()
//Set texture points.
//Set the texture coordinates for a panel.
WKSPoint textureUpperLeft = new WKSPoint();
WKSPoint textureLowerLeft = new WKSPoint();
WKSPoint textureUpperRight = new WKSPoint();
WKSPoint textureLowerRight = new WKSPoint();
![]()
textureUpperLeft.X = 0;
textureUpperLeft.Y = 0;
textureUpperRight.X = 1;
textureUpperRight.Y = 0;
textureLowerLeft.X = 0;
textureLowerLeft.Y = 1;
textureLowerRight.X = 1;
textureLowerRight.Y = 1;
![]()
multiPatchCreator.SetTextureWKSPoint(0, ref textureUpperRight);
multiPatchCreator.SetTextureWKSPoint(1, ref textureLowerRight);
multiPatchCreator.SetTextureWKSPoint(2, ref textureUpperLeft);
multiPatchCreator.SetTextureWKSPoint(3, ref textureLowerLeft);
IMultiPatch multiPatch = multiPatchCreator.CreateMultiPatch() as IMultiPatch;
![]()
return multiPatch;
}
参考资料:ArcEngine 9.2帮助文档
0