//- // ========================================================================== // 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 #include class MIntArray; class MVectorArray; class MFnArrayAttrsData; #define McheckErr(stat, msg) \ if ( MS::kSuccess != stat ) \ { \ cerr << msg; \ return MS::kFailure; \ } class sweptEmitter: public MPxEmitterNode { public: sweptEmitter(); virtual ~sweptEmitter(); static void *creator(); static MStatus initialize(); virtual MStatus compute( const MPlug& plug, MDataBlock& block ); static MTypeId id; private: void emit( const MVectorArray &inPosAry, const MVectorArray &inVelAry, const MIntArray &countAry, double dt, double speed, double inheritFactor, MVector dirV, MVectorArray &outPos, MVectorArray &outVel ); MVector useRotation ( MVector &direction ); MStatus emitCountPerPoint( const MPlug& plug, MDataBlock& block, int length, MIntArray &countAry ); // methods to get attribute value. // double rateValue( MDataBlock& block ); double speedValue( MDataBlock& block ); MVector directionVector( MDataBlock& block ); bool isFullValue( int plugIndex, MDataBlock& block ); double inheritFactorValue( int plugIndex, MDataBlock& block ); MTime currentTimeValue( MDataBlock& block ); MTime startTimeValue( int plugIndex, MDataBlock& block ); MTime deltaTimeValue( int plugIndex, MDataBlock& block ); // the previous position in the world space. // MPoint lastWorldPoint; }; // inlines // inline double sweptEmitter::rateValue( MDataBlock& block ) { MStatus status; MDataHandle hValue = block.inputValue( mRate, &status ); double value = 0.0; if( status == MS::kSuccess ) value = hValue.asDouble(); return( value ); } inline double sweptEmitter::speedValue( MDataBlock& block ) { MStatus status; MDataHandle hValue = block.inputValue( mSpeed, &status ); double value = 0.0; if( status == MS::kSuccess ) value = hValue.asDouble(); return( value ); } inline MVector sweptEmitter::directionVector( MDataBlock& block ) { MStatus status; MVector dirV(0.0, 0.0, 0.0); MDataHandle hValue = block.inputValue( mDirection, &status ); if( status == MS::kSuccess ) { double3 &value = hValue.asDouble3(); dirV[0] = value[0]; dirV[1] = value[1]; dirV[2] = value[2]; } return( dirV ); } inline bool sweptEmitter::isFullValue( int plugIndex, MDataBlock& block ) { MStatus status; bool value = true; MArrayDataHandle mhValue = block.inputArrayValue( mIsFull, &status ); if( status == MS::kSuccess ) { status = mhValue.jumpToElement( plugIndex ); if( status == MS::kSuccess ) { MDataHandle hValue = mhValue.inputValue( &status ); if( status == MS::kSuccess ) value = hValue.asBool(); } } return( value ); } inline double sweptEmitter::inheritFactorValue(int plugIndex,MDataBlock& block) { MStatus status; double value = 0.0; MArrayDataHandle mhValue = block.inputArrayValue( mInheritFactor, &status ); if( status == MS::kSuccess ) { status = mhValue.jumpToElement( plugIndex ); if( status == MS::kSuccess ) { MDataHandle hValue = mhValue.inputValue( &status ); if( status == MS::kSuccess ) value = hValue.asDouble(); } } return( value ); } inline MTime sweptEmitter::currentTimeValue( MDataBlock& block ) { MStatus status; MDataHandle hValue = block.inputValue( mCurrentTime, &status ); MTime value(0.0); if( status == MS::kSuccess ) value = hValue.asTime(); return( value ); } inline MTime sweptEmitter::startTimeValue( int plugIndex, MDataBlock& block ) { MStatus status; MTime value(0.0); MArrayDataHandle mhValue = block.inputArrayValue( mStartTime, &status ); if( status == MS::kSuccess ) { status = mhValue.jumpToElement( plugIndex ); if( status == MS::kSuccess ) { MDataHandle hValue = mhValue.inputValue( &status ); if( status == MS::kSuccess ) value = hValue.asTime(); } } return( value ); } inline MTime sweptEmitter::deltaTimeValue( int plugIndex, MDataBlock& block ) { MStatus status; MTime value(0.0); MArrayDataHandle mhValue = block.inputArrayValue( mDeltaTime, &status ); if( status == MS::kSuccess ) { status = mhValue.jumpToElement( plugIndex ); if( status == MS::kSuccess ) { MDataHandle hValue = mhValue.inputValue( &status ); if( status == MS::kSuccess ) value = hValue.asTime(); } } return( value ); }