首页 / 浏览问题 / 组件GIS / 问题详情
如何更新导入模型的纹理?
8EXP 2019年04月28日

您好,请问:

在idesktop.net 9.1.0.16631桌面端,可以编辑模型更新纹理.

图层类型:SuperMap.Realspace.Layer3DDataset

楼房模型:GeoModel3D

Model:存在纹理,且属性如下:

HasLOD false bool
LODCount 0x00000000 int

问题:1,以下代码的方式更改GeoModel3D的纹理,存在什么问题?

   2,正确的更新GeoModel3D纹理的方法是什么?

问题环境:supermap-iobjectsdotnet-9.1.1-16828-70590-all.zip

应用64位. 操作系统:win7 x64

重现步骤:

1,让模型图层,可编辑.

2,用鼠标选中一个带纹理的模型时,运行测试代码A.

3,场景内模型建筑并没有更新为指定的纹理.

测试代码A 如下:

void UpdateTexture(GeoModel3D geoModel3D,int iLod)
{
try
{
string strModelLayer = "Building@OlympicGreen";
Scene scene = Scene;
Layer3D layer3D = scene.Layers[strModelLayer];
layer3D.IsEditable = true;


Model model = geoModel3D.Model;
int count = model.GetSkeletonCount(iLod);

for (int i = 0;i < count; i++)
{
SkeletonID id = new SkeletonID();
id.Skeleton = i;
id.LOD = iLod;

Skeleton skeleton = model.GetSkeleton(id);

if (null == skeleton)
{
continue;
}

Material3D material3D = skeleton.Material;
int iCountTexture = material3D.Textures.Count;
material3D.RemoveTextures();

List<TextureData> list = new List<TextureData>();
for (int j = 0; j < iCountTexture; j++)
{
TextureData textureData = new TextureData();
textureData.Name = "08oh0301.jpg";

string strPath = @"E:\08oh0301.jpg";
textureData.FromFile(strPath);

list.Add(textureData);
}

material3D = new Material3D();
material3D.Name = "materialName";

material3D.Textures = list;

if(list.Count > 0)
{
TextureData textureData = list[0];
material3D.Texture = textureData;
}
else
{
TextureData textureData = new TextureData();
textureData.Name = "08oh0301.jpg";

string strPath = @"E:\08oh0301.jpg";
textureData.FromFile(strPath);
material3D.Texture = textureData;
}

skeleton.Material = material3D;
model.Update(skeleton);
}

geoModel3D.Model = model;
layer3D.UpdateData();
}
catch(Exception e)
{

}
finally
{
Scene.Refresh();
}
}

问题关闭原因: 因为一天前没有看到问题发布,所以重新发布了.
...