home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2000 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Nov. 18, 1997
- //
- //
- // Description:
- // Given a selected surface that has nurbs primitive as its immediate
- // creator, cap it with a degenerate surface.
- //
-
- proc string capDummyCurve( string $parent )
- {
- // Make a default curve and parent it under the surface:
- string $curve = `createNode nurbsCurve -p $parent`;
- setAttr -k off ".v";
- setAttr ".cc" -type "nurbsCurve"
- 1 1 0 no 3
- 2 0 1
- 2
- 0 0 0
- 1 0 0
- ;
- setAttr ".v" false;
- setAttr ".dcv" yes;
- setAttr ".dep" yes;
- setAttr ".dh" yes;
-
- return $curve;
- }
-
- proc string capSurface( string $maker, string $curve, string $parent )
- {
- // Now revolve
- string $revNode = `createNode revolve`;
- setAttr ($revNode + ".ssw") 0.0;
-
- connectAttr ($curve + ".l") ($revNode + ".ic");
- connectAttr ($maker + ".p") ($revNode + ".p");
- connectAttr ($maker + ".ax") ($revNode + ".ax");
-
- expression -s ($revNode + ".esw = " + $maker + ".esw - " + $maker + ".ssw");
- string $cap = `createNode nurbsSurface -p $parent`;
- connectAttr ($revNode + ".os") ($cap + ".cr");
-
- return $cap;
- }
-
- proc string capCone( string $parent, string $shape, string $cone )
- {
- // Make the info node and connect it:
- string $info = `createNode pointOnSurfaceInfo`;
- setAttr ".top" 1;
- setAttr ".u" 0.0;
- setAttr ".v" 0.0;
- connectAttr ($shape + ".local") ($info + ".is");
-
- string $curve = `capDummyCurve $parent`;
-
- // Connect the CVs
- connectAttr ($cone + ".p") ($curve + ".cp[0]");
- connectAttr ($info + ".p") ($curve + ".cp[1]");
-
- string $cap = `capSurface $cone $curve $parent`;
- return $cap;
- }
-
- proc string capCylinder( string $parent, string $shape, string $cylinder )
- {
- // Make the info nodes and connect them:
- string $info1 = `createNode pointOnSurfaceInfo`;
- setAttr ".top" 1;
- setAttr ".u" 0.0;
- setAttr ".v" 0.0;
- connectAttr ($shape + ".local") ($info1 + ".is");
-
- string $info2 = `createNode pointOnSurfaceInfo`;
- setAttr ".top" 1;
- setAttr ".u" 1.0;
- setAttr ".v" 0.0;
- connectAttr ($shape + ".local") ($info2 + ".is");
-
- // Make a default curve:
- string $curve1 = `capDummyCurve $parent`;
-
- // Connect the CVs:
- expression -s ($curve1 + ".cp[0].xv = " + $cylinder + ".px - " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axx");
- expression -s ($curve1 + ".cp[0].yv = " + $cylinder + ".py - " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axy");
- expression -s ($curve1 + ".cp[0].zv = " + $cylinder + ".pz - " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axz");
- connectAttr ($info1 + ".p") ($curve1 + ".cp[1]");
- string $cap1 = `capSurface $cylinder $curve1 $parent`;
-
-
- // Make the second curve:
- string $curve2 = `capDummyCurve $parent`;
-
- // Connect the CVs:
- expression -s ($curve2 + ".cp[0].xv = " + $cylinder + ".px + " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axx");
- expression -s ($curve2 + ".cp[0].yv = " + $cylinder + ".py + " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axy");
- expression -s ($curve2 + ".cp[0].zv = " + $cylinder + ".pz + " + $cylinder +
- ".r * " + $cylinder + ".hr * 0.5 * " + $cylinder + ".axz");
- connectAttr ($info2 + ".p") ($curve2 + ".cp[1]");
- string $cap2 = `capSurface $cylinder $curve2 $parent`;
-
- return ($cap1 + " " + $cap2);
- }
-
- proc string capRevolved( string $parent, string $shape, string $revolve )
- {
- // Make the info nodes and connect them:
- string $info1 = `createNode pointOnSurfaceInfo`;
- setAttr ".top" 1;
- setAttr ".u" 0.0;
- setAttr ".v" 0.0;
- connectAttr ($shape + ".local") ($info1 + ".is");
-
- string $info2 = `createNode pointOnSurfaceInfo`;
- setAttr ".top" 1;
- setAttr ".u" 1.0;
- setAttr ".v" 0.0;
- connectAttr ($shape + ".local") ($info2 + ".is");
-
- // Make a default curve:
- string $curve1 = `capDummyCurve $parent`;
-
- // Connect the CVs:
- expression -s ($curve1 + ".cp[0].xv = (" + $info1 + ".px - " + $revolve +
- ".px) * " + $revolve + ".axx");
- expression -s ($curve1 + ".cp[0].yv = (" + $info1 + ".py - " + $revolve +
- ".py) * " + $revolve + ".axy");
- expression -s ($curve1 + ".cp[0].zv = (" + $info1 + ".pz - " + $revolve +
- ".pz) * " + $revolve + ".axz");
- connectAttr ($info1 + ".p") ($curve1 + ".cp[1]");
- string $cap1 = `capSurface $revolve $curve1 $parent`;
-
-
- // Make the second curve:
- string $curve2 = `capDummyCurve $parent`;
-
- // Connect the CVs:
- expression -s ($curve2 + ".cp[0].xv = (" + $info2 + ".px - " + $revolve +
- ".px) * " + $revolve + ".axx");
- expression -s ($curve2 + ".cp[0].yv = (" + $info2 + ".py - " + $revolve +
- ".py) * " + $revolve + ".axy");
- expression -s ($curve2 + ".cp[0].zv = (" + $info2 + ".pz - " + $revolve +
- ".pz) * " + $revolve + ".axz");
- connectAttr ($info2 + ".p") ($curve2 + ".cp[1]");
- string $cap2 = `capSurface $revolve $curve2 $parent`;
-
- return ($cap1 + " " + $cap2);
- }
-
- global proc capNurbsPrimitive()
- {
- string $objs[] = `ls -sl -type dagNode`;
- string $chain[];
- string $nt, $parent[];
-
- int $n = size($objs);
- int $i;
- for( $i=0; $i<$n; $i+=1 ) {
- $chain = `listHistory -lf 1 -f 0 $objs[$i]`;
- if( size($chain) > 1 ) {
- $nt = `nodeType $chain[1]`;
- if( "makeNurbCylinder" == $nt ) {
- $parent = `listRelatives -p $chain[0]`;
- capCylinder $parent[0] $chain[0] $chain[1];
- }
- else if( "makeNurbCone" == $nt ) {
- $parent = `listRelatives -p $chain[0]`;
- capCone $parent[0] $chain[0] $chain[1];
- }
- else if( "revolve" == $nt ) {
- $parent = `listRelatives -p $chain[0]`;
- capRevolved $parent[0] $chain[0] $chain[1];
- }
- }
- }
- }
-
-