1 #using scripts\codescripts\struct;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\filter_shared;
5 #using scripts\shared\math_shared;
6 #using scripts\shared\system_shared;
7 #using scripts\shared\util_shared;
9 #insert scripts\shared\shared.gsh;
16 function SetStage( localClientNum, bundle, filterid, stagePrefix, stageLength, accumTime, totalAccumTime, setConstants )
19 for ( constIdx = 0 ; constIdx < num_consts ; constIdx++ )
21 constPrefix = stagePrefix +
"c";
22 if ( constIdx < 10 ) constPrefix +=
"0";
23 constPrefix += constIdx +
"_";
29 channels = GetStructField( bundle, constPrefix +
"channels" );
30 isColor = IsString( channels ) && ( channels ==
"color" || channels ==
"color+alpha" );
32 animName = GetStructField( bundle, constPrefix +
"anm" );
35 for ( i=0 ; i<4 ; i++ )
39 for ( chanIdx = 0 ; chanIdx < startValue.size ; chanIdx++ )
41 delayTime = delays[ ( isColor ? 0 : chanIdx ) ] * 1000;
43 if ( accumTime > delayTime && stageLength > delayTime )
45 timeRatio = ( accumTime - delayTime ) / ( stageLength - delayTime );
49 delta = endValue[ chanIdx ] - startValue[ chanIdx ];
54 lerpRatio = timeRatio;
63 lerpRatio = timeRatio * timeRatio;
68 lerpRatio = -timeRatio * ( timeRatio - 2 );
76 lerpRatio = 0.5 * lerpRatio * lerpRatio;
81 lerpRatio = -0.5 * ( lerpRatio * ( lerpRatio - 2 ) - 1 );
86 lerpRatio = timeRatio;
90 if ( timeRatio > 0.5 )
91 lerpRatio = 1.0 - timeRatio;
93 lerpRatio = timeRatio;
97 lerpRatio = 0.5 - 0.5*cos( 360.0 * timeRatio );
106 values[ chanIdx ] = startValue[ chanIdx ] + lerpRatio * delta;
110 values[ chanIdx ] = startValue[ chanIdx ];
114 [[ setConstants ]]( localClientNum, GetStructField( bundle, constPrefix +
"name" ), filterid, values );
122 stageConstants[0] = totalAccumTime;
123 stageConstants[1] = accumTime;
124 stageConstants[2] = stageLength;
125 stageConstants[3] = 0;
127 [[ setConstants ]]( localClientNum,
"scriptvector7", filterid, stageConstants );
133 channels = GetStructField( bundle, constPrefix +
"channels" );
136 if (
delay && IsString( channels ) && ( channels ==
"color" || channels ==
"color+alpha" ) )
189 ret = GetStructField( bundle, field );
190 if ( !isdefined( ret ) )
200 switch ( codeConstName )
202 case "scriptvector0":
return 0;
203 case "scriptvector1":
return 4;
204 case "scriptvector2":
return 8;
205 case "scriptvector3":
return 12;
206 case "scriptvector4":
return 16;
207 case "scriptvector5":
return 20;
208 case "scriptvector6":
return 24;
209 case "scriptvector7":
return 28;