ruby - Sketchup Ruby,为面添加纹理
问题描述
我正在使用它来添加绘制一个盒子,然后为盒子着色。
l=96
w=60
h=60
clr='Gray'
ent = Sketchup.active_model.entities
#---------Clear All
Sketchup.active_model.entities.clear!
#----------------
model = Sketchup.active_model
model.start_operation "Create Box"
#-----------------------------------------------------------------------------
entities = model.active_entities
group = entities.add_group
entities = group.entities
group.name = "Box"
@pt0 = [0, 0, 0]
@pt1 = [0, l*12, 0]
@pt2 = [w*12.0, l*12, 0]
@pt3 = [w*12, 0, 0]
newface = entities.add_face(@pt0, @pt1, @pt2, @pt3)
newface.material = Sketchup::Color.new clr
newface.reverse!
newface.pushpull h*12
我也想添加纹理,但找不到如何做到这一点。
就像“Metal Corrugated Shiny”一样,但还没有弄清楚如何做到这一点。
有人知道如何用红宝石添加纹理吗?
解决方案
你想要的元素是Texture
. 这是公开图像纹理信息(如宽度和高度、平均颜色等)的类对象。
设置纹理的最简单方法是直接在材质上。
newface.material = Sketchup::Color.new clr
newface.material.texture = "C:\\MyMaterialDirectory\\MyMaterial.jpg"
显然,该文件需要是有效的图像并位于适当的目录中。
推荐阅读
- flutter - 在颤振中使用 Navigator.push() 导航到页面时发生内存泄漏
- c# - 基于 2D Shader 的阴影实现
- javascript - Day.js 倒数计时器
- reactjs - 有没有办法通过反应删除firebase中的集合?
- java - 分两步创建 SHA256withRSA
- java - NoSuchMethodError:org.apache.hadoop.conf.Configuration.getPassword
- azure-devops - 我如何使用自定义名称来评论工作项,想要使用通用名称而不是基于 PAT 的显示名称
- c# - 如何访问直接放在kudu home/site/wwwroot中的html页面?
- python-3.x - Pandas 按列分组并应用函数创建新列
- firebase - 排除为 Flutter Web 运行 firebase_messaging