>: CG Forums on 3dtotal - The best forums for CG artists :.
threedy forums home
 


top-table-gradient
Go Back   3DTotal Forums > Archives > Archives > Scripting & coding
bottom-table-gradient

Reply
 
Thread Tools Display Modes
Old 16-05-2007, 12:53 AM   #1
MaggieQue
Registered User
 
MaggieQue's Avatar
 
 
Join Date: Apr 2005
Location: Singapore
Posts: 2,326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MaggieQue Send a message via Skype™ to MaggieQue
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! Speed Animation - Gold: Winner of a speed animation challenge! - Issue reason: For Excellence in Speed Animation 
Total Awards: 3
Lightbulb Using Maxscript generates Escalator Animation v1.0

Please correct me if it's wrong.

Using Maxscript generates Escalator Animation v1.0


Why we need to use maxscript to generate escalator animation?
1. When using path constraint and turn on “Follow”, the object flips unreasonably.


2. If turn off “Follow” at Path Constraint, and animate the escalator steps rotation manually, it becomes repetitive burden if there are thousands of steps. The following is an animated gif of duplicated escalator steps, with same rotation keyframes but different “% Along Path”. Will you spends hour to move the keys with your hand?
MaggieQue is offline   Reply With Quote
Old 16-05-2007, 12:56 AM   #2
MaggieQue
Registered User
 
MaggieQue's Avatar
 
 
Join Date: Apr 2005
Location: Singapore
Posts: 2,326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MaggieQue Send a message via Skype™ to MaggieQue
Awards Showcase
Threedy Top Poster - Silver: Contributing to the forums with 1,000+ posts - Issue reason: Target reached! Threedy Top Poster - Bronze: Contributing to the forums with 100+ posts - Issue reason: Target reached! Speed Animation - Gold: Winner of a speed animation challenge! - Issue reason: For Excellence in Speed Animation 
Total Awards: 3
How to use this script?
1. Preparing a rectangle spline path (any length, width and corner radius), called Rectangle01, and make sure the “first vertex” is at your right hand top:


2. After applying path constraint to escalator step (called Box01) by using Rectangle01 path, animate “% Along Path” to 200 (or 300, 350 etc, minimum is 200) at frame 100. This value is called var3 in the script.


3. Find out which frames the escalator step starts and ends rotating. So we have
var2 = 18 --1st keyframe, when rotation 0.
var4 = 25 --2nd keyframe, when rotation 180.



4. From the menu, click Maxscript > New Script, copy and paste the following code and edit the values. Then click CTRL+E (File > Evaluate All).


Code:
--Value that you could change
numbox = 25 --Total of box/escalator step.
var1 = 4 --Time interval (%Along Path" of Path constraint) between boxes. Smaller value causes smaller gaps between boxes.
var3 = 200 as float --Speed, minimum 200, must same with last animation keyframe: "%Along Path" of Path constraint.
var2 = 18 --1st keyframe, when rotation 0.
var4 = 25 --2nd keyframe, when rotation 180.

--DONOT change these
endframe = 100 as float --End Time, you could re-scale time manually at Time Configuration dialog after running this script.
period = var3/endframe
animationRange = interval 0 endframe
sliderTime=0
set coordsys local
myarray = #()
myarray[1] = $Box01
$Box01.pos.controller = path follow:false 
PosCont=$Box01.pos.controller 
PosCont.path= $Rectangle01
PosCont.axis=0
animate on(at time endframe $Box01.pos.controller.percent=var3)

for i=2 to numbox do
(
myarray[i] = instance myarray[1]
myarray[i].pos.controller.percent = (i-1)*(-var1)
)

for j=1 to myarray.count do
(
myarray[j].wirecolor = (color 88 199 255)
animate on(
for k=0 to (period-1) do
(
at time (endframe/(var3/var2/(var3/100))*1               + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 0 y_axis)
at time (endframe/(var3/var2/(var3/100))*1+(var4-var2)   + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 180 y_axis)
at time (endframe/(var3/var2/(var3/100))*2+(var4-var2)   + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 0 y_axis)
at time (endframe/(var3/var2/(var3/100))*2+2*(var4-var2) + (endframe/period)*k + (var1*100/var3)*(j-1)) rotate myarray[j] (quat 180 y_axis)
)))
animationRange = interval 50 endframe
5. It runs, but speed too fast. So we need to re-scale the animation. We have to set the start time to zero first, then res-scale time.



Animation before scaling time:
http://s82.photobucket.com/albums/j2...rrent=054g.flv

Animation after scaling time:
http://s82.photobucket.com/albums/j2...rrent=054i.flv

That's all. Please correct me if anything's wrong.
MaggieQue is offline   Reply With Quote
Old 09-06-2007, 12:53 PM   #3
Alendri85
Registered User
 
Join Date: Mar 2007
Location: Sweden
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Alendri85
Great script, works like a charm for many things, I used it to send sparks along a wire and a bunch of water drops in anther animation.

Now I might aim to incorporate an escalator in some future animation just for the reason to use this script in it's proper way heh

//Alendri
Alendri85 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 11:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
all images displayed on this site are copyright the original artists and may not be reproduced, copied or published elsewhere without their express permission