- Mon May 02, 2005 9:14 am
#20870
Hi there!
...when i was playing with those flash lights mentioned by others on these forum i noticed that in maya flashlight should have a deflector on the back to make it more realistic.
So... i made a script for all You guys that does:
1. check if maxwell plug is loaded and if not loads it
2. creates a new maxwellcamera
3. creates a flashlight with emitter mat on flashlamp and diffuse mat on deflector
4.groups it and parents it to the maxwellcamera
5.finally switches to this newly created camera
6.in camerashape there are controls for turning flash on/off and for setiing flash intensity
just copy code to notepad and save as "flashCam.mel" in your maya scripts folder (c:\documents and settings\USERNAME\My Documents\maya\scripts), reload maya and in cmdline of maya write "flashCam;"
in case you need to specify another version of maya just edit the 2nd and 3rd line of the code exchanging mayall_maya65 into whatever version u like(mayall_maya60) but...
it was tesed on maya65

...when i was playing with those flash lights mentioned by others on these forum i noticed that in maya flashlight should have a deflector on the back to make it more realistic.
So... i made a script for all You guys that does:
1. check if maxwell plug is loaded and if not loads it
2. creates a new maxwellcamera
3. creates a flashlight with emitter mat on flashlamp and diffuse mat on deflector
4.groups it and parents it to the maxwellcamera
5.finally switches to this newly created camera
6.in camerashape there are controls for turning flash on/off and for setiing flash intensity
just copy code to notepad and save as "flashCam.mel" in your maya scripts folder (c:\documents and settings\USERNAME\My Documents\maya\scripts), reload maya and in cmdline of maya write "flashCam;"
in case you need to specify another version of maya just edit the 2nd and 3rd line of the code exchanging mayall_maya65 into whatever version u like(mayall_maya60) but...
it was tesed on maya65

Code: Select all
hope You'll like and and find it usefull global proc flashCam() {
if (`pluginInfo -q -l mayall_maya65`!=1) {
loadPlugin mayall_maya65;
};
//Create Maxwell camera.
string $MXcam=`maxwellCamera 1`;
string $MXcam_s=startString($MXcam, 6)+"Shape"+endString($MXcam, 1);
setAttr($MXcam+".scale", 10,10,10);
//Create Flash lamp and parent to camera
polySphere -n Lamp -r 0.015 -sx 10 -sy 6 -ax 0 1 0 -tx 1 -ch 1;
setAttr "Lamp.tz" .015;
sphere -n Deflector_proxy -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 180 -r 0.05 -d 3 -ut 0 -tol 0.01 -s 4 -nsp 4 -ch 1;
nurbsToPoly -n Deflector -mnd 1 -ch 1 -f 2 -pt 1 -pc 200 -chr 0.1 -ft 0.01 -mel 0.001 -d 0.1 -ut 3 -un 2 -vt 3 -vn 2 -uch 0 -ucr 0 -cht 0.2 -es 0 -ntr 0 -uss 1 "Deflector_proxy";
delete -ch Deflector;
delete Deflector_proxy;
group -n Flash Lamp Deflector;
setAttr "Flash.ty" .1;
parent Flash $MXcam;
//Create 650W emitter
string $MXem=`shadingNode -asShader MXEmitter`;
sets -renderable true -noSurfaceShader true -empty -name ($MXem+"SG");
connectAttr -f ($MXem+".outColor") ($MXem+"SG.surfaceShader");
setAttr ($MXem+".intensity", 650);
//Assign emitter to flash lamp
select -r ($MXcam+"_group|"+$MXcam+"|Flash|Lamp");
sets -e -forceElement ($MXem+"SG");
//Create white deflector material
string $MXdef=`shadingNode -asShader MXDiffuse`;
sets -renderable true -noSurfaceShader true -empty -name ($MXdef+"SG");
connectAttr -f ($MXdef+".outColor") ($MXdef+"SG.surfaceShader");
setAttr ($MXdef+".outColor", 1,1,1);
//Assign deflector material to flash deflector
select -r ($MXcam+"_group|"+$MXcam+"|Flash|Deflector");
sets -e -forceElement ($MXdef+"SG");
//Create Flash control in camerashapeX for turning on/off flash (located in camerShapeX/Extra Attributes)
addAttr -ln FlashIntensity -at double -min 0 -dv 650 ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s);
setAttr -e -keyable true ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s+".FlashIntensity");
addAttr -ln Flash -at bool ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s);
setAttr -e -keyable true ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s+".Flash");
expression -s ("if ("+$MXcam_s+".Flash==1) {"+$MXem+".intensity="+$MXcam_s+".FlashIntensity;} else {"+$MXem+".intensity=0;};") -o $MXem -ae 1 -uc all;
//Look thru created camera
lookThroughModelPanel $MXcam_s modelPanel4;
select $MXcam;
warning "Camera with flashlight successfully created!";
};

Last edited by gutaker on Mon May 02, 2005 12:37 pm, edited 1 time in total.