How To ... Move Objects to a Surface的疑问之处

本文介绍了一个用于将3D场景中的物件移动到指定表面的宏脚本。通过射线检测技术找到物件与目标表面的交点,并据此调整物件位置。文中还讨论了射线概念及undo功能的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文章名:How To ... Move Objects to a Surface


=====================================
 macroscript MoveToSurface category:"HowTo"


(

fn g_filter o = superclassof o == Geometryclass

fn find_intersection z_node node_to_z =

(

local testRay = ray node_to_z.pos [0,0,-1]

local nodeMaxZ = z_node.max.z

testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ

intersectRay z_node testRay

)

on isEnabled return selection.count > 0

on Execute do

(

target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter

if isValidNode target_mesh then

(

undo "MoveToSurface" on

(

for i in selection do

(

int_point = find_intersection target_mesh i

if int_point != undefined then i.pos = int_point.pos

)--end i loop

)--end undo

)--end if

)--end execute

)--end script



========================================================

看了一个小时,没看懂,划红线的是不明白的地方,ray 什么意思一直搞不明白,google翻译成射线,很别扭,不知道专业的怎么称呼

还有undo 的用法,帮助文档也没看明白


文档中有一句话是这么解释undo在本段代码中的作用: In case a valid object has been picked, enable an undo context ,没读懂,也请指点一下

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值