>: 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 14-08-2006, 09:57 PM   #1
vicar
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
How to execute MAX Script on every frame at render time ? - please advise

Hello All !

I wonder if somebody would be so kind as to point me closer to the solution of the particular MAX Script issue I have.

Using Max 6, I need a precise control over a video file bitmap starttime property (found in "Time" rollout of the Material editor).
That property is not animatable directly in Max 6 , so I wrote a tiny script that manages what I want to achieve, but only at viewport level.

Here's a script :

*************************************
unRegisterTimeCallback startFrame_add

fn startFrame_add = (
if mod sliderTime 100 == 0 then (
meditMaterials[1].material1.diffuseMap.starttime += 25
)
)

registerTimeCallback startFrame_add

*************************************
I know it's very crude, but as said - it works as a "proof of concept".

What it does is : Every 100 frames the start time (offset) of a video file placed in difussion channel of my object material is set back by 25 frames.

I won't bore anybody explaining just why do I need such effect, suffice to say the script above works, but just in the viewports.

It does not execute at render time, however

I know I am missing something vital to do with a different type of callback mechanism, but after trying out several routes I am none the wiser still ...

Can anybody think of how to implement a script that will have the same result, but at reder time ?

(And before anybody suggests to edit my source Video file in the first place prior to using it in Diffuse channel - Thank you, but it would be very unpractical in my case as I need to use several varying segments of it with different delays)

Your help will be much appreciated !

Thank you.
vicar is offline   Reply With Quote
Old 17-08-2006, 04:31 AM   #2
Nykster
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Hi
I hope I understand the problem correctly, here's a solution that could work... if you haven't already tried it

You could use the "general event callback" from Max; #postRenderFrame:

callbacks.addScript #postRenderFrame "startFrame_add()" id:#MyCallBack

According to MaxScript reference, this callback will is sent after each frame is rendered. So the function "startFrame_add" will be called after each frame is done rendering. I haven't tried that particular callback, so I dont know if it's gonna work... Good luck

Oh and, you might wanna kill the callback when you close your script or something... (callbacks.removeScripts id:#MyCallBack)

Hope this helps...
Nykster is offline   Reply With Quote
Old 07-04-2007, 09:47 AM   #3
eeek
Registered User
 
eeek's Avatar
 
Join Date: Mar 2004
Location: UK & Canada
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
why dont you call the fn on each frame, then render each frame sequencially using a for loop? then load the frames into the video post and render out as a movie etc?
__________________
Please leave a message after the beep...

Snr Technical Animator
Bioware Corp, Canada
eeek is offline   Reply With Quote
Old 20-04-2007, 04:24 AM   #4
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
I used for loop generate keys.



Code:
deleteKeys meditMaterials[1].diffuse.controller /*Delete diffuse color keyframes at Slot1 material if applicable*/
delete $* /*Delete everything on scene*/
b = box() /*Create box*/
b.material = meditMaterials[1] /*Assign Slot1 material to box*/

animate on
(
for i=0 to 100 by 10 do /*Create key at every 10th frame within 100 frames*/
(
at time i
(
--Generate random color
meditMaterials[1].diffuse.r = (random 0 255)
meditMaterials[1].diffuse.g = (random 0 255)
meditMaterials[1].diffuse.b = (random 0 255)
)
)
)

Last edited by MaggieQue; 20-04-2007 at 04:35 AM..
MaggieQue is offline   Reply With Quote
Old 20-04-2007, 04:43 AM   #5
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
Quote:
Originally Posted by vicar
I need a precise control over a video file bitmap starttime property (found in "Time" rollout of the Material editor).
That property is not animatable directly in Max 6 , so I wrote a tiny script that manages what I want to achieve, but only at viewport level.

meditMaterials[1].diffuseMap.starttime = 9f
meditMaterials[1].diffuseMap.playBackRate = 2
meditMaterials[1].diffuseMap.endCondition = 0 --0:Loop, 2:Ping Pong, 3:Hold
MaggieQue is offline   Reply With Quote
Old 08-05-2007, 10:29 PM   #6
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
u could try this little funny script:

Code:
s = sphere()
for i = 0 to 100 do
(
sliderTime  = i
s.radius = currentTime
)
The slide bar will move by itself. But after execute, when u scroll the timeline the radius remain unchange.


And I learnt this from maxscript reference file:

Code:
s = Sphere()
s.radius.controller = Float_Script()
s.radius.controller.script = "currentTime"
Assign controller to the sphere radius, when u scroll the timeline, radius change interactively.


Correct me if I'm wrong.

Last edited by MaggieQue; 09-05-2007 at 11:29 AM..
MaggieQue 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 09:07 AM.


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