Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
OneShot

Ancora Flashlight

Recommended Posts

Ciao gente,

prendendo spunto da uno scriptino visto sul forum NL,ecco la mia versione del generatore di "Camera con Flash".

Il test:

Yasff.jpg

Lo script:

global proc yasff() { 



window YetAnotherScript4FlashLight;

string $form = `formLayout`;

string $b0 = `checkBox -label "Activate" swF`;

string $b1 = `text -label  "Flash Power"`;

string $b2 = `intField -minValue 0 -maxValue 100000 -value 0 FP`;

string $b3 = `text -label  "Camera Scale"`;

string $b4 = `intField -minValue 0 -maxValue 100000 -value 1 CS`;

string $b5 = `button -label "create"  `;

string $b6 = `button -label "cancel"  `;


formLayout -edit

         


    -attachForm            $b1 "top"    15

    -attachForm            $b1 "left"   15


    -attachOppositeControl $b2 "top"    0 $b1

    -attachControl         $b2 "left"   15 $b1

    -attachNone            $b2 "right"

    -attachNone            $b2 "bottom"


    -attachOppositeControl $b0 "top"    0 $b1

    -attachControl         $b0 "left"   5 $b2

    -attachNone            $b0 "right"

    -attachNone            $b0 "bottom"


    -attachControl         $b3 "top"    10 $b1

    -attachOppositeControl $b3 "left"   0 $b1

    -attachNone            $b3 "right"

    -attachNone            $b3 "bottom"


    -attachOppositeControl $b4 "top"    0 $b3

    -attachControl         $b4 "left"   5 $b3

    -attachNone            $b4 "right"

    -attachNone            $b4 "bottom"


    -attachControl         $b5 "top"    10 $b3

    -attachOppositeControl $b5 "left"   0  $b3

    -attachOppositeControl $b5 "right"  0  $b3

    -attachNone            $b5 "bottom"

    

    -attachOppositeControl $b6 "top"    0 $b5

    -attachOppositeControl $b6 "left"   0 $b4

    -attachOppositeControl $b6 "right"  0 $b4 

    -attachNone            $b6 "bottom"


    


    $form;

showWindow YetAnotherScript4FlashLight;


button -edit -command ("createCam()") $b5; 


button -edit -command ("deleteUI -window " + "YetAnotherScript4FlashLight") $b6;



};


global proc createCam()

