IntersectRay with scale animation

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 08 August 2013   #1
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 August 2013 at 07:59 PM.
 
Old 08 August 2013   #2
do you want to use intersectRay with a script controller?
 
Old 08 August 2013   #3
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 August 2013   #4
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 August 2013   #5
the intersectRay is too slow for using in script controllers.
 
Old 08 August 2013   #6
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 August 2013 at 12:52 AM.
 
Old 08 August 2013   #7
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 August 2013   #8
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 August 2013   #9
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.
 
Thread Closed share thread



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 11:49 PM.


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