// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 2002 // // Description: Create an ocean surface with optional preview plane // on selected surfaces. // // create a plane with resolution concentrated in the center and // a default oceanShader global proc string[] createOceanPlane(){ string $tform = `createNode transform -n "oceanPlane1"`; string $shape = `createNode nurbsSurface -n "oceanPlaneShape1" -p $tform`; setAttr -k off ".v"; setAttr ".vir" yes; setAttr ".vif" yes; setAttr ".tw" yes; setAttr -s 121 ".cp[0:120]" -type "double3" 0.14677356245004036 4.1577566360353477e-17 -0.14677356245004036 0.13166760969656849 3.4190198363577702e-17 -0.12069530888852098 0.098944563191612989 2.1021535180232667e-17 -0.074208422393709728 0.053414235837186408 7.5655107705930314e-18 -0.026707117918593204 0.010632473589959279 7.529836587766168e-19 -0.0026581183974898198 0 0 0 0.010632473589959279 -7.529836587766168e-19 0.0026581183974898198 0.053414235837186408 -7.5655107705930314e-18 0.026707117918593204 0.098944563191612989 -2.1021535180232667e-17 0.074208422393709728 0.13166760969656849 -3.4190198363577702e-17 0.12069530888852098 0.14677356245004036 -4.1577566360353477e-17 0.14677356245004036 0.12069530888852098 3.7298398214811989e-17 -0.13166760969656849 0.22334387636476571 6.3268170954803047e-17 -0.22334387636476571 0.20528885641474087 4.7580218233829302e-17 -0.16796360979387873 0.18328848333292425 2.83207645040069e-17 -0.099975536363413248 0.16953425189925797 1.3097766799348588e-17 -0.046236614154343061 0.16847234378759496 0 0 0.16953425189925797 -1.3097766799348588e-17 0.046236614154343061 0.18328848333292425 -2.83207645040069e-17 0.099975536363413248 0.20528885641474087 -4.7580218233829302e-17 0.16796360979387873 0.22334387636476571 -6.3268170954803047e-17 0.22334387636476571 0.12069530888852098 -3.7298398214811989e-17 0.13166760969656849 0.074208422393709728 2.802871357364368e-17 -0.098944563191612989 0.16796360979387873 5.8153600063569208e-17 -0.20528885641474087 0.25261524985034939 7.1560076208310855e-17 -0.25261524985034939 0.2328661834254368 4.3977080671454716e-17 -0.15524412228362444 0.21975098660657011 2.0750129373600711e-17 -0.073250328868856712 0.21711251513877425 0 0 0.21975098660657011 -2.0750129373600718e-17 0.07325032886885674 0.2328661834254368 -4.3977080671454716e-17 0.15524412228362444 0.25261524985034939 -7.1560076208310855e-17 0.25261524985034939 0.16796360979387873 -5.8153600063569208e-17 0.20528885641474087 0.074208422393709728 -2.802871357364368e-17 0.098944563191612989 0.026707117918593204 1.5131021541186063e-17 -0.053414235837186408 0.099975536363413248 5.1921401590679278e-17 -0.18328848333292425 0.15524412228362444 6.596562100718207e-17 -0.2328661834254368 0.19453643315744718 5.5107686453160644e-17 -0.19453643315744718 0.18854460657107269 2.6705170061753666e-17 -0.094272303285536346 0.18509276456554621 0 0 0.18854460657107269 -2.6705170061753672e-17 0.094272303285536374 0.19453643315744718 -5.5107686453160644e-17 0.19453643315744718 0.15524412228362444 -6.596562100718207e-17 0.2328661834254368 0.099975536363413248 -5.1921401590679278e-17 0.18328848333292425 0.026707117918593204 -1.5131021541186063e-17 0.053414235837186408 0.0026581183974898198 3.0119346351064672e-18 -0.010632473589959279 0.046236614154343061 4.8025144930944805e-17 -0.16953425189925797 0.073250328868856712 6.225038812080218e-17 -0.21975098660657011 0.094272303285536346 5.3410340123507332e-17 -0.18854460657107269 0.10796038170857056 3.0582687098741499e-17 -0.10796038170857056 0.10450853970304411 4.6659014702819536e-34 -1.0506676061454628e-18 0.10796038170857056 -3.0582687098741499e-17 0.10796038170857059 0.094272303285536346 -5.3410340123507332e-17 0.18854460657107269 0.073250328868856712 -6.225038812080218e-17 0.21975098660657011 0.046236614154343061 -4.8025144930944805e-17 0.16953425189925797 0.0026581183974898198 -3.0119346351064672e-18 0.010632473589959279 0 0 0 0 4.7724330845327099e-17 -0.16847234378759496 0 6.1502969984245581e-17 -0.21711251513877425 0 5.2432512865965072e-17 -0.18509276456554621 1.0506676061454628e-18 2.9604859841199233e-17 -0.10450853970304411 1.0506676061454628e-18 4.6659014702819536e-34 -1.0506676061454628e-18 1.0506676061454628e-18 -2.9604859841199233e-17 0.10450853970304413 0 -5.2432512865965072e-17 0.18509276456554621 0 -6.1502969984245581e-17 0.21711251513877425 0 -4.7724330845327099e-17 0.16847234378759496 0 0 0 -0.0026581183974898198 3.0119346351064672e-18 -0.010632473589959279 -0.046236614154343061 4.8025144930944805e-17 -0.16953425189925797 -0.07325032886885674 6.225038812080218e-17 -0.21975098660657011 -0.094272303285536374 5.3410340123507332e-17 -0.18854460657107269 -0.10796038170857059 3.0582687098741499e-17 -0.10796038170857056 -0.10450853970304413 4.6659014702819536e-34 -1.0506676061454628e-18 -0.10796038170857059 -3.0582687098741499e-17 0.10796038170857059 -0.094272303285536374 -5.3410340123507332e-17 0.18854460657107269 -0.07325032886885674 -6.225038812080218e-17 0.21975098660657011 -0.046236614154343061 -4.8025144930944805e-17 0.16953425189925797 -0.0026581183974898198 -3.0119346351064672e-18 0.010632473589959279 -0.026707117918593204 1.5131021541186063e-17 -0.053414235837186408 -0.099975536363413248 5.1921401590679278e-17 -0.18328848333292425 -0.15524412228362444 6.596562100718207e-17 -0.2328661834254368 -0.19453643315744718 5.5107686453160644e-17 -0.19453643315744718 -0.18854460657107269 2.6705170061753666e-17 -0.094272303285536346 -0.18509276456554621 0 0 -0.18854460657107269 -2.6705170061753672e-17 0.094272303285536374 -0.19453643315744718 -5.5107686453160644e-17 0.19453643315744718 -0.15524412228362444 -6.596562100718207e-17 0.2328661834254368 -0.099975536363413248 -5.1921401590679278e-17 0.18328848333292425 -0.026707117918593204 -1.5131021541186063e-17 0.053414235837186408 -0.074208422393709728 2.802871357364368e-17 -0.098944563191612989 -0.16796360979387873 5.8153600063569208e-17 -0.20528885641474087 -0.25261524985034939 7.1560076208310855e-17 -0.25261524985034939 -0.2328661834254368 4.3977080671454716e-17 -0.15524412228362444 -0.21975098660657011 2.0750129373600711e-17 -0.073250328868856712 -0.21711251513877425 0 0 -0.21975098660657011 -2.0750129373600718e-17 0.07325032886885674 -0.2328661834254368 -4.3977080671454716e-17 0.15524412228362444 -0.25261524985034939 -7.1560076208310855e-17 0.25261524985034939 -0.16796360979387873 -5.8153600063569208e-17 0.20528885641474087 -0.074208422393709728 -2.802871357364368e-17 0.098944563191612989 -0.12069530888852098 3.7298398214811989e-17 -0.13166760969656849 -0.22334387636476571 6.3268170954803047e-17 -0.22334387636476571 -0.20528885641474087 4.7580218233829302e-17 -0.16796360979387873 -0.18328848333292425 2.83207645040069e-17 -0.099975536363413248 -0.16953425189925797 1.3097766799348588e-17 -0.046236614154343061 -0.16847234378759496 0 0 -0.16953425189925797 -1.3097766799348588e-17 0.046236614154343061 -0.18328848333292425 -2.83207645040069e-17 0.099975536363413248 -0.20528885641474087 -4.7580218233829302e-17 0.16796360979387873 -0.22334387636476571 -6.3268170954803047e-17 0.22334387636476571 -0.12069530888852098 -3.7298398214811989e-17 0.13166760969656849 -0.14677356245004036 4.1577566360353477e-17 -0.14677356245004036 -0.13166760969656849 3.4190198363577702e-17 -0.12069530888852098 -0.098944563191612989 2.1021535180232667e-17 -0.074208422393709728 -0.053414235837186408 7.5655107705930314e-18 -0.026707117918593204 -0.010632473589959279 7.529836587766168e-19 -0.0026581183974898198 0 0 0 -0.010632473589959279 -7.529836587766168e-19 0.0026581183974898198 -0.053414235837186408 -7.5655107705930314e-18 0.026707117918593204 -0.098944563191612989 -2.1021535180232667e-17 0.074208422393709728 -0.13166760969656849 -3.4190198363577702e-17 0.12069530888852098 -0.14677356245004036 -4.1577566360353477e-17 0.14677356245004036; setAttr ".fbda" no; setAttr ".dvu" 0; setAttr ".dvv" 0; setAttr ".cpr" 4; setAttr ".cps" 1; setAttr ".ucr" no; setAttr ".nu" 10; setAttr ".nv" 10; setAttr ".eta" yes; setAttr ".nufa" 4.5; setAttr ".nvfa" 4.5; setAttr ".overrideEnabled" 1; setAttr ".overrideShading" 0; setAttr ".overrideTexturing" 0; setAttr ".overridePlayback" 0; string $makeNurbPlane = `createNode makeNurbPlane -n "makeNurbPlane1"`; setAttr ".ax" -type "double3" 0 1 0 ; setAttr ".u" 8; setAttr ".v" 8; float $wid = `getAttr ".width"`; setAttr ".width" 1; connectAttr ($makeNurbPlane + ".os") ($shape + ".cr"); float $scl = $wid * 575.0; setAttr ($tform + ".s") -type "double3" $scl $scl $scl ; createAndAssignShader oceanShader $shape; string $ret[2]; $ret[0] = $tform; $ret[1] = $shape; return( $ret ); } global proc createOcean( int $attachToCamera, int $previewPlane, float $planeScale) { string $objs[] = createOceanPlane(); string $tform = $objs[0]; string $shape = $objs[1]; string $shapeHelp = ("This node is used to render the ocean surface. It is" +" designed to concentrate more triangles in the center so that one" +" can can have the ocean extend to the horizon, and yet still see" +" reasonable resolution in the local displacement." +" The draw overrides have been set to disable interactive shading of" +" this surface, which would slow down playback."); if( $attachToCamera ){ string $allCameras[] = `listCameras -p`; int $i; int $numRenderable = 0; string $cam; for ($i = 0; $i < size($allCameras); $i++) { if (`getAttr ($allCameras[$i] + ".renderable")`) { if( $numRenderable == 0 ){ $cam = $allCameras[$i]; } $numRenderable++; } } if( $numRenderable == 0 ){ warning((uiRes("m_createOcean.kNoRenderableCameras"))); } else if( $numRenderable > 1 ){ warning((uiRes("m_createOcean.kTooManyRenderableCameras"))); } else { string $exp = ($tform + ".tx = " + $cam + ".tx;\n" +$tform + ".tz = " + $cam + ".tz;\n" +"float $scale = abs(150.0 * " + $cam + ".ty) + 10.0;\n" +$tform + ".sx = $scale;\n" +$tform + ".sy = $scale;\n" +$tform + ".sz = $scale;\n"); string $expName = `expression -s $exp`; string $tformHelp = ("The expression "+$expName+" has been set up to scale and" +" translate this node based on the camera "+ $cam + ", thus" +" maintaining an optimum distribution of triangles for the" +" given point of view." ); addAttr -sn nts -ln notes -dt "string" $tform; setAttr -type "string" ($tform + ".notes") $tformHelp; } } else { $shapeHelp += ("For best resolution you may wish to translate this surface so that" +" the center is just in front of the view. Scale it as small as is" +" acceptable, based on the horizon."); } if( $previewPlane ){ string $con[] = `listConnections ($shape + ".instObjGroups[0]")`; string $con2[] = `listConnections ($con[0] + ".displacementShader")`; string $oceanShader = $con2[0]; string $hf = `shadingNode -asUtility -n oceanPreviewPlane1 heightField`; string $hfTform[] = `listRelatives -p $hf`; scale $planeScale 1.0 $planeScale $hfTform[0]; setAttr -l true ($hfTform[0] + ".scaleY"); setAttr -l true ($hfTform[0] + ".translateY"); setAttr -l true ($hfTform[0] + ".rotateX"); setAttr -l true ($hfTform[0] + ".rotateY"); setAttr -l true ($hfTform[0] + ".rotateZ"); setAttr ($hf + ".resolution") 20; setAttr ($hf + ".color") -type double3 0.2 0.5 0.5; connectAttr ($oceanShader + ".displacement") ($hf + ".displacement"); connectAttr ($oceanShader + ".outColor") ($hf + ".color"); string $helpString = ("This node is used to preview the ocean's surface. " +"It does not appear in renders. (oceanPlane1 is the node that renders) " +"Translate and scale it to preview " +"different parts of the ocean.\n" +"One may increase the resolution to better judge the fine details " +"on the surface, or lower it to provide faster playback performance.\n"); addAttr -sn nts -ln notes -dt "string" $hf; setAttr -type "string" ($hf + ".notes") $helpString; $shapeHelp += ("\nThe heightfield node "+$hf+" has been set up to allow" +" one to interactively preview the ocean at a defined location."); } addAttr -sn nts -ln notes -dt "string" $shape; setAttr -type "string" ($shape + ".notes") $shapeHelp; }