QString qs_surface_file = QDir::currentPath() + "test.png";
TCollection_AsciiString surface_file = QStringToTCollection_AsciiString(qs_surface_file);
Handle(Graphic3d_Texture2D) texture = new Graphic3d_Texture2D(surface_file);
if (!texture.IsNull())
{
Handle(Graphic3d_TextureSet) textureset = new Graphic3d_TextureSet(texture);
if (!ais_shape->Attributes()->HasOwnShadingAspect())
{
Handle(Prs3d_ShadingAspect) shadingAspect = new Prs3d_ShadingAspect();
ais_shape->Attributes()->SetShadingAspect(shadingAspect);
}
ais_shape->Attributes()->ShadingAspect()->Aspect()->SetTextureSet(textureset);
ais_shape->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
bool state = ais_shape->Attributes()->ShadingAspect()->Aspect()->TextureMapState();
if (state)
{
Standard_Real toScaleU = 1;
Standard_Real toScaleV = 1;
Standard_Real toRepeatU = 3;
Standard_Real toRepeatV = 2;
Standard_Real originU = 0;
Standard_Real originV = 0;
ais_shape->SetTextureScaleUV(gp_Pnt2d(toScaleU, toScaleV));
ais_shape->SetTextureRepeatUV(gp_Pnt2d(toRepeatU, toRepeatV));
ais_shape->SetTextureOriginUV(gp_Pnt2d(originU, originV));
}
}
ais_shape->SetPolygonOffsets(Aspect_POM_Fill, 1.5, 0.5);
ais_shape->SetMaterial(Graphic3d_NOM_SILVER);//设置黄铜颜色Graphic3d_NOM_BRASS 设置银色,影响光学特性和颜色
old_ais_shape->GetContext()->Redisplay(ais_shape,true);
opencascade中为模型设置贴图
最新推荐文章于 2024-07-02 20:57:16 发布