Exemplo n.º 1
0
MStatus deleteCurrentSelection()
{
    MStatus status;

    MDGModifier modifier;
    status = modifier.commandToExecute("\ndelete;\n");
    status = modifier.doIt();

    return status;
}
Exemplo n.º 2
0
MStatus setupRGBShaders::redoIt()
{
    int numLayers = meshObjs.length() / 3;

    if( numLayers == 0 && meshObjs.length() > 0 )
        numLayers++;

    if( meshObjs.length() % 3 > 0 && meshObjs.length() > 3 )
        numLayers++;

    for( int l = 0; l < numLayers; l++ ) {
        MStatus stat;

        MFnDependencyNode mrUserBufferFn( dgMod.createNode( "mentalrayUserBuffer", &stat ));
        dgDoIt();
        //MGlobal::executeCommand( MString( "connectAttr -f " ) + mrUserBufferFn.name() + ".message miDefaultOptions.frameBufferList[" + l + "]" );
        dgMod.commandToExecute( MString( "connectAttr -f " ) + mrUserBufferFn.name() + ".message miDefaultOptions.frameBufferList[" + l + "]" );
        dgDoIt();
        mrUserBufferFn.findPlug( "dataType" ).setValue( 5 );

        for( int i = 0; i < 3; i++ ) {
            if(( l * 3 + i ) > (int)meshObjs.length() - 1 ) break;

            MFnDependencyNode nkPassFn( dgMod.createNode( "nkPass" ));
            dgDoIt();
            MFnDependencyNode meshFn( meshObjs[ l * 3 + i ]);

            dgMod.commandToExecute( MString( "sets -renderable true -noSurfaceShader true -empty -name " ) + nkPassFn.name() + "SG" );
            dgDoIt();
            dgMod.commandToExecute( MString( "connectAttr -f " ) + nkPassFn.name() + ".outValue " + nkPassFn.name() + "SG.miMaterialShader" );
            dgDoIt();
            dgMod.commandToExecute( MString( "sets -e -forceElement ") + nkPassFn.name() + "SG " + meshFn.name());
            dgDoIt();

            /*MGlobal::executeCommand( MString( "sets -renderable true -noSurfaceShader true -empty -name " ) + nkPassFn.name() + "SG" );
            MGlobal::executeCommand( MString( "connectAttr -f " ) + nkPassFn.name() + ".outValue " + nkPassFn.name() + "SG.miMaterialShader" );
            MGlobal::executeCommand( MString( "sets -e -forceElement ") + nkPassFn.name() + "SG " + meshFn.name());*/

            nkPassFn.findPlug( "layerNumber" ).setValue( l );

            if( i == 0 )
                dgMod.commandToExecute( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 1 0 0" );
            //MGlobal::executeCommand( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 1 0 0" );

            if( i == 1 )
                dgMod.commandToExecute( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 0 1 0" );
            //MGlobal::executeCommand( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 0 1 0" );

            if( i == 2 )
                dgMod.commandToExecute( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 0 0 1" );
            //MGlobal::executeCommand( MString( "setAttr " ) + nkPassFn.name() + ".color -type double3 0 0 1" );

            dgDoIt();
        }
    }

    for( unsigned int c = 0; c < camObjs.length(); c++ ) {
        MFnDependencyNode mrOutputPass( dgMod.createNode( "mentalrayOutputPass" ));
        dgDoIt();
        MFnDependencyNode nkSaver( dgMod.createNode( "nkSaver" ));
        dgDoIt();
        dgMod.connect( nkSaver.findPlug( "outValue" ), mrOutputPass.findPlug( "outputShader" ));
        dgDoIt();

        MFnDependencyNode camFn( camObjs[c] );

        //MGlobal::executeCommand( MString( "connectAttr -f " ) + mrOutputPass.name() + ".message " + camFn.name() + ".miOutputShaderList[0]" );
        dgMod.commandToExecute( MString( "connectAttr -f " ) + mrOutputPass.name() + ".message " + camFn.name() + ".miOutputShaderList[0]" );
        dgDoIt();

        nkSaver.findPlug( "numLayers" ).setValue( numLayers );
        nkSaver.findPlug( "camName" ).setValue( camFn.name() );
        nkSaver.findPlug( "fileName" ).setValue( fileName );
        nkSaver.findPlug( "folderPath" ).setValue( folderPath );
        mrOutputPass.findPlug( "datatype" ).setValue( 5 );
    }

    setResult( "Shaders setup to Render" );

    return MS::kSuccess;
}