本文整理汇总了C++中MDagModifier::createNode方法的典型用法代码示例。如果您正苦于以下问题:C++ MDagModifier::createNode方法的具体用法?C++ MDagModifier::createNode怎么用?C++ MDagModifier::createNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDagModifier
的用法示例。
在下文中一共展示了MDagModifier::createNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doIt
MStatus DDConvexHullCmd::doIt(const MArgList& args)
{
if (args.length() != 1)
{
MGlobal::displayError("Needs at least 2 args");
return MS::kFailure;
}
MString input = args.asString(0);
MString output = args.asString(1);
// Get the mObject for the input
MSelectionList selList;
selList.add(input);
MDagPath inputMesh;
selList.getDagPath(0, inputMesh);
// Ensure we're looking at the shape
inputMesh.extendToShape();
// Create output object
MDagModifier dm;
MObject outMeshNode = dm.createNode(MFn::kMesh);
MFnDependencyNode outMeshDag(outMeshNode);
outMeshDag.setName("poopShape#");
DDConvexHullUtils::hullOpts hullOptions;
return DDConvexHullUtils::generateMayaHull(outMeshNode,
inputMesh.node(), hullOptions);
}
示例2: fnLoc
/* override */
MStatus
offset::accessoryNodeSetup(MDagModifier& cmd)
//
// Description:
// This method is called when the deformer is created by the
// "deformer" command. You can add to the cmds in the MDagModifier
// cmd in order to hook up any additional nodes that your node needs
// to operate.
//
// In this example, we create a locator and attach its matrix attribute
// to the matrix input on the offset node. The locator is used to
// set the direction and scale of the random field.
//
// Description:
// This method is optional.
//
{
MStatus result;
// hook up the accessory node
//
MObject objLoc = cmd.createNode(MString("locator"),
MObject::kNullObj,
&result);
if (MS::kSuccess == result) {
MFnDependencyNode fnLoc(objLoc);
MString attrName;
attrName.set("matrix");
MObject attrMat = fnLoc.attribute(attrName);
result = cmd.connect(objLoc,attrMat,this->thisMObject(),offset::offsetMatrix);
}
return result;
}
示例3: createJointFromLocation
MObject lrutils::createJointFromLocation(MVectorArray location, MString prefix, unsigned int num, MObject parent) {
MStatus status = MS::kFailure;
MObject jointObj;
//make joint object
MDagModifier dagMod;
jointObj = dagMod.createNode( "joint", MObject::kNullObj, &status );
MyCheckStatus(status, "MDagModifier.createNode() failed");
dagMod.doIt();
//set position
lrutils::setLocation(jointObj, location, MFnTransform::MFnTransform(), true, false, false);
//set name
MString jointName = prefix + "_Skel" + boost::lexical_cast<string>(num).c_str() + "_JNT";
dagMod.renameNode(jointObj, jointName);
dagMod.doIt();
MFnTransform jointFn(jointObj);
//parent the joint to its parent, if not null
if(parent != MObject::kNullObj) {
MFnTransform parentFn(parent);
MGlobal::executeCommand("parent " + jointFn.fullPathName() + " " + parentFn.fullPathName() + ";");
}
return jointObj;
}
示例4: TF_VERIFY
/* static */
bool
PxrUsdMayaTranslatorUtil::CreateNode(
const MString& nodeName,
const MString& nodeTypeName,
MObject& parentNode,
MStatus* status,
MObject* mayaNodeObj)
{
// XXX:
// Using MFnDagNode::create() results in nodes that are not properly
// registered with parent scene assemblies. For now, just massaging the
// transform code accordingly so that child scene assemblies properly post
// their edits to their parents-- if this is indeed the best pattern for
// this, all Maya*Reader node creation needs to be adjusted accordingly (for
// much less trivial cases like MFnMesh).
MDagModifier dagMod;
*mayaNodeObj = dagMod.createNode(nodeTypeName, parentNode, status);
CHECK_MSTATUS_AND_RETURN(*status, false);
*status = dagMod.renameNode(*mayaNodeObj, nodeName);
CHECK_MSTATUS_AND_RETURN(*status, false);
*status = dagMod.doIt();
CHECK_MSTATUS_AND_RETURN(*status, false);
return TF_VERIFY(not mayaNodeObj->isNull());
}
示例5: makeHomeNull
MStatus lrutils::makeHomeNull(MObject obj, MFnTransform& transformFn, MObject& groupObj) {
MStatus status = MS::kFailure;
status = transformFn.setObject(obj);
MyCheckStatusReturn(status, "invalid MObject provided for MFnTransform.setObject()");
if( status == MS::kSuccess ) {
MDagModifier dagMod;
groupObj = dagMod.createNode( "transform", MObject::kNullObj, &status );
MyCheckStatusReturn(status, "MDagModifier.createNode() failed");
dagMod.doIt();
MFnTransform groupFn;
groupFn.setObject(groupObj);
groupFn.set(transformFn.transformation());
groupFn.addChild(obj);
MString groupName = transformFn.name();
groupName = groupName.substring(0, groupName.numChars() - 4);
groupName += "GRP";
groupFn.setName(groupName);
}
return status;
}
示例6: cameraFn
/* static */
bool
UsdMayaTranslatorCamera::Read(
const UsdGeomCamera& usdCamera,
MObject parentNode,
const UsdMayaPrimReaderArgs& args,
UsdMayaPrimReaderContext* context)
{
if (!usdCamera) {
return false;
}
const UsdPrim& prim = usdCamera.GetPrim();
const SdfPath primPath = prim.GetPath();
MStatus status;
// Create the transform node for the camera.
MObject transformObj;
if (!UsdMayaTranslatorUtil::CreateTransformNode(prim,
parentNode,
args,
context,
&status,
&transformObj)) {
return false;
}
// Create the camera shape node.
MDagModifier dagMod;
MObject cameraObj = dagMod.createNode(_tokens->MayaCameraTypeName.GetText(),
transformObj,
&status);
CHECK_MSTATUS_AND_RETURN(status, false);
status = dagMod.doIt();
CHECK_MSTATUS_AND_RETURN(status, false);
TF_VERIFY(!cameraObj.isNull());
MFnCamera cameraFn(cameraObj, &status);
CHECK_MSTATUS_AND_RETURN(status, false);
const std::string cameraShapeName = prim.GetName().GetString() +
_tokens->MayaCameraShapeNameSuffix.GetString();
cameraFn.setName(cameraShapeName.c_str(), &status);
CHECK_MSTATUS_AND_RETURN(status, false);
if (context) {
const SdfPath shapePrimPath = primPath.AppendChild(TfToken(cameraShapeName));
context->RegisterNewMayaNode(shapePrimPath.GetString(), cameraObj);
}
return _ReadToCamera(usdCamera, cameraFn, args, context);
}
示例7: accessoryNodeSetup
MStatus SwirlDeformer::accessoryNodeSetup( MDagModifier &dagMod )
{
MStatus stat;
MObject locObj = dagMod.createNode( "locator", MObject::kNullObj, &stat );
if( !stat )
return stat;
dagMod.renameNode( locObj, "swirlHandle" );
MFnDependencyNode locFn( locObj );
MObject attrMat = locFn.attribute( "matrix" );
stat = dagMod.connect( locObj, attrMat, thisMObject(), deformSpace );
return stat;
}
示例8: makeGroup
MStatus lrutils::makeGroup(MObject & obj, MString name) {
MStatus status = MS::kFailure;
MDagModifier dagMod;
MObject groupObj = dagMod.createNode( "transform", MObject::kNullObj, &status );
MyCheckStatusReturn(status, "MDagModifier.createNode() failed");
dagMod.doIt();
MFnTransform groupFn;
groupFn.setObject(groupObj);
MString groupName = name;
groupName += "_GRP";
groupFn.setName(groupName);
obj = groupObj;
return status;
}
示例9: activate
//------------------------------------------------------------------------------
//
bool CacheRepresentation::activate()
{
AssemblyDefinition* const assembly =
dynamic_cast< AssemblyDefinition* >( getAssembly() );
if ( assembly == 0 ) {
return false;
}
// Create a gpuCache node, and parent it to our container.
MDagModifier dagMod;
MStatus status;
MObject cacheObj = dagMod.createNode(
MString("gpuCache"), assembly->thisMObject(), &status);
if (status != MStatus::kSuccess) {
int isLoaded = false;
// Validate that the gpuCache plugin is loaded.
MGlobal::executeCommand( "pluginInfo -query -loaded gpuCache", isLoaded );
if(!isLoaded){
MString errorString = MStringResource::getString(rCreateGPUCacheNodeError, status);
MGlobal::displayError(errorString);
}
return false;
}
status = dagMod.doIt();
if (status != MStatus::kSuccess) {
return false;
}
// Set the cache attribute to point to our Alembic file.
MFnDependencyNode cache(cacheObj);
MPlug fileName = cache.findPlug(MString("cacheFileName"), true, &status);
if (status != MStatus::kSuccess) {
return false;
}
fileName.setValue(assembly->getRepData(getName()));
return status == MStatus::kSuccess;
}
示例10: connectionFailedCallback
void atomImport::connectionFailedCallback(MPlug& srcPlug,
MPlug& dstPlug,
const MString& srcName,
const MString& dstName,
void* clientData)
{
// MString output = "Connection failed callback: ";
// output += srcName; output += " "; output += dstName;
// MGlobal::displayInfo(output);
atomEditsHelper* helper = (NULL != clientData) ? (atomEditsHelper*)clientData : NULL;
atomNodeNameReplacer* replacer = (NULL != helper) ? helper->fReplacer : NULL;
atomTemplateReader* templateReader = (NULL != helper) ? helper->fTemplateReader : NULL;
if (NULL != replacer && srcPlug.isNull()) {
// Import of the edits didn't find a match for the source name, use the
// replacer and see if that helps
//
if (replaceNameAndFindPlug(srcName,*replacer,srcPlug)) {
if (!dstPlug.isNull()) {
// we've found the proper source plug to use and we already
// had a dest, so connect them up and we're done
//
MDagModifier mod;
mod.connect(srcPlug,dstPlug);
return;
}
}
}
if (NULL != replacer && dstPlug.isNull()) {
// Import of the edits didn't find a match for the dest name, use the
// replacer and see if that helps
//
if (replaceNameAndFindPlug(dstName,*replacer,dstPlug)) {
MStringArray dstParts;
dstName.split('.', dstParts);
if (!checkPlugAgainstTemplate(dstParts[0],dstPlug,templateReader))
return;
if (!srcPlug.isNull()) {
// we've found the proper dest plug to use and we already
// had a source, so connect them up and we're done
//
MDagModifier mod;
mod.connect(srcPlug,dstPlug);
return;
}
}
}
if (!dstPlug.isNull()) {
MObject dstNode = dstPlug.node();
// Check whether the failed connection was to a setDrivenKey curve
//
if (dstNode.hasFn(MFn::kAnimCurveUnitlessToAngular) ||
dstNode.hasFn(MFn::kAnimCurveUnitlessToDistance) ||
dstNode.hasFn(MFn::kAnimCurveUnitlessToTime) ||
dstNode.hasFn(MFn::kAnimCurveUnitlessToUnitless)) {
// If so, create a stand-in driver for that curve
//
MDagModifier mod;
MObject locator = mod.createNode( "locator", MObject::kNullObj );
MFnDependencyNode fnLoc(locator);
MStringArray nameParts;
srcName.split('.', nameParts);
MString leafAttr(nameParts[nameParts.length()-1]);
MPlug leafPlug = fnLoc.findPlug(leafAttr);
if (!leafPlug.isNull()) {
mod.connect(leafPlug,dstPlug);
// rename the locator to the name of the original source
// so that any subsequent connections will work
//
fnLoc.setName(nameParts[0]);
}
}
}
}
示例11: doConversion
bool ToMayaLocatorConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const
{
ConstCoordinateSystemPtr coordSys = IECore::runTimeCast<const CoordinateSystem>( from );
if ( !coordSys )
{
IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "The source object is not an IECore::CoordinateSystem." );
return false;
}
// check if incoming object is a locator itself
MObject locatorObj;
if ( to.hasFn( MFn::kLocator ) )
{
locatorObj = to;
}
// check if incoming object is a parent of an existing locator
if ( locatorObj.isNull() )
{
MFnDagNode fnTo( to );
for ( unsigned i=0; i < fnTo.childCount(); ++i )
{
MObject child = fnTo.child( i );
if ( child.hasFn( MFn::kLocator ) )
{
locatorObj = child;
break;
}
}
}
// make a new locator and parent it to the incoming object
if ( locatorObj.isNull() )
{
if ( !MFnTransform().hasObj( to ) )
{
IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to create a locator as a child of the input object." );
return false;
}
MDagModifier dagMod;
locatorObj = dagMod.createNode( "locator", to );
dagMod.renameNode( locatorObj, coordSys->getName().c_str() );
if ( !dagMod.doIt() )
{
IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to modify the DAG correctly." );
dagMod.undoIt();
return false;
}
}
if ( locatorObj.isNull() )
{
IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion", "Unable to find or create a locator from the input object." );
return false;
}
MFnDagNode fnLocator( locatorObj );
Imath::M44f m = coordSys->getTransform()->transform();
Imath::V3f s,h,r,t;
Imath::extractSHRT(m, s, h, r, t);
/// obtain local position and scale from locator
MStatus st;
MPlug positionPlug = fnLocator.findPlug( "localPositionX", &st );
if ( !st ) return false;
positionPlug.setValue(t[0]);
positionPlug = fnLocator.findPlug( "localPositionY", &st );
if ( !st ) return false;
positionPlug.setValue(t[1]);
positionPlug = fnLocator.findPlug( "localPositionZ", &st );
if ( !st ) return false;
positionPlug.setValue(t[2]);
MPlug scalePlug = fnLocator.findPlug( "localScaleX", &st );
if ( !st ) return false;
scalePlug.setValue(s[0]);
scalePlug = fnLocator.findPlug( "localScaleY", &st );
if ( !st ) return false;
scalePlug.setValue(s[1]);
scalePlug = fnLocator.findPlug( "localScaleZ", &st );
if ( !st ) return false;
scalePlug.setValue(s[2]);
return true;
}