CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 08-22-2013, 05:59 PM   #1
BebeteLANUITE
The Crazy Creative Mind
 
BebeteLANUITE's Avatar
portfolio
Bruno ISANA
2D/3D designer and animator
Belgium
 
Join Date: Jun 2002
Posts: 384
Send a message via MSN to BebeteLANUITE
IntersectRay with scale animation

Hello maxscript guys and girls,

I need your help.
I'am trying to do a simple scale_script to interactively make a bunch of cubes scale up when a plane pass in front of them. My actual script make the cubes pop up from scale 0 % to 100 % but i want them to gradually scale up or down during 10 frames.

In fact, the cubes launch a ray and intersectRay see if the ray hit the plane surface. I want when the ray hit the plane the cube grows up by 10% per frame to 100 % and when the ray stops to hit the plane the cube gradually grows down by 10% per frame to 0%.

This is my actual script :
Code:
DependsOn $Plane001 varRay = intersectRay $Plane001 (ray $Box001.pos [0,-1,0]) if varRay != undefined then return [0,0,0] else return [1,1,1]


Do you have an idea to do this kind of effect ?
Thank you for your help.

Last edited by BebeteLANUITE : 08-22-2013 at 07:59 PM.
 
Old 08-22-2013, 10:48 PM   #2
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
do you want to use intersectRay with a script controller?
 
Old 08-22-2013, 11:27 PM   #3
BebeteLANUITE
The Crazy Creative Mind
 
BebeteLANUITE's Avatar
portfolio
Bruno ISANA
2D/3D designer and animator
Belgium
 
Join Date: Jun 2002
Posts: 384
Send a message via MSN to BebeteLANUITE
Hello DenisT,

Yes, i put the script in the scale controller script of each cube.
The cubes are stacked to form a matrix or a kind of brick wall.
 
Old 08-23-2013, 12:03 AM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
what's the bigger problem? to make the scale fading-in/out or make the using of intersectRay fast enough to be used?
 
Old 08-23-2013, 12:09 AM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
the intersectRay is too slow for using in script controllers.
 
Old 08-23-2013, 12:46 AM   #6
BebeteLANUITE
The Crazy Creative Mind
 
BebeteLANUITE's Avatar
portfolio
Bruno ISANA
2D/3D designer and animator
Belgium
 
Join Date: Jun 2002
Posts: 384
Send a message via MSN to BebeteLANUITE
In fact, i have only 97 cubes and the reactivity of the intersectRay is fast enough for me by now.
My bigger problem is to make the cubes scale up by 10% step to 100% when the ray hits the plane and make the cubes scale down by 10% to 0% when the ray doesn't hit the plane.

These are the steps, i guess, for the script :
- the ray of the cube N hit the plane
- instead of poping from 0 to 100%, the cube scale up from 0 to 100% by 10 % steps (10 frames)
- the plane moves and the ray doesn't hit it no more.
- the cube N scale down to 0 by 10 % steps (10 frames)

Do you have an idea to do it ?

Last edited by BebeteLANUITE : 08-23-2013 at 12:52 AM.
 
Old 08-23-2013, 01:22 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,328
Send a message via ICQ to denisT
i will show below how to make an animated fading of a value using custom attribute...
Code:
global FadeAttr = attributes FadeAttr ( parameters params rollout:params ( fade type:#integer default:1 ui:ui_fade range type:#floatTab tabsize:3 ui:(ui_lower_limit,ui_upper_limit,ui_value_scale) time type:#time animatable:off value type:#float animatable:off ) rollout params "Fade Parameters" ( group "Fade: " ( radiobuttons ui_fade labels:#("In", "None", "Out") align:#left offset:[10,0] ) group "Value: " ( spinner ui_lower_limit "Min: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#right offset:[0,-2] spinner ui_upper_limit "Max: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#right offset:[0,0] spinner ui_value_scale "Scale: " range:[-1e9,1e9,0] type:#float fieldwidth:54 align:#right offset:[0,0] ) ) ) ( delete objects b = box name:"b" height:0 isselected:on s = b.height.controller = Float_Script() attr = createinstance FadeAttr range:#(10,100,10) append b.baseobject.custattributes attr s.addobject "fade" attr ss = "" ss += "v = fade.value + (f - fade.time)*fade.range[3]*((2 - fade.fade) as integer);\n" ss += "v = amax fade.range[1] (amin fade.range[2] v)\n" ss += "if fade.value != v do fade.value = v\n" ss += "if fade.time != f do fade.time = f\n" ss += "v" s.setexpression ss f = attr.fade.controller = Bezier_Float() k = addnewkey f 0f k.value = 1 -- in k = addnewkey f 15f k.value = 2 -- none k = addnewkey f 30f k.value = 2 -- none k = addnewkey f 35f k.value = 3 -- out f.keys.outTangentType = f.keys.inTangentType = #step ok )

i add the attribute to the object just to demonstrate how the setup works. technically it can be added to a controller to be invisible for user.
also to make your life not too easy i'm not showing how to make the TRUE backward playback try to solve it yourself.
 
Old 08-23-2013, 09:28 PM   #8
BebeteLANUITE
The Crazy Creative Mind
 
BebeteLANUITE's Avatar
portfolio
Bruno ISANA
2D/3D designer and animator
Belgium
 
Join Date: Jun 2002
Posts: 384
Send a message via MSN to BebeteLANUITE
Hello DenisT,

Thank you a lot for your help.
Your script works very well.

I will analyse it to understand the way you make it and adapt it for my purpose.
I'am not a great maxscript coder but i learn every day.

Thank you very much.
Cheers.
 
Old 08-23-2013, 09:28 PM   #9
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:48 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.