opencascade中为模型设置贴图

	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);
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值