You are here: Home / CG Master class / Class_02 / mel_02

mel_02

How to create nurbs controller.

Maya uses Shading Groups to control the association of objects and materials. Shading Groups are created as a "renderable" set. For example:

// Create a Shading Group
//
sets -renderable true -noSurfaceShader true -empty -name "myShadingGroup";

Logically then, a Shading Group's membership is controlled like other Maya sets - via the "sets" command.

To assign an object or a face component to a material, you simply add that object to the Shading Group which controls membership for that material. If you attempt at assign objects to the material instead, Maya will politely inform you that a material node is not a set:

// Error: The argument provided is NOT a set //

Note that Shading Group assignments are mutually exclusive - you cannot assign an object to more than one Shading Group. If an object is already a member of one Shading Group when you attempt to assign it to another, then Maya will issue an error:

sets -add blinn1SG pSphere1;
// Error: Cannot add the following items to the set since they would break the
          exclusivity constraint //

To instruct Maya that you know what you're doing and, yes, you do want to re-assign your object to a new Shading Group, specify the '-forceElement' flag with the sets command. You'll commonly see this flag by its short form: '-fe'.

sets -forceElement blinn1SG pSphere1;
// Result: blinn1SG //

The same method is used for assigning individual face components to Shading Groups:

// Assign face 0 to a blinn shader.
//
sets -fe blinn1SG pSphere1.f[0];
// Result: blinn1SG //

// Assign faces 7-11 to a phongE shader.
//
sets -fe phongE1SG pSphere1.f[7:11];
// Result: phongE1SG //

 

//make roll

makeRoll objName radius cube(blean) ty;

// one side arrow

 

createDisplayLayer -name "Ground" -number 1 -empty;

select -r C_ground_GEO ;

editDisplayLayerMembers -noRecurse Ground `ls -selection`;

 

createDisplayLayer -name "rail_GRP" -number 1 -empty;

select -r C_rail_GRP ;

editDisplayLayerMembers -noRecurse Ground `ls -selection`;

 

 

//

string $cntName = "C_local_CNT";

string $oneSideArrows = `curve -d 1 -p 1 0 -1 -p 2 0 -1 -p 0 0 -3 -p -2 0 -1 -p -1 0 -1 -p -1 0 1 -p -2 0 1 -p 0 0 3 -p 2 0 1 -p 1 0 1 -p 1 0 -1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10`;

string $changedName = `rename $oneSideArrows $cntName`;

setAttr ($changedName + "Shape.overrideEnabled") 1;

setAttr ($changedName + "Shape.overrideColor") 17;

 

string $cntName = "C_local_CNT";

string $oneSideArrows = `curve -d 1 -p 1 0 -1 -p 1 0 -3 -p 2 0 -3 -p 0 0 -5 -p -2 0 -3 -p -1 0 -3 -p -1 0 -1 -p -3 0 -1 -p -3 0 -2 -p -5 0 0 -p -3 0 2 -p -3 0 1 -p -1 0 1 -p -1 0 3 -p -2 0 3 -p 0 0 5 -p 2 0 3 -p 1 0 3 -p 1 0 1 -p 3 0 1 -p 3 0 2 -p 5 0 0 -p 3 0 -2 -p 3 0 -1 -p 1 0 -1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24`;

string $changedName = `rename $oneSideArrows $cntName`;

setAttr ($changedName + "Shape.overrideEnabled") 1;

setAttr ($changedName + "Shape.overrideColor") 17;

 

 

//yellow

 

setAttr "twosidearrowShape.overrideEnabled" 1;

 

setAttr twosidearrowShape.overrideColor 17;

 

//red

 

setAttr curveShape2.overrideColor 13;

 

//blue

 

setAttr curveShape2.overrideColor 6;

 

 

 

//add attribute

 

addAttr -ln "boom"  -at double  -min 0 -max 10 -dv 0 |Master|RIG|C_local_CNT;

 

setAttr -e-keyable true |Master|RIG|C_local_CNT.boom;

 

addAttr -ln "rot"  -at double  -min 0 -max 360 -dv 0 |Master|RIG|C_local_CNT;

 

setAttr -e-keyable true |Master|RIG|C_local_CNT.rot;

 

addAttr -ln "dolly"  -at double  -min -10 -max 10 -dv 0 |Master|RIG|C_local_CNT;

 

setAttr -e-keyable true |Master|RIG|C_local_CNT.dolly;

 

 

 

//show in the channel box

 

setAttr -e-keyable true |Master|RIG|twosidearrow.boom;

 

//hide in the channel box

 

setAttr -e-keyable false |Master|RIG|twosidearrow.boom;

 

 

 

//set driven key

 

setAttr "C_local_CNT.boom" 0;

 

setAttr "C_boomCam_GEO.rotateX" 0;

 

setDrivenKeyframe -currentDriver C_local_CNT.boom C_boomCam_GEO.rotateX;

 

 

 

// Result: 1 //

 

setAttr "C_local_CNT.boom" 10;

 

setAttr "C_boomCam_GEO.rotateX" -20;

 

setDrivenKeyframe -currentDriver C_local_CNT.boom C_boomCam_GEO.rotateX;

 

 

 

// set driven key on Rot

 

setAttr "C_local_CNT.rot" 0;

 

setAttr "C_bodyRot_GEO.rotateY" 0;

 

setDrivenKeyframe -currentDriver C_local_CNT.rot C_bodyRot_GEO.rotateY;

 

 

 

setAttr "C_local_CNT.rot" 360;

 

setAttr "C_bodyRot_GEO.rotateY" 360;

 

setDrivenKeyframe -currentDriver C_local_CNT.rot C_bodyRot_GEO.rotateY;

 

 

 

//set driven key on dolly

 

setAttr "C_local_CNT.dolly" 0;

 

setAttr "C_dollyCam_GEO.translateZ" 0;

 

setDrivenKeyframe -currentDriver C_local_CNT.dolly C_dollyCam_GEO.translateZ;

 

 

 

//set driven key on Rot

 

setAttr "C_local_CNT.dolly" -10;

 

setAttr "C_dollyCam_GEO.translateZ" -12;

 

setDrivenKeyframe -currentDriver C_local_CNT.dolly C_dollyCam_GEO.translateZ;

 

 

 

//set driven key on Rot

 

setAttr "C_local_CNT.dolly" 10;

 

setAttr "C_dollyCam_GEO.translateZ" 12;

 

setDrivenKeyframe -currentDriver C_local_CNT.dolly C_dollyCam_GEO.translateZ;

 

// creat parent constraint

 

parentConstraint  -mo -weight 1  "C_global_CNT" "C_camera_GRP" ;

 

parentConstraint  -mo -weight 1  "C_local_CNT" "C_dolly_GEO" ;

OpenID Login