//- // ========================================================================== // 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 "testNobjectNode.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "stdio.h" /* Introduction to interacting with the N Solver ============================================= In order to create an N cloth object that can interact with the Nucleus solver, your object will need to own a MnCloth, which represents the underlying N cloth and its data. your node will also need the following 6 attributes: ATTR Type Description startState kNObject initial state of your N object currentState kNObject current state of your N object currentTime Time connection to the current time nextState kNObject next state of you N object inputGeom kMesh input mesh outputGeom kMesh output mesh inputGeom,outputGeom and currentTime are self explanatory. A connection is to be made from the nucleus solver's outputObjects attribute to the nextState attribute of your node. Also, you need to connect the currentState and startState attributes of your node to the inputActive and inputActiveStart attributes on the solver node respectively. Once these connections are made, the normal sequence of events is the following: The refresh will trigger a pull on the output mesh attribute. At this your node will pull on the nextState attribute, triggering a solve from the solver. Depending on the current time, the solver will trigger pulls on either the currentState or startState attributes of your node. If the startState is pulled on, you need to initialize the MnCloth which you node owns from the input geometry. Once this is done and the data passed back to the solver, a solve will occur, and the solver will automatically update your MnCloth behind the scenes. At this point you may extract the results of the solve via methods on the MnCloth and apply it to the output mesh. Below is a script that show how to test this node: //This example show how 2 cloth objects falling and colliding with a sphere //side by side. One is a default nCloth object, the other is a cloth //object created by our plugin. //************************************************************************** //Note: Before running this code, make sure the plugin testNobjectNode is loaded! //************************************************************************** global proc setupCustomClothScene() { file -f -new; //plane1 will be driven by regular nCloth string $pPlane1[] = `polyPlane -w 5 -h 5 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1`; move -r -10 0 0; createNCloth 0; //plane2 will act as input to our testNobjectNode string $pPlane2[] = `polyPlane -w 5 -h 5 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1`; //plane3 will act as output to our testNobjectNode string $pPlane3[] = `polyPlane -w 5 -h 5 -sx 10 -sy 10 -ax 0 1 0 -cuv 2 -ch 1`; select -r polyPlane3 ; doDelete; //spheres 1 and 2 will both act as passive objects. string $pSphere1[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`; move -r -10 -3 0; string $pSphere2[] = `polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1`; move -r 0 -3 0; select -r $pSphere1[0] $pSphere2[0]; makeCollideNCloth; createNode testNobjectNode; connectAttr pPlaneShape2.worldMesh[0] testNobjectNode1.inputGeom; connectAttr nucleus1.outputObjects[1] testNobjectNode1.nextState; connectAttr testNobjectNode1.currentState nucleus1.inputActive[1]; connectAttr testNobjectNode1.startState nucleus1.inputActiveStart[1]; connectAttr testNobjectNode1.outputGeom pPlaneShape3.inMesh; connectAttr time1.outTime testNobjectNode1.currentTime; } */ const MTypeId testNobjectNode::id( 0x85003 ); MObject testNobjectNode::startState; MObject testNobjectNode::currentState; MObject testNobjectNode::currentTime; MObject testNobjectNode::nextState; MObject testNobjectNode::inputGeom; MObject testNobjectNode::outputGeom; inline void statCheck( MStatus stat, MString msg ) { if ( !stat ) { cout<