# 常规三维切片制作-局部坐标系-Quat

3dmax中模型分割后使用该脚本构建tileset,使用局部相对坐标(使用RTC_CENTER),模型之间相对位置更为精确, 该方法使用了quaterion作为旋转信息

# 适用场景

适用于某一栋建筑物,部件之间构建3dtiles,门,窗,墙壁等部件之间需要精确对接情景

# 使用方法

  1. 直接在3dmax中选择对象集合
  2. 仅影响轴,居中到对象
  3. 执行以下脚本 exportInfo.ms,输出模型信息
点击查看代码
   --select $*???*
   --max select all
   selObj = selection as Array

   out_file = createfile "F:/Document/3dsMax/export/output_info.txt" encoding:#utf8
   --format "id;name;pos;width;z;mesh\n" to:out_file

   for i=1 to selObj.count do(
   if classOf selObj[i] == 'Editable_mesh' do
       format "%;%;%;%;%;[%,%]\n" (i) (selObj[i].name) (selObj[i].pos) (selObj[i].max-selObj[i].min) (selObj[i].rotation) (selObj[i].mesh.numverts) (selObj[i].mesh.numfaces)to:out_file
   )
   close out_file
  1. 修改该脚本中txtFile路径,并执行,执行结果在txtFile同目录下
  2. 3dmax中批量导出模型,导出之前需要把模型坐标改为0,旋转角度设为0,使用batchExportObj.ms 执行:
点击查看代码
fn exportAll=(
     --max select all
     selObj = selection as Array
     dir_path = "F:/Document/3dsMax/export"
     for i=1 to selObj.count do(
         select selObj[i]
         pos = $.pos
         rotation = $.rotation
         $.pos = [0,0,0]
         $.rotation = (quat 0 0 0 1)
         file_path = dir_path + "/" +($.name) +".fbx"
         exportfile file_path #noprompt selectedOnly:true
         $.pos = pos
         $.rotation = rotation
     )
     close out_file
 )
 exportAll()
  1. 批量执行:
    fbx2gltf -i data.fbx -o data.glb