Jump to content

script - auto animate rotation


Recommended Posts

This is the first script I ever wrote in max script after seeing an arch viz animation featuring a building "being built" by lots of rotating slabs.

 

I wanted to do something similar for some pathing I was doing at the time and decided to learn max script. Feel free to have a play with it. I'm spending today writing it as an object modifier. Any suggestions for interaction would be welcome.

 

The script requires one camera named camera01 and rotates every object in the selection 180 degrees one after the other, within a given number of frames, ordered based on their distance from camera01

 

 
oA=for i in $selection collect i
fn cF v1 v2 =
(
local d = (distance v1.pos $camera01.pos)-(distance v2.pos $camera01.pos)
case of
(
(d (d > .0): -1
default: 0
)
)
qsort oA cF 
for p in oA do print p
global nF = 200;
global nO = oA.count;
global inc = nF/nO;
global sT = 0;
global eT = inc;
global iR = eulerangles 0 0 0;
global rB = eulerangles 0 180 0;
animationrange = interval 0 nF;
rotate selection rB;
for i in oA do
(
animate on
(
at time sT (rotate i iR)
at time eT (rotate i rB)
 )
sT = sT + inc;
eT = eT + inc;
) 

Link to comment
Share on other sites

Thanks, feel free to play. I have plans to pack a few of my scripts into something more user friendly. At the moment they are just a bunch of glorified keyboard shortcuts designed to speed modeling and extend my coffee breaks.

 

It's quite addictive, I'm hooked at the moment on a script for automating the animation of characters playing instruments based on midi and tab data from tab music files. Not sure how useful that will be to the cg/arch viz community but I'll post it if I ever get it finished :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...