本文整理汇总了C++中MFnNumericData类的典型用法代码示例。如果您正苦于以下问题:C++ MFnNumericData类的具体用法?C++ MFnNumericData怎么用?C++ MFnNumericData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFnNumericData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setZeroTweaks
//############################################### tima:
bool polyModifierCmd::setZeroTweaks()
{
MFnNumericData numDataFn;
MObject nullVector;
MFnDependencyNode depNodeFn;
numDataFn.create( MFnNumericData::k3Float );
numDataFn.setData( 0, 0, 0 );
nullVector = numDataFn.object();
MObject object = fDagPath.node();
depNodeFn.setObject( object);
MPlug meshTweakPlug = depNodeFn.findPlug( "pnts" );
MPlug tweak;
unsigned numTweaks = fTweakIndexArray.length();
if( !meshTweakPlug.isNull() )
{
for( unsigned i = 0; i < numTweaks; i++ )
{
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( nullVector );
}
}
return true;
}
示例2: translateFn
MManipData V3Manipulator::vectorManipToPlugConversion( unsigned int plugIndex )
{
MFnFreePointTriadManip translateFn( m_translateManip );
MPoint t;
getConverterManipValue( translateFn.pointIndex(), t );
t = t * m_localMatrixInv;
MFnNumericData numericData;
MObject returnData;
// We have to check what type of data to generate so Maya
// will be able to set it back into the attribute correctly.
MFnNumericAttribute attr( m_translatePlug.attribute() );
if( attr.unitType() == MFnNumericData::k3Float )
{
returnData = numericData.create( MFnNumericData::k3Float );
numericData.setData( float(t.x), float(t.y), float(t.z) );
}
else
{
returnData = numericData.create( MFnNumericData::k3Double );
numericData.setData( t.x, t.y, t.z );
}
return MManipData( returnData );
}
示例3: depTmpFn
// --------------------------------------------------------------------------------------------
void polyModifierCmd::deleteTweaks()
// --------------------------------------------------------------------------------------------
{
// Now, set the tweak values on the meshNode(s) to zero (History dependent)
//
MStatus stat;
MFnNumericData numDataFn;
MObject nullVector;
// Create a NULL vector (0,0,0) using MFnNumericData to pass into the plug
//
MFnDependencyNode depTmpFn(fDagPath.node(),&stat);
//stat.perror("");
MPlug meshTweakPlug = depTmpFn.findPlug("pnts");
numDataFn.create( MFnNumericData::k3Float );
numDataFn.setData( 0, 0, 0 );
nullVector = numDataFn.object();
unsigned numTweaks = meshTweakPlug.numElements();
MPlug tweak;
for(unsigned i = 0; i < numTweaks; i++ )
{
// Access using logical indices since they are the only plugs guaranteed
// to hold tweak data.
//
tweak = meshTweakPlug.elementByPhysicalIndex(i);
tweak.setValue( nullVector );
}
}
示例4: briefName
MStatus PRTAttrs::addColorParameter(MFnDependencyNode & node, MObject & attr, const MString & name, MString & value ) {
MStatus stat;
MFnNumericAttribute nAttr;
const wchar_t* s = value.asWChar();
attr = nAttr.createColor(longName(name), briefName(name), &stat );
MCHECK(stat);
double r = 0.0;
double g = 0.0;
double b = 0.0;
if (s[0] == '#' && wcslen(s) >= 7) {
r = (double)((prtu::fromHex(s[1]) << 4) + prtu::fromHex(s[2])) / 255.0;
g = (double)((prtu::fromHex(s[3]) << 4) + prtu::fromHex(s[4])) / 255.0;
b = (double)((prtu::fromHex(s[5]) << 4) + prtu::fromHex(s[6])) / 255.0;
nAttr.setDefault(r, g, b);
}
MCHECK(addParameter(node, attr, nAttr));
MFnNumericData fnData;
MObject rgb = fnData.create(MFnNumericData::k3Double, &stat);
MCHECK(stat);
fnData.setData(r, g, b);
MPlug plug(node.object(), attr);
MCHECK(plug.setValue(rgb));
return MS::kSuccess;
}
示例5: scaleManip
MManipData componentScaleManip::plugToManipConversion(unsigned index) {
MObject obj = MObject::kNullObj;
// If we entered the callback with an invalid index, print an error and
// return. Since we registered the callback only for one index, all
// invocations of the callback should be for that index.
//
MFnScaleManip scaleManip(fScaleManip);
if (index == scaleManip.scaleCenterIndex())
{
// Set the center point for scaling to the centroid of the CV's.
//
MFnNumericData numericData;
obj = numericData.create( MFnNumericData::k3Double );
numericData.setData(centroid.x,centroid.y,centroid.z);
return MManipData(obj);
}
MGlobal::displayError("Invalid index in plugToManipConversion()!");
// For invalid indices, return vector of 0's
MFnNumericData numericData;
obj = numericData.create( MFnNumericData::k3Double );
numericData.setData(0.0,0.0,0.0);
return obj;
}
示例6: setPlugValue
//---------------------------------------------------
bool DagHelper::setPlugValue ( MPlug& plug, float x, float y )
{
MFnNumericData data;
MObject obj = data.create ( MFnNumericData::k2Float );
data.setData ( x, y );
return plug.setValue ( obj );
}
示例7:
MStatus polyModifierCmd::getFloat3asMObject( MFloatVector value, MObject& object )
{
// Convert the float value into an MObject
//
MFnNumericData numDataFn;
numDataFn.create( MFnNumericData::k3Float );
numDataFn.setData( value[0], value[1], value[2] );
object = numDataFn.object();
return MS::kSuccess;
}
示例8: startPointCallback
MManipData swissArmyLocatorManip::startPointCallback(unsigned /*index*/)
const
{
MManipData manipData;
MFnNumericData numData;
MObject numDataObj = numData.create(MFnNumericData::k3Double);
MVector vec = nodeTranslation();
numData.setData(vec.x, vec.y, vec.z);
manipData = numDataObj;
return manipData;
}
示例9: fcolor
//---------------------------------------------------
bool DagHelper::getPlugValue ( const MPlug& plug, float& x, float& y )
{
MObject obj;
plug.getValue ( obj );
MStatus status;
MFnNumericData fcolor ( obj, &status );
if ( !status ) return 0;
fcolor.getData ( x , y );
return 1;
}
示例10: COLLADABU_ASSERT
//---------------------------------------------------
bool DagHelper::getPlugValue ( const MPlug& plug, MVector& value )
{
MObject obj;
plug.getValue ( obj );
MStatus status = plug.getValue ( obj );
COLLADABU_ASSERT ( status );
MFnNumericData data ( obj );
double x, y, z;
status = data.getData ( x, y, z );
COLLADABU_ASSERT ( status );
value = MVector ( x,y,z );
return true;
}
示例11: transformObject
MStatus geometrySurfaceConstraintCommand::connectObjectAndConstraint( MDGModifier& modifier )
{
MObject transform = transformObject();
if ( transform.isNull() )
{
MGlobal::displayError("Failed to get transformObject()");
return MS::kFailure;
}
MStatus status;
MFnTransform transformFn( transform );
MVector translate = transformFn.getTranslation(MSpace::kTransform,&status);
if (!status) { status.perror(" transformFn.getTranslation"); return status;}
MPlug translatePlug = transformFn.findPlug( "translate", &status );
if (!status) { status.perror(" transformFn.findPlug"); return status;}
if ( MPlug::kFreeToChange == translatePlug.isFreeToChange() )
{
MFnNumericData nd;
MObject translateData = nd.create( MFnNumericData::k3Double, &status );
status = nd.setData3Double( translate.x,translate.y,translate.z);
if (!status) { status.perror("nd.setData3Double"); return status;}
status = modifier.newPlugValue( translatePlug, translateData );
if (!status) { status.perror("modifier.newPlugValue"); return status;}
status = connectObjectAttribute(
MPxTransform::geometry,
geometrySurfaceConstraint::constraintGeometry, false );
if (!status) { status.perror("connectObjectAttribute"); return status;}
}
status = connectObjectAttribute(
MPxTransform::parentInverseMatrix,
geometrySurfaceConstraint::constraintParentInverseMatrix, true, true );
if (!status) { status.perror("connectObjectAttribute"); return status;}
return MS::kSuccess;
}
示例12: fnTrans
//- This method is plugToManipConversionCallback function
//- You implement it so that a specific component of the manipulator
//- will be modified automatically when some plug value changes on
//- the custom locator.
//- Arguments:
//- manipIndex - the index of the component on the manip you want to affect,
//- in this case, it is the center point of this manip
//- Return Values:
//- MManipData object, which represents the updated value
MManipData arrowLocatorManip::centerPointCallback(unsigned int manipIndex)
{
MStatus status;
//Get parent transform node of the locator node
MObject parentTransform = fNodePath.transform(&status);
//Get the transform node DAG path
MDagPath transformPath;
MDagPath::getAPathTo(parentTransform,transformPath);
//Retrieve world space translation
MFnTransform fnTrans(transformPath,&status);
MVector translation = fnTrans.getTranslation(MSpace::kWorld,&status);
MFnNumericData numData;
MObject numDataValue = numData.create(MFnNumericData::k3Double,&status);
status = numData.setData3Double(translation.x,translation.y,translation.z);
MManipData manipData(numDataValue);
return manipData;
}
示例13: MStatusAssert
//.........这里部分代码省略.........
int dstOffset = 0;
//Progress initialisieren
progressBar progress("Processing Tweaks", numTweaks);
for( i = 0; i < numTweaks; i++ )
{
// Apply tweak data
//
tweak = polyTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( tweakDataArray[i] );
// ASSERT: Element plug should be compound!
//
MStatusAssert( (tweak.isCompound()),
"tweak.isCompound() -- Element plug, 'tweak', is not compound" );
unsigned numChildren = tweak.numChildren();
for( j = 0; j < numChildren; j++ )
{
tweakChild = tweak.child(j);
// Apply tweak source connection data
//
if( 0 < tweakSrcConnectionCountArray[i*numChildren + j] )
{
for( k = 0;
k < (unsigned) tweakSrcConnectionCountArray[i*numChildren + j];
k++ )
{
fDGModifier.connect( tweakChild,
tweakSrcConnectionPlugArray[srcOffset] );
srcOffset++;
}
}
// Apply tweak destination connection data
//
if( 0 < tweakDstConnectionCountArray[i*numChildren + j] )
{
fDGModifier.connect( tweakDstConnectionPlugArray[dstOffset],
tweakChild );
dstOffset++;
}
}
if(i%50 == 0)
{
progress.set(i);
}
}
// Now, set the tweak values on the meshNode(s) to zero (History dependent)
//
MFnNumericData numDataFn;
MObject nullVector;
// Create a NULL vector (0,0,0) using MFnNumericData to pass into the plug
//
numDataFn.create( MFnNumericData::k3Float );
numDataFn.setData( 0, 0, 0 );
nullVector = numDataFn.object();
for( i = 0; i < numTweaks; i++ )
{
// Access using logical indices since they are the only plugs guaranteed
// to hold tweak data.
//
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( nullVector );
}
// Only have to clear the tweaks off the duplicate mesh if we do not have history
// and we want history.
//
if( !fHasHistory && fHasRecordHistory )
{
depNodeFn.setObject( data.upstreamNodeShape );
upstreamTweakPlug = depNodeFn.findPlug( "pnts" );
if( !upstreamTweakPlug.isNull() )
{
for( i = 0; i < numTweaks; i++ )
{
tweak = meshTweakPlug.elementByLogicalIndex( fTweakIndexArray[i] );
tweak.setValue( nullVector );
}
}
}
}
else
fHasTweaks = false;
return status;
}
示例14:
void V3Manipulator::getPlugValues( MPlug &plug, MFnNumericData &data )
{
double values[3];
getPlugValues( plug, values );
data.setData( values[0], values[1], values[2] );
}
示例15: stateManip
MManipData exampleRotateManip::rotationChangedCallback(unsigned index) {
static MEulerRotation cache;
MObject obj = MObject::kNullObj;
// If we entered the callback with an invalid index, print an error and
// return. Since we registered the callback only for one plug, all
// invocations of the callback should be for that plug.
//
if (index != rotatePlugIndex)
{
MGlobal::displayError("Invalid index in rotation changed callback!");
// For invalid indices, return vector of 0's
MFnNumericData numericData;
obj = numericData.create( MFnNumericData::k3Double );
numericData.setData(0.0,0.0,0.0);
return obj;
}
// Assign function sets to the manipulators
//
MFnStateManip stateManip(fStateManip);
MFnRotateManip rotateManip(fRotateManip);
// Adjust settings on the rotate manip based on the state of the state
// manip.
//
int mode = stateManip.state();
if (mode != 3)
{
rotateManip.setRotateMode((MFnRotateManip::RotateMode) stateManip.state());
rotateManip.setSnapMode(false);
}
else {
// State 3 enables snapping for an object space manip. In this case,
// we snap every 15.0 degrees.
//
rotateManip.setRotateMode(MFnRotateManip::kObjectSpace);
rotateManip.setSnapMode(true);
rotateManip.setSnapIncrement(15.0);
}
// The following code creates a data object to be returned in the
// MManipData. In this case, the plug to be computed must be a 3-component
// vector, so create data as MFnNumericData::k3Double
//
MFnNumericData numericData;
obj = numericData.create( MFnNumericData::k3Double );
// Retrieve the value for the rotation from the manipulator and return it
// directly without modification. If the manipulator should eg. slow down
// rotation, this method would need to do some math with the value before
// returning it.
//
MEulerRotation manipRotation;
if (!getConverterManipValue (rotateManip.rotationIndex(), manipRotation))
{
MGlobal::displayError("Error retrieving manip value");
numericData.setData(0.0,0.0,0.0);
}
else {
numericData.setData(manipRotation.x, manipRotation.y, manipRotation.z);
}
return MManipData(obj);
}