//- // ========================================================================== // Copyright (C) 1995 - 2006 Autodesk, Inc. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to Autodesk, Inc. ("Autodesk") and/or its // licensors, which is protected by U.S. and Canadian federal copyright // law and by international treaties. // // The Data is provided for use exclusively by You. You have the right // to use, modify, and incorporate this Data into other products for // purposes authorized by the Autodesk software license agreement, // without fee. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the // following disclaimer, must be included in all copies of the // Software, in whole or in part, and all derivative works of // the Software, unless such copies or derivative works are solely // in the form of machine-executable object code generated by a // source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR // PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR // TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS LICENSORS // BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK // AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY // OR PROBABILITY OF SUCH DAMAGES. // // ========================================================================== //+ #include #include #include #include #include #include #include // // renderViewRender command declaration // class renderViewRender : public MPxCommand { public: renderViewRender() {}; ~renderViewRender() {}; virtual MStatus doIt ( const MArgList& ); static void* creator(); static MSyntax newSyntax(); MStatus parseSyntax (MArgDatabase &argData); static const char * cmdName; private: bool doNotClearBackground; }; static const char * kDoNotClearBackground = "-b"; static const char * kDoNotClearBackgroundLong = "-background"; const char * renderViewRender::cmdName = "renderViewRender"; void* renderViewRender::creator() { return new renderViewRender; } MSyntax renderViewRender::newSyntax() { MStatus status; MSyntax syntax; syntax.addFlag( kDoNotClearBackground, kDoNotClearBackgroundLong ); CHECK_MSTATUS_AND_RETURN(status, syntax); return syntax; } // // Description: // Read the values of the additionnal flags for this command. // MStatus renderViewRender::parseSyntax (MArgDatabase &argData) { // Get the flag values, otherwise the default values are used. doNotClearBackground = argData.isFlagSet( kDoNotClearBackground ); return MS::kSuccess; } // // Description: // register the command // MStatus initializePlugin( MObject obj ) { MFnPlugin plugin( obj, PLUGIN_COMPANY, "4.5" ); MStatus stat; stat = plugin.registerCommand( renderViewRender::cmdName, renderViewRender::creator, renderViewRender::newSyntax); if ( !stat ) stat.perror( "registerCommand" ); return stat; } // // Description: // unregister the command // MStatus uninitializePlugin( MObject obj ) { MFnPlugin plugin( obj ); MStatus stat; stat = plugin.deregisterCommand( renderViewRender::cmdName ); if ( !stat ) stat.perror( "deregisterCommand" ); return stat; } RV_PIXEL evaluate(int x, int y) // // Description: // Generates a simple procedural circular pattern to be sent to the // Render View. // // Arguments: // x, y - coordinates in the current tile (the pattern is centred // around (0,0) ). // // Return Value: // An RV_PIXEL structure containing the colour of pixel (x,y). // { unsigned int distance = (unsigned int) sqrt(double((x*x) + (y*y))); RV_PIXEL pixel; // Always fully red. pixel.r = 255.0f; // Green and blue varies according to the distance. pixel.g = pixel.b = 155.0f + (distance % 20) * 5; pixel.a = 255.0f; return pixel; } MStatus renderViewRender::doIt( const MArgList& args ) // // Description: // Implements the MEL renderViewRender command. This command // Draws a 640x480 tiled pattern of red and white circles into Maya's // Render View window. // // Arguments: // args - The argument list that was passed to the command from MEL. // -background/-b renders the pattern without clearing the Render View // // Return Value: // MS::kSuccess - command succeeded // MS::kFailure - command failed (returning this value will cause the // MEL script that is being run to terminate unless the // error is caught using a "catch" statement. // { MStatus stat = MS::kSuccess; // Check if the render view exists. It should always exist, unless // Maya is running in batch mode. // if (!MRenderView::doesRenderEditorExist()) { setResult( "Cannot renderViewRender in batch render mode. " "Please run in interactive mode, " "so that the render editor exists." ); return MS::kFailure; } else { cout<<"Past doesRenderEditorExist()"<