예제 #1
0
static MStatus twistNurbsSurface(MDagPath& objectPath, MObject& component)
{
	MStatus status;

	MPoint  center;
	MVector toCenter( -center.x, 0.0, -center.y );
	double  rotFactor = 0.5;

	// We have a nurbs surface or component
	//
	MItSurfaceCV cvIter( objectPath, component, true, &status );

	if ( status ) {
		// We successfully created a nurbs surface iterator
		//
		for ( ; !cvIter.isDone(); cvIter.nextRow() ) {
			for ( ; !cvIter.isRowDone(); cvIter.next() ) {
				// Get the location of the CV
				//
				MPoint pnt = cvIter.position( MSpace::kWorld );
				pnt = pnt + toCenter;
				// Calculate rotation in radians about the y-axis
				//
				double rotation = pnt.y * rotFactor;
				MMatrix rotMatrix;
				// Set matrix to a rotation about the y axis
				//
				rotMatrix(0,0) = cos( rotation );
				rotMatrix(0,2) = sin( rotation );
				rotMatrix(2,0) = -sin( rotation );
				rotMatrix(2,2) = cos( rotation );
				pnt = ( pnt * rotMatrix ) - toCenter;

				status = cvIter.setPosition( pnt, MSpace::kWorld );
				if ( !status ) {
					status.perror("MItSurfaceCV::setPosition");
					break;
				}
			}
		}
		// Tell maya to redraw the surface with all of our changes
		//
		cvIter.updateSurface();
	} else
		status.perror("MItSurfaceCV::MItSurfaceCV");
	return status;
}
예제 #2
0
MStatus cvExpand::doIt( const MArgList& args )
{

	MSelectionList list;
	MSelectionList newList;

	// Get the geometry list from what is currently selected in the 
	// model
	//
	MGlobal::getActiveSelectionList( list );

	MDagPath path;
	MObject  component;
 
	// Make expanded Selection List
	//
	for ( MItSelectionList iter( list ); !iter.isDone(); iter.next() ) {
		iter.getDagPath( path, component );
		
		if ( path.hasFn( MFn::kNurbsSurfaceGeom ) && 
			 !component.isNull() ) {
			for ( MItSurfaceCV cvIter( path, component ); 
				  !cvIter.isDone(); cvIter.next() ) {
				newList.add( path, cvIter.cv() );
			}
		} else {
			newList.add( path, component );
		}
	}

	// Return expanded selection list as an array of strings
	//
	MStringArray returnArray;
	newList.getSelectionStrings( returnArray );

	MPxCommand::setResult( returnArray );

	return MS::kSuccess;
}