Toy Radio

(Requires Specific Model)

Script:

//Author: Kim Czerniewski
//Date: 11/14/17
//Purpose: Create a GUI of the radio from Project 3
//Coding Language: Maya Embedded Language

$p4= `window -title “Radio Controls” -wh 410 505`;
columnLayout -adjustableColumn true -bgc 1 .68 .78;

//__GUI_functions__//

//_2 RowColumn spacers_//
proc fnc_spacer(){
separator -h 10 ;
separator -h 10 ;
}

//_______________________________________________________________________________________//

//____________Project 3 Code_________________//

/////_______Material Creation________/////

if (`objExists bg_shader`){
print “bg_shader is here”;
} else {
shadingNode -asShader aiStandard -name “bg_shader”;
sets -renderable true -noSurfaceShader true -empty -name “bg_shaderSG”;
connectAttr -f bg_shader.outColor bg_shaderSG.surfaceShader;

shadingNode -asTexture ramp -n “bg_ramp”;
shadingNode -asUtility place2dTexture -n “bg_ramp_placement”;
connectAttr “bg_ramp_placement.outUV” “bg_ramp.uv”;
connectAttr “bg_ramp_placement.outUvFilterSize” “bg_ramp.uvFilterSize”;
setAttr “bg_ramp.type” 1;
setAttr “bg_ramp.colorEntryList[0].color” -type double3 1 0.294 0.3961 ;
setAttr “bg_ramp.colorEntryList[1].color” -type double3 0.2723 0.048 0.0948 ;

connectAttr bg_ramp.outColor bg_shader.color;

setAttr “bg_shader.Kd” .7;
setAttr “bg_shader.Ks” .3;
setAttr “bg_shader.specularRoughness” 0.4;

select -r pPlane1 ;
sets -e -forceElement bg_shaderSG;
}

if (`objExists bar_shader`){
print “bar_shader is here”;
}else{
shadingNode -asShader aiStandard -name “bar_shader”;
sets -renderable true -noSurfaceShader true -empty -name “bar_shaderSG”;
connectAttr -f bar_shader.outColor bar_shaderSG.surfaceShader;
setAttr “bar_shader.color” -type double3 0 0 0;
setAttr “bar_shader.Kd” .7;
setAttr “bar_shader.Ks” .3;
setAttr “bar_shader.specularRoughness” 0.2;

}

//_____Controller_____//

if (`objExists controller`){
select “controller”;
delete;
}

spaceLocator -n “controller”;

addAttr -ln “Heart_light_controls” “controller”;
addAttr -ln “Heart_light_control” -minValue 0 -maxValue 1 -defaultValue 0 -keyable true “controller”;

addAttr -ln “front_bar_color_controls” “controller”;
addAttr -ln “front_bar_color_R” -minValue 0 -maxValue 1 -defaultValue .8 -keyable true “controller”;
addAttr -ln “front_bar_color_G” -minValue 0 -maxValue 1 -defaultValue .8 -keyable true “controller”;
addAttr -ln “front_bar_color_B” -minValue 0 -maxValue 1 -defaultValue .8 -keyable true “controller”;

addAttr -ln “front_bar_animation_controls” “controller”;
addAttr -ln “front_bar_frequency” -minValue 0 -maxValue 30 -defaultValue 3 -keyable true “controller”;
addAttr -ln “front_bar_height” -minValue 0 -maxValue 14 -defaultValue 10 -keyable true “controller”;
addAttr -ln “front_bar_amplitude” -minValue 0 -maxValue 10 -defaultValue 5 -keyable true “controller”;

addAttr -ln “front_background_controls” “controller”;
addAttr -ln “front_bg_light” -minValue 0 -maxValue 1 -defaultValue 0 -keyable true “controller”;
addAttr -ln “front_bg_dark” -minValue 0 -maxValue 1 -defaultValue 1 -keyable true “controller”;

