home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Maximum 3D 3
/
m3d-p3.iso
/
3DS_MAX
/
3DSMAX.2_0
/
SCRIPTS
/
BANK.MS
< prev
next >
Wrap
Text File
|
1997-10-19
|
2KB
|
61 lines
-- A bank-and-turn function that takes any animated object (not
-- just one that is animated along a path) and will generate
-- bank and turn keyframes, with controls similar to those
-- in the path controller.
-- John Wainwright
bx = box length:200 width:200 height:10 mapcoords:true \
lengthsegs:16 widthsegs:16
function fly obj bank:on bankAmount:40 smoothness:5.0 dt:2f bankSteps:5 =
(
local tm = scaleMatrix obj.scale, local_r,
pt0 = at time (currentTime - dt) obj.pos,
pt1 = at time (currentTime + dt) obj.pos
tm.translation = obj.pos
tm.row1 = normalize (pt1 - pt0)
tm.row2 = cross [0,0,1] tm.row1
tm.row3 = cross tm.row1 tm.row2
if bank then
(
local pt2, v0, v1,
cv = 0.0,
t = currentTime - (bankSteps/2.0) * smoothness,
terms = 0,
end_t = (getTimeRange obj.pos.controller).end
pt1 = at time t obj.pos
t += smoothness
pt2 = at time t obj.pos
t += smoothness
for i in 1 to bankSteps do
(
if t > end_t then exit
pt0 = pt1; pt1 = pt2
pt2 = at time t obj.pos
v0 = normalize (pt2 - pt1)
v1 = normalize (pt1 - pt0)
v0.z = v1.z = 0
if pt0 == pt1 then exit
cv += (cross v0 v1).z * bankAmount / length (pt1 - pt0)
terms += 1
t += smoothness
)
if terms > 0 then preRotateX tm ((cv/terms) * (180/pi))
)
obj.transform = tm
)
-- this will place keyframes every 5 frames
animate on for t in 0 to 100 by 5 do at time t fly $box01
-- this will place key frames at existing position keyframes,
-- probably not enough
animate on for k in $box01.pos.keys do at time k.time fly $box01
-- if you want to delete all the scale keys, use:
deleteKeys $box01.scale.controller