// =========================================================================== // 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: Get selected or sole ocean shader // global proc string getCurrentOcean() { string $shaders[] = `ls -type oceanShader`; if( size($shaders) == 0 ){ warning((uiRes("m_getCurrentOcean.kNoOceanShaders"))); return( "" ); } // If only one shader then use it if( size( $shaders ) == 1 ){ return( $shaders[0] ); } // There is more than one, so we need to disambiguate using the selection // First check for selected oceanShaders string $sel[] = `ls -sl -type oceanShader`; if( size($sel) > 0 ){ return( $sel[0] ); } // next check for selected objects with ocean shaders $sel = `ls -sl -dag -type shape`; int $i; for( $i = 0; $i < size( $sel ); $i++ ){ string $nType = `nodeType $sel[$i]`; if( $nType == "heightField" ){ string $con[] = `listConnections ($sel[$i] + ".displacement")`; if( size( $con ) > 0){ $nType = `nodeType $con[0]`; if( $nType == "oceanShader" ){ return( $con[0] ); } } } else { string $con[] = `listConnections ($sel[$i] + ".instObjGroups[0]")`; if( size( $con ) > 0 ){ string $con2[] = `listConnections ($con[0] + ".displacementShader")`; if( size( $con2 ) > 0 ){ $nType = `nodeType $con2[0]`; if( $nType == "oceanShader" ){ return( $con2[0] ); } } } } } warning((uiRes("m_getCurrentOcean.kTooManyOceanShaders"))); return( "" ); }