{

polyCube -name pCubeF -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1;

scale -r 2.979993 1 1;

select -r pCubeF.f[0];

polyExtrudeFacet -ch 1 -kft 1 -pvx 0 -pvy 0 -pvz 0.5 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0 -divisions 1 -twist         0 -taper 1 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0 -gx 0 -gy -1    -gz 0      -att 0 -mx 0 -my 0 -mz 0 pCubeF.f[0];

setAttr "polyExtrudeFace1.localScale" -type double3 0.432426 1 1;

setAttr "polyExtrudeFace1.localScale" -type double3 0.432426 0.304011 1;

setAttr "polyExtrudeFace1.localTranslate" -type double3 0 0 -0.514562;

ExtrudeFace;

select -r pCubeF.f[0];

polyExtrudeFacet -ch 1 -kft 1 -pvx 0 -pvy 0 -pvz -0.01456212997 -tx 0 -ty 0 -tz 0 -rx 0 -ry 0 -rz 0 -sx 1 -sy 1 -sz 1 -ran 0         -divisions 1 -twist 0 -taper 1 -off 0 -ltz 0 -ws 0 -ltx 0 -lty 0 -lrx 0 -lry 0 -lrz 0 -lsx 1 -lsy 1 -lsz 1 -ldx 1 -ldy 0 -ldz 0 -w 0         -gx 0 -gy -1 -gz 0 -att 0 -mx 0 -my 0 -mz 0 pCubeF.f[0];

setAttr "polyExtrudeFace2.localScale" -type double3 1 1 0.915206;

setAttr "polyExtrudeFace2.localTranslate" -type double3 0 0 -0.126197;

setAttr "polyExtrudeFace2.localScale" -type double3 0.616667 0.616667 0.564377;

polyCylinder -r 1 -h 2 -sx 20 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1;

scale -r 0.0527694 0.0527694 0.0527694;

rotate -r -os 0 0 44.565829;

setAttr "pCylinder1.rotateZ" 90;

scale -r 1 6.275211 1;

scale -r 1 1.357056 1;

scale -r 1 1.417102 1;

move -r 0 0 -0.0794799;

//FlashMat  //

   

   string $FlashMat=`shadingNode -asShader MXEmitter`; 

   sets -renderable true -noSurfaceShader true -empty -name ($FlashMat+"SG"); 

   connectAttr -f ($FlashMat+".outColor") ($FlashMat+"SG.surfaceShader"); 

   setAttr ($FlashMat+".intensity", 0); 

   select -r pCylinder1; 

   sets -e -forceElement ($FlashMat+"SG"); 


//MirrorMat //


string $MirrorMat=`shadingNode -asShader MXMetal`; 

sets -renderable true -noSurfaceShader true -empty -name ($MirrorMat+"SG"); 

connectAttr -f ($MirrorMat+".outColor") ($MirrorMat+"SG.surfaceShader"); 


select -r pCubeF.f[9];

select -tgl pCubeF.f[6];

select -tgl pCubeF.f[7];

select -tgl pCubeF.f[11];

select -tgl pCubeF.f[8];

select -tgl pCubeF.f[13];

select -tgl pCubeF.f[0];

select -tgl pCubeF.f[10];

select -tgl pCubeF.f[12];

sets -e -forceElement ($MirrorMat+"SG");


select -r pCylinder1;

select -r pCubeF pCylinder1;

group; xform -os -piv 0 0 0;

rename "group1" "flash";



setAttr "flash.rotateY" 180;

setAttr "flash.scaleX" .05;

setAttr "flash.scaleY" .05;

setAttr "flash.scaleZ" .05;


//Cam + Assign


string $MXcam=`maxwellCamera 1`;

string $MXcam_s=startString($MXcam, 6)+"Shape"+endString($MXcam, 1);


string $Flash=("Flash"+endString($MXcam, 1));

addAttr -ln FlashPower -at double  -min 0 -dv `intField  -query -value FP` ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s); 

setAttr -e -keyable true ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s+".FlashPower");    

addAttr -ln Flash -at bool  ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s); 

setAttr -e -keyable true ($MXcam+"_group|"+$MXcam+"|"+$MXcam_s+".Flash");


//Expr


expression -s ("if ("+$MXcam_s+".Flash==1) {"+$FlashMat+".intensity="+$MXcam_s+".FlashPower;} else    {"+$FlashMat+".intensity=0;};")      -o $FlashMat -ae 1 -uc all;


if (`checkBox -query -value swF`) { setAttr($MXcam_s+".Flash") on;}

else

{setAttr($MXcam_s+".Flash") off;};


//

select -r flash;

move -r 0 0.424419 0;

move -r 0.147116 0 0;


select -r flash;

select -add camera1;

parent;


//scale

setAttr($MXcam+"_group.scale",`intField  -query -value CS`,`intField  -query -value CS`,`intField  -query -value CS`);


deleteUI YetAnotherScript4FlashLight;

};

L'oggetto Flash creato e linkato alla camera:

yasf_1.jpg

L'interfaccia e i nuovi attributi della camera:

yasf_2.jpg

Non fate caso alla "poca eleganza" del codice ma l'ho scritto in fretta ed è ancora beta (eheh come maxwell :P ).

Ciao

Share this post


Link to post
Share on other sites

ehm.....

Scusa OneShot...

Preso dalla fobia di questa cosa, ho fatto copia incolla.....Ma a me non funziona, o + probabilmente non riesco a farlo funzionare.... Sai dirmi dove sbaglio?

io non uso Maya da parecchio.... ho la versione 6, sicuramente ceffo in qualche cosa che proprio ignoro! :)

Grazie!

Ciao!

Share this post


Link to post
Share on other sites

Grazie Luca & dagon :P

@dedandy:

Copia lo script in un file di testo e rinaminalo in yasff.mel,poi mettilo nella cartella degli script. (es:C:\Documents and Settings\Utente\Documenti\maya\6.0\scripts).

Lancia maya e nella command line scrivi "yasff" + invio.

Ciao

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...