addAttr -ln “Radio_Squash_n_Stretch_controls” “controller”;
addAttr -ln “Squash_and_Stretch_strength” -minValue 0 -maxValue 1 -defaultValue .2 -keyable true “controller”;
addAttr -ln “Squash_and_Stretch_height” -minValue 0 -maxValue 1 -defaultValue 1 -keyable true “controller”;
addAttr -ln “Squash_and_Stretch_frequency” -minValue 0 -maxValue 30 -defaultValue 15 -keyable true “controller”;

/*proc $fnc_radio (float $h_lgt,
float $d_bg,
float $l_bg,
float $waveR,
float $waveG,
float $waveB,
float $waveFreq,
float $waveAmp,
float $waveHeight,
float $squashFreq,
float $squashAmp,
float $squashHeight,
float $noiseMix){
*/
proc fnc_radio(){
/////_____Connect_dial_Heart_Light_____/////~~~~~~~~~~~WORKING~~~~~~~~~~~~

string $R_sliderControl= “power_dial.ry = controller.Heart_light_control*(360)”;
expression -string $R_sliderControl -o power_dial -ae 1;
string $R_colorControl= “light_power_heartShape.intensity = controller.Heart_light_control”;
expression -string $R_colorControl -o power_dial -ae 1;

/////_____BG_color_key_connection_____/////~~~~~~~~~~~~WORKING~~~~~~~~~~~~

string $R_sliderControl= “bg_light_color_dial.rz = controller.front_bg_light*(-1*150)”;
expression -string $R_sliderControl -o bg_light_color_dial -ae 1;
string $R_colorControl= “bg_ramp.colorEntryList[0].position = controller.front_bg_light”;
expression -string $R_colorControl -o pPlane1 -ae 1;

string $R_sliderControl= “bg_dark_color_dial.rz = controller.front_bg_dark*150”;
expression -string $R_sliderControl -o color_slider1 -ae 1;
string $R_colorControl= “bg_ramp.colorEntryList[1].position = controller.front_bg_dark”;
expression -string $R_colorControl -o color_slider1 -ae 1;

/////_____Key_Connection_Bar_Colors_____/////~~~~~~~~~~~~WORKING~~~~~~~~~~~~~~~~~

string $R_sliderControl= “color_slider1.tz = controller.front_bar_color_R*(-1*5)”;
expression -string $R_sliderControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.emissionColorR = controller.front_bar_color_R”;
expression -string $R_colorControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.colorR = controller.front_bar_color_R”;
expression -string $R_colorControl -o color_slider1 -ae 1;

string $R_sliderControl= “color_slider2.tz = controller.front_bar_color_G*(-1*5)”;
expression -string $R_sliderControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.emissionColorG = controller.front_bar_color_G”;
expression -string $R_colorControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.colorG = controller.front_bar_color_G”;
expression -string $R_colorControl -o color_slider1 -ae 1;

string $R_sliderControl= “color_slider.tz = controller.front_bar_color_B*(-1*5)”;
expression -string $R_sliderControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.emissionColorB = controller.front_bar_color_B”;
expression -string $R_colorControl -o color_slider1 -ae 1;
string $R_colorControl= “bar_shader.colorB = controller.front_bar_color_B”;
expression -string $R_colorControl -o color_slider1 -ae 1;

string $R_colorControl= “bar_shader.emission = controller.Heart_light_control*(.75)”;

/////_____Front_Bars_sin_Wave_____/////~~~~~~~WORKING~~~~~~~~~~~
if (`objExists anim_bar48`){
print “all front bars in place”;
}else{
string $bars[]={};
for ($i=0; $i<=48; $i++){
$this_bar= `polyCube -h .3 -w.2 -d .2 -n “anim_bar”`;
move 3.64 1.38 6.49;
move 3.636 1.23 6.49 ($this_bar[0]+”.scalePivot”) ($this_bar[0]+”.rotatePivot”);
move -r 0 0 (-.2775*$i);

select ($this_bar[0]+”.f[4]”);
scale -r -os 1 .9 .7;

setAttr ($this_bar[0] + “.sy”) ($i*3);
string $attr = $this_bar[0]+ “.sy”;
string $exp_barY = $this_bar[0]+”.sy = (sin(time+”+$i+”*controller.front_bar_frequency)*controller.front_bar_amplitude+controller.front_bar_height)”;
$myExpr = `expression -s $exp_barY -o ($this_bar[0] + “.sy”) -ae 1`;

$bars[$i]=$this_bar[0];
}
select $bars;
sets -e -forceElement bar_shaderSG;
group -n “expression_anim_bars”;
}

/////_____Squash_and_Stretch_____/////~~~~~~~IN PROGRESS~~~~~~~~~~~
select -all;
select -d “controller” “key_light_1” “key_light_2” “fill_light_diffuse” “fill_light_spec” “fill_light_dome” “shotCam_heart_light” “shotCam_color_sliders” “shotCam_Radio”;
group -n “Radio”;
move 0 0 0 Radio.scalePivot Radio.rotatePivot ;

string $squash_n_stretch = “Radio.sy = cos(time*controller.Squash_and_Stretch_frequency)*controller.Squash_and_Stretch_strength+controller.Squash_and_Stretch_height”;
expression -string $squash_n_stretch -o Radio -ae 1;

string $squash_n_stretch = “Radio.sz = (1-cos(time*controller.Squash_and_Stretch_frequency)*controller.Squash_and_Stretch_strength+controller.Squash_and_Stretch_height)*.5”;
expression -string $squash_n_stretch -o Radio -ae 1;
}

