//- // ========================================================================== // Copyright (C) 1995 - 2005 Alias Systems Corp. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files are provided by Alias // Systems Corp. ("Alias") and/or its licensors for the exclusive use of the // Customer (as defined in the Alias Software License Agreement that // accompanies this Alias software). Such Customer has the right to use, // modify, and incorporate the Data into other products and to distribute such // products for use by end-users. // // THE DATA IS PROVIDED "AS IS". ALIAS HEREBY DISCLAIMS ALL WARRANTIES // RELATING TO THE DATA, INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR // IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES // WHATSOEVER, WHETHER DIRECT, INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, OR IN EQUITY, // ARISING OUT OF ACCESS TO, USE OF, OR RELIANCE UPON THE DATA. // ========================================================================== //+ //////////////////////////////////////////////////////////////////////// // // particleSystemInfoCmd // // Demonstrates the use of the new MFnParticleSystem class for retrieving // particle information. The number of particle positions followed by // the positions are printed to the script editor. // // Syntax: // particleSystemInfo $particleNodeName; // // Example: // particleSystemInfo particleShape2; // //////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mCommandName "particleSystemInfo" // Command name #define CHECKRESULT(stat,msg) \ if ( MS::kSuccess != stat ) { \ cerr << msg << endl; \ } class particleSystemInfoCmd : public MPxCommand { public: particleSystemInfoCmd(); virtual ~particleSystemInfoCmd(); virtual MStatus doIt ( const MArgList& args ); static void* creator(); private: static MStatus nodeFromName(MString name, MObject & obj); MStatus parseArgs ( const MArgList& args ); MObject particleNode; }; particleSystemInfoCmd::particleSystemInfoCmd() { } particleSystemInfoCmd::~particleSystemInfoCmd() { } // // /////////////////////////////////////////////////////////////////////////////// MStatus particleSystemInfoCmd::nodeFromName(MString name, MObject & obj) { MSelectionList tempList; tempList.add( name ); if ( tempList.length() > 0 ) { tempList.getDependNode( 0, obj ); return MS::kSuccess; } return MS::kFailure; } MStatus particleSystemInfoCmd::parseArgs( const MArgList& args ) { // Parse the arguments. MStatus stat = MS::kSuccess; if( args.length() > 1 ) { MGlobal::displayError( "Too many arguments." ); return MS::kFailure; } if( args.length() == 1 ) { MString particleName = args.asString( 0, &stat ); CHECKRESULT(stat, "Failed to parse particle node name argument." ); nodeFromName( particleName, particleNode ); if( !particleNode.isNull() && !particleNode.hasFn( MFn::kParticle ) ) { MGlobal::displayError( "The named node is not a particle system." ); return MS::kFailure; } } return MS::kSuccess; } // // Main routine /////////////////////////////////////////////////////////////////////////////// MStatus particleSystemInfoCmd::doIt( const MArgList& args ) { MStatus stat = parseArgs( args ); if( stat != MS::kSuccess ) return stat; if( particleNode.isNull() ) { MObject parent; MFnParticleSystem dummy; particleNode = dummy.create(&stat); CHECKRESULT(stat,"MFnParticleSystem::create(status) failed!"); MFnParticleSystem ps( particleNode, &stat ); CHECKRESULT(stat,"MFnParticleSystem::MFnParticleSystem(MObject,status) failed!"); MPointArray posArray; posArray.append(MPoint(-5, 5, 0)); posArray.append(MPoint(-5, 10, 0)); MVectorArray velArray; velArray.append(MPoint(1, 1, 0)); velArray.append(MPoint(1, 1, 0)); stat = ps.emit(posArray, velArray); CHECKRESULT(stat,"MFnParticleSystem::emit(posArray,velArray) failed!"); stat = ps.emit(MPoint(5, 5, 0)); CHECKRESULT(stat,"MFnParticleSystem::emit(pos) failed!"); stat = ps.emit(MPoint(5, 10, 0)); CHECKRESULT(stat,"MFnParticleSystem::emit(pos) failed!"); stat = ps.saveInitialState(); CHECKRESULT(stat,"MFnParticleSystem::saveInitialState() failed!"); MVectorArray accArray; accArray.setLength(4); for( unsigned int i=0; i