《generate smooth group in 3ds max》

本文介绍了一个使用3ds Max进行批量导入、平滑处理并导出模型的自动化脚本。该脚本通过设置自动平滑阈值来优化模型的平滑组,支持递归目录操作,并可以将处理后的模型导出为FBX格式。

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

(

local ResetMax
local GetAllFilesWithPatternInDirectoryRecursively
local DoedFolderExist
local DoImportFile
local DoExportFile
local DoAutoSmooth
 
fn StartExecute =
(
--Fields
local rootFolderPath = "D:\Source"
local exportRootFolderPath = "D:\Dest"
local autosmoothThreshold = 50.0
local exportASCII = true
--Editable_Poly for some reason gives bad results. false for now
local useEditablePoly = false
ResetMax()
 
openLog(exportRootFolderPath+"\"+logFileName) mode:"w" outputonly:true
 
print("Start: "+(timestamp() as string))
print("SutismoothThreshold: "+ (autosmoothThreshold as string))
 
local filesInFolder = GetAllFilesWithPatternInDirectoryRecursively rootFolderPath "*.fbx"
 
print("Files to Process: " + (filesInFolder.count as string))
 
for filePath in filesInFolder do
(
--if filenameFromPath filePath != "__xxx.fbx" then
--continue
print "New Object"
print filePath
 
DoImportFile(filePath)
 
DoAutoSmooth autosmoothThreshold useEditablePoly
 
local exportPath = replace filePath 1 rootFolderPath.count exportRootFolderPath
 
print exportPath
 
DoesFolderExist(getFilenamePath exportPath) create:true
 
DoExportFile exportPath exportASCII
 
ResetMax()
 
--Exit()
)
)
 
--Returns an array
fn GetAllFilesWithPatternInDircetoryRecursively dir pattern =
(
local dirArr = GetDirectories(dir+"\\*")
for d in dirArr do
(
join dirArr (getDirectories(d+"\\*"))
)
 
append dirArr (dir+"\") -- Need to include the original top level directory
 
local patternMatchedFile = #()
 
for f in dirArr do
(
join patternMatchedFiles (getFiles(f+pattern))
)
return patternMatchedFiles
)
 
--Test whether folderPath exists and is a folder; create it if it doesn't and create==true
fn DoesFolderExist folderPath create:true = 
(
local val = if(doesFileExist folderPath) and (getfileattribute folderPath #directory) then true else false
 
if not val and create then
(
val = makeDir folderPath
)
 
return val
)
 
fn DoImportFile fileName =
(
FBXImporterSetParam "ResetImport"
FBXImporterSetParam "SmoothingGroups" true
importFile fileName #noPrompt using:FXBIMP
)
 
fn DoExportFile fileName exportASCII =
(
FBXExporterSetParam "ResetExport"
FBXExporterSetParam "SmoothingGroups" true
FBXExporterSetParam "Animation" false
FBXExporterSetParam "Cameras" false
 
--Set to true if you want a Human-Readable file.
if exportAscii then
(
FBXExporterSetParam "ASCII" true
)
 
if units.SystemType == #Inches then
(
print "Converting Units to CM"
 
--This is completely broken.
--FBXExporterSetParam "COnvertUnit" "cm"
 
--Shitty replacement solution
selectedObject = selection[1]
print selectedObject.scale
selectedObject.scale=[1,1,1]
print selectedObject.scale
)
print "Exp Smooth?"
print ((FBXExporterGetParam "SmoothingGroups") as string)
exportFile (fileName) #noPrompt selectedOnly:false using:FBXEXP
)
 
fn ResetMax=
(
--Reset max file silently
resetMaxFile #noPrompt
)
 
fn ExitMan=
(
--Exit max
quitMax #noPrompt
)
 
fn DoAutoSmooth autosmoothThreshold useEditablePoly=
(
if selection.count == 1 then
(
print selection[1]
selectedObject = selection[1]
if useEditablePoly then
(
convertTo selectedObject Editable_Poly
)
select selectedObject
if useEditablePoly then
(
print "converting to Editable Poly"
polyOp.setFaceSelection selectedObject #{1..polyOp.getNumFaces selectedObject}
 
--Clear existing smoothing groups
selectObject.EditablePoly.setSmoothingGroups 0
 
selectedObject.autosmoothThreshold = autosmoothThreshold
 
print "[erforming AutoSmooth on Editable Poly"
selectedObject.EditablePoly.autosmooth()
)
else
(
print "Performing AutoSmooth on Editable Mesh"
meshop.autoSmooth selectedObject #{1..selectedObject.numfaces} autosmoothThreshold
)
)
else
(
print "Error:Multiple Objects Selected."
)
)
 
--Start at the end?
StartExecute()
 
ExitMax()
)
posted on 2017-07-11 01:30 DeanWang 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/DeanWang/p/7148570.html

``` def create_coord(self): return o3d.geometry.TriangleMesh.create_coordinate_frame(size=1.0) def project_to_slice_plane(self, points, mode, param): """将三维点投影到切片平面,返回投影后的三维坐标和二维特征坐标""" if mode == 'x': projected = np.copy(points) projected[:, 0] = param # X坐标固定 features = projected[:, [1, 2]] # 取Y,Z作为二维特征 elif mode == 'y': projected = np.copy(points) projected[:, 1] = param # Y坐标固定 features = projected[:, [0, 2]] # 取X,Z作为二维特征 elif mode == 'polar': # 计算极坐标投影参数 ct, st = np.cos(param), np.sin(param) s = points[:, 0] * ct + points[:, 1] * st # 沿极角方向的投影 projected = np.column_stack(( points[:, 0] * ct ** 2 + points[:, 1] * ct * st, points[:, 0] * ct * st + points[:, 1] * st ** 2, points[:, 2] )) features = np.column_stack((s, points[:, 2])) # 取S,Z作为二维特征 return projected, features def fit_curve(self, features, mode): if len(features) < 2: return [] # 改进排序逻辑 sort_idx = np.argsort(features[:, 0]) sorted_features = features[sort_idx] # 改进分割逻辑 if len(sorted_features) < 2: return [] diffs = np.diff(sorted_features[:, 0]) split_index = np.argmax(diffs) + 1 if len(diffs) > 0 else 0 curves = [] for group in [sorted_features[:split_index], sorted_features[split_index:]]: if len(group) < 3: continue # 使用线性插值作为后备方案 try: f = interp1d(group[:, 0], group[:, 1], kind='linear', fill_value='extrapolate') x_new = np.linspace(group[:, 0].min(), group[:, 0].max(), 100) y_new = f(x_new) # 改进滤波参数 window_length = min(21, len(y_new)) if window_length > 3 and window_length % 2 == 1: y_smooth = savgol_filter(y_new, window_length, 2) else: y_smooth = y_new curves.append(np.column_stack((x_new, y_smooth))) except Exception as e: print(f"曲线拟合优化后仍失败: {str(e)}") return curves def calculate_curvature(self, curve): """计算曲线的曲率""" x = curve[:, 0] y = curve[:, 1] dx = np.gradient(x) dy = np.gradient(y) ddx = np.gradient(dx) ddy = np.gradient(dy) curvature = np.abs(ddx * dy - dx * ddy) / (dx**2 + dy**2)**(3/2) return curvature def split_curve_by_curvature(self, curve, threshold=0.05): """根据曲率分割曲线""" curvature = self.calculate_curvature(curve) diff_curvature = np.abs(np.diff(curvature)) split_indices = np.where(diff_curvature > threshold)[0] + 1 sub_curves = np.split(curve, split_indices) return sub_curves def calculate_length(self, curve): """计算曲线的长度""" x = curve[:, 0] y = curve[:, 1] dx = np.diff(x) dy = np.diff(y) ds = np.sqrt(dx**2 + dy**2) length = np.sum(ds) return length```clickable Avatar: undefined 能否帮我根据下面的数据画出曲线圆弧 1: 半径=9.975, 弧长=2.170 圆弧 2: 半径=105.750, 弧长=61.535 圆弧 3: 半径=3289.445, 弧长=27.438 圆弧 4: 半径=218.040, 弧长=27.862 圆弧 5: 半径=9.093, 弧长=2.647
03-27
基于Spring Boot搭建的一个多功能在线学习系统的实现细节。系统分为管理员和用户两个主要模块。管理员负责视频、文件和文章资料的管理以及系统运营维护;用户则可以进行视频播放、资料下载、参与学习论坛并享受个性化学习服务。文中重点探讨了文件下载的安全性和性能优化(如使用Resource对象避免内存溢出),积分排行榜的高效实现(采用Redis Sorted Set结构),敏感词过滤机制(利用DFA算法构建内存过滤树)以及视频播放的浏览器兼容性解决方案(通过FFmpeg调整MOOV原子位置)。此外,还提到了权限管理方面自定义动态加载器的应用,提高了系统的灵活性和易用性。 适合人群:对Spring Boot有一定了解,希望深入理解其实际应用的技术人员,尤其是从事在线教育平台开发的相关从业者。 使用场景及目标:适用于需要快速搭建稳定高效的在线学习平台的企业或团队。目标在于提供一套完整的解决方案,涵盖从资源管理到用户体验优化等多个方面,帮助开发者更好地理解和掌握Spring Boot框架的实际运用技巧。 其他说明:文中不仅提供了具体的代码示例和技术思路,还分享了许多实践经验教训,对于提高项目质量有着重要的指导意义。同时强调了安全性、性能优化等方面的重要性,确保系统能够应对大规模用户的并发访问需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值