/////_____GUI Development_____/////

///___Controller contected___///

button -label “Make Connections and Create Front Bars” -h 50 -command “fnc_radio ()” -bgc 1 .48 .68;

attrFieldSliderGrp -adj true -bgc 1 .78 .88 -h 30 -min 0 -max 1 -at “controller.Heart_light_control”;

setParent ..;
frameLayout -label “Background Gradiant” -collapsable true -collapse true -bgc .9 .38 .58;
attrFieldSliderGrp -adj true -min 0 -max 1 -bgc 1 0.294 0.3961 -at “controller.front_bg_light”;
attrFieldSliderGrp -adj true -min 0 -max 1 -bgc 0.2723 0.048 0.0948 -at “controller.front_bg_dark”;

setParent ..;
frameLayout -label “Animated Bar Color” -collapsable true -collapse true -bgc .9 .38 .58;

attrFieldSliderGrp -adj true -min 0 -max 1 -bgc 1 .4 .4 -at “controller.front_bar_color_R”;
separator -h 1 ;
attrFieldSliderGrp -adj true -min 0 -max 1 -bgc .4 1 .4 -at “controller.front_bar_color_G”;
separator -h 1 ;
attrFieldSliderGrp -adj true -min 0 -max 1 -bgc .4 .4 1 -at “controller.front_bar_color_B”;

setParent .. ;
frameLayout -label “Animated Bar Wave Behavior” -collapsable true -collapse true -bgc .9 .38 .58;

attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 30 -at “controller.front_bar_frequency”;
attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 14 -at “controller.front_bar_height”;
attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 10 -at “controller.front_bar_amplitude”;

setParent .. ;
frameLayout -label “Radio Squash and Streach Behavior” -collapsable true -collapse true -bgc .9 .38 .58;

attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 1 -at “controller.Squash_and_Stretch_strength”;
attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 1 -at “controller.Squash_and_Stretch_height”;
attrFieldSliderGrp -adj true -bgc 1 .78 .88 -min 0 -max 30 -at “controller.Squash_and_Stretch_frequency”;

setParent .. ;
separator -h 10 ;
button -label “close” -h 30 -command “deleteUI -window $p4” -bgc 1 .48 .68;

showWindow;