MAXScript101 5.3 ExportMesh - Writing Custom Scene Exporters

 

MAXScript101 5.3 ExportMesh - Writing Custom Scene Exporters

 

I. Biped Walk

1. create a bipe: create > system > biped;

2. create footsteps: 

(1) click motion, and select one part of the Biped. 

(2) under Biped rollout, select Footstep mode. 

(3) under Footstep Creation rollout, select Create Multiple Footsteps, in the dialogue, modify the Number of 

 

Footsteps and leave others default.

3.  create keys for the footsteps

with the footstep mode selected, under Footstep Operations, select Create Keys for Inactive Footsteps.

 

II. Custom Mesh Exporter

 

MAXScript101 5.3 ExportMesh - Writing Custom Scene Exporters_第1张图片  

 

 

-- dumps vertex deltas of given object in given origin -- function exportMesh obj fileName origin: obj = ( -- step1: 定义局部变量:以给定文件名创建文件,存储顶点的数组,以及总的帧数 -- define local variables local file = createFile fileName, vertStore = #(), numFrames = (animationRange.end - animationRange.start).frame as integer -- step2: 在输出的文件中,记录提示信息及数据输出的格式 -- output header lines format "%, numVerts = %, numFrames = %/n/n" / obj.name obj.numVerts numFrames / to: file format "Frame, Vert No., Delta/n" to: file -- step3: 对于每一个frame, 输出obj在当前帧与前一帧对应顶点的delta值 -- loop over anim range, dumping vertex position deltas for f = animationRange.start to animationRange.end do ( -- set MAX time slider to current frame sliderTime = f -- loop over object vertices for i in 1 to obj.numVerts do ( -- use the origin coordinate system, get the i-th vertex local v = coordsys origin getVert obj i -- if the i-th vertex exists, then dv=v - vertStore[i]; else dv = v local dv = if vertStore[i] == undefined then v else v - vertStore[i] vertStore[i] = v -- output data in Listener format "i = %, v = %, dv = %/n" i v dv -- output data to file format "%, %, %/n" (f.frame as integer) (i - 1) dv to: file ) ) -- close file close file -- edit: specifies the name of the file whose contents are to be loaded into the new MAXScript Editor window edit fileName ) -- usage: exportMesh $Bip01 "mesh-deltas.txt" origin:$Bip01 

 

III. 注解:

1. 帧数与整数的转换

animationRange.end -- return 124f

(animationRange.end - animationRange.start).frame  -- return 124.0

 

2. 有关mesh的操作,参考MAXScript Reference, 可搜索关键字:getVert

 

 

 

你可能感兴趣的:(object,File,Integer,System,reference,output)