Beispiel #1
0
// to check if an object is animated, we need to check e.g. its transform inputs
// if the object is from an instancer node, always return true
bool MayaObject::isObjAnimated()
{
	MStatus stat;
	bool returnValue = false;
	
	if( this->instancerParticleId > -1)
		return true;

	if( this->mobject.hasFn(MFn::kTransform))
	{
		MFnDependencyNode depFn(this->mobject, &stat);
		if(stat)
		{
			MPlugArray connections;
			depFn.getConnections(connections);
			if( connections.length() == 0)
				returnValue = false;
			else{
				for( uint cId = 0; cId < connections.length(); cId++)
				{
					if( connections[cId].isDestination())
					{
						returnValue = true;
					}
				}
			}
			
		}
	}
	return returnValue;
}
Beispiel #2
0
MObject getConnectedInNode(const MObject& thisObject, const char *attrName)
{
    MObject result = MObject::kNullObj;
    MString indexStr, base;
    int index = -1;
    if (getArrayIndex(attrName, indexStr, base))
    {
        index = indexStr.asInt();
        attrName = base.asChar();
    }
    MFnDependencyNode depFn(thisObject);
    MPlug inPlug = depFn.findPlug(attrName);
    if (index > -1)
        inPlug = inPlug[index];
    MString plugname = inPlug.name();

    if (!inPlug.isConnected())
        return result;

    MPlugArray connectedPlugs;
    inPlug.connectedTo(connectedPlugs, true, false);
    if (connectedPlugs.length() == 0)
        return result;

    return connectedPlugs[0].node();
}
Beispiel #3
0
TheaSDK::Normal3D TheaRenderer::getSunDirection()
{
	MFnDependencyNode depFn(getRenderGlobalsNode());
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;
	std::shared_ptr<TheaRenderer> renderer = std::static_pointer_cast<TheaRenderer>(MayaTo::getWorldPtr()->worldRendererPtr);

	TheaSDK::Normal3D sunDir;

	MObjectArray nodeList;
	getConnectedInNodes(MString("sunLightConnection"), getRenderGlobalsNode(), nodeList);
	if( nodeList.length() > 0)	
	{
		MVector lightDir(0,0,1);
		MFnDagNode sunDagNode(nodeList[0]);
		//lightDir *= this->mtth_renderGlobals->globalConversionMatrix.inverse();
		lightDir *= sunDagNode.transformationMatrix();
		lightDir *= renderGlobals->globalConversionMatrix;
		lightDir.normalize();
		return TheaSDK::Normal3D(lightDir.x,lightDir.y,lightDir.z);
	}
	float sunDirX = 0.0f, sunDirY = 0.0f, sunDirZ = 1.0f;
	MPlug sunDirPlug = depFn.findPlug("sunDirection");
	if (!sunDirPlug.isNull())
	{
		sunDirX = sunDirPlug.child(0).asFloat();
		sunDirY = sunDirPlug.child(1).asFloat();
		sunDirZ = sunDirPlug.child(2).asFloat();
	}
	return TheaSDK::Normal3D(sunDirX, sunDirY, sunDirZ);
}
Beispiel #4
0
SkyMap::SkyMap(MObject sObject)
{
	MFnDependencyNode depFn(sObject);

	this->params = new Corona::SkyParams;

	params->multiplier = getFloatAttr("pSkyMultiplier", depFn, 1.0);
	int skyModel = getEnumInt("pSkyModel", depFn);
	if (skyModel == 0)
		params->mode = Corona::SkyModelType::MODEL_PREETHAM;
	if (skyModel == 1)
		params->mode = Corona::SkyModelType::MODEL_RAWAFAKE;
	if (skyModel == 2)
		params->mode = Corona::SkyModelType::MODEL_HOSEK;
	params->groundColor = toCorona(getColorAttr("pSkyGroundColor", depFn));
	params->horizonBlur = getFloatAttr("pSkyHorizBlur", depFn, .1f);
	params->skyAffectGround = getBoolAttr("pSkyAffectGround", depFn, true);
	params->preetham.turbidity = getFloatAttr("pSkyPreethamTurb", depFn, 2.5f);
	params->rawafake.horizon = toCorona(getColorAttr("pSkyHorizon", depFn));
	params->rawafake.horizon = toCorona(getColorAttr("pSkyZenith", depFn));
	params->rawafake.sunBleed = getFloatAttr("pSkySunBleed", depFn, 1.0f);
	params->rawafake.sunFalloff = getFloatAttr("pSkySunFalloff", depFn, 3.0f);
	params->rawafake.sunGlow = getFloatAttr("pSkySunGlow", depFn, 1.0f);
	params->rawafake.sunSideGlow = getFloatAttr("pSkySunSideGlow", depFn, .2f);

	this->initSky();
};
void addVisibilityFlags(boost::shared_ptr<MayaObject> obj, renderer::ParamArray& paramArray)
{
    MFnDependencyNode depFn(obj->mobject);

    if (obj->mobject.hasFn(MFn::kMesh) || obj->mobject.hasFn(MFn::kAreaLight))
    {
        if (!getBoolAttr("primaryVisibility", depFn, true))
            paramArray.insert_path("visibility.camera", false);

        if (!getBoolAttr("castsShadows", depFn, true))
            paramArray.insert_path("visibility.shadow", false);

        if (!getBoolAttr("visibleInRefractions", depFn, true))
            paramArray.insert_path("visibility.transparency", false);

        if (!getBoolAttr("mtap_visibleLights", depFn, true))
            paramArray.insert_path("visibility.light", false);

        if (!getBoolAttr("mtap_visibleProbe", depFn, true))
            paramArray.insert_path("visibility.probe", false);

        if (!getBoolAttr("mtap_visibleGlossy", depFn, true))
            paramArray.insert_path("visibility.glossy", false);

        if (!getBoolAttr("mtap_visibleSpecular", depFn, true))
            paramArray.insert_path("visibility.specular", false);

        if (!getBoolAttr("mtap_visibleDiffuse", depFn, true))
            paramArray.insert_path("visibility.diffuse", false);
    }
}
Beispiel #6
0
void TheaRenderer::defineIBLNode(TheaSDK::XML::EnvironmentOptions::IBLMap& iblMap, const char *attName)
{
	MFnDependencyNode depFn(getRenderGlobalsNode());
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;
	std::shared_ptr<TheaRenderer> renderer = std::static_pointer_cast<TheaRenderer>(MayaTo::getWorldPtr()->worldRendererPtr);

	MObject fileNodeObject = getConnectedFileTextureObject(MString(attName), depFn);
	if(fileNodeObject != MObject::kNullObj)
	{
		MFnDependencyNode fileNode(fileNodeObject);
		MString fileName;
		getString(MString("fileTextureName"), fileNode, fileName); 
		if( fileName.length() > 1)
		{	
			iblMap.bitmapFilename = fileName.asChar();
			float intensity = 0.0f, rotation = 0.0f;
			getFloat("mtth_file_iblIntensity", fileNode, intensity);
			iblMap.intensity = intensity;
			getFloat("mtth_file_iblRotation", fileNode, rotation);
			iblMap.rotation = rotation;
			int wrapping = 0;
			getEnum(MString("mtth_file_iblWrapping"), fileNode, wrapping);
			iblMap.wrapping = (TheaSDK::IBLWrapping)wrapping;
			iblMap.enabled = true;
			return;
		}
	}
	iblMap.enabled = false;
}
Beispiel #7
0
void CoronaRenderer::defineColorMapping()
{
	float gamma = 2.2f;
#if MAYA_API_VERSION > 2015
	if (MColorManagementUtilities::isColorManagementEnabled())
		gamma = 1.0f;
#endif
	MFnDependencyNode depFn(getRenderGlobalsNode());
	context.colorMappingData->colorTemperature = getFloatAttr("colorMapping_colorTemperature", depFn, 6500.0f);
	context.colorMappingData->contrast = getFloatAttr("colorMapping_contrast", depFn, 1.0f);
	context.colorMappingData->gamma = gamma;
	context.colorMappingData->tint = toCorona(getColorAttr("colorMapping_tint", depFn));
	context.colorMappingData->exposure.simple.exponent = getFloatAttr("colorMapping_simpleExposure", depFn, 0.0f);
	context.colorMappingData->highlightCompression = getFloatAttr("colorMapping_highlightCompression", depFn, 1.0f);
	context.colorMappingData->photographicExposure = getEnumInt("exposure_type", depFn) == 1;

	// release 0.39 override camera settings
	if (context.colorMappingData->photographicExposure)
	{
		context.colorMappingData->exposure.photographic.fStop = getFloatAttr("colorMapping_fStop", depFn, 5.6);
		context.colorMappingData->exposure.photographic.iso = getFloatAttr("colorMapping_iso", depFn, 100.0);
		context.colorMappingData->exposure.photographic.shutterSpeed = 1.0f / getFloatAttr("colorMapping_shutterSpeed", depFn, 250.0f);

		if ( this->renderCam != MObject::kNullObj)
		{
			MFnDependencyNode camFn(renderCam);
			if (getBoolAttr("mtco_overrideRenderSettings", camFn, false))
			{
				context.settings->set(Corona::PARAM_COLORMAP_ISO, getFloatAttr("mtco_iso", camFn, 1.0));
				context.settings->set(Corona::PARAM_COLORMAP_F_STOP, getFloatAttr("fStop", camFn, 5.6));
				context.settings->set(Corona::PARAM_COLORMAP_SHUTTER_SPEED, 1.0f / getFloatAttr("mtco_shutterSpeed", camFn, 250.0f));
			}
		}
	}
}
Beispiel #8
0
bool MayaObject::isGeo()
{

	if( this->mobject.hasFn(MFn::kMesh))
		return true;
	if( this->mobject.hasFn(MFn::kNurbsSurface))
		return true;
	if( this->mobject.hasFn(MFn::kParticle))
		return true;
	if( this->mobject.hasFn(MFn::kSubSurface))
		return true;
	if( this->mobject.hasFn(MFn::kNurbsCurve))
		return true;
	if( this->mobject.hasFn(MFn::kHairSystem))
		return true;

	MFnDependencyNode depFn(this->mobject);
	uint nodeId = depFn.typeId().id();
	for( uint lId = 0; lId < objectIdentifier.size(); lId++)
	{
		if( nodeId == objectIdentifier[lId])
		{
			Logging::debug(MString("Found external geotype: ") + depFn.name());
			return true;
		}
	}
	return false;
}
Beispiel #9
0
void ShadingNode::getConnectedInputObjects(MObjectArray& objectArray)
{
	MStatus stat;
	MFnDependencyNode depFn(this->mobject);
	MStringArray aliasArray;
	depFn.getAliasList(aliasArray);
	MObjectArray objectList;
	MPlugArray connections;
	depFn.getConnections(connections);

	for (uint connId = 0; connId < connections.length(); connId++)
	{
		MPlug p = connections[connId];
		if (!p.isDestination())
			continue;
		
		// a connection can be a direct connection or a child connection e.g. colorR, colorG...
		// but in a shader description file only the main attribute is listed so we go up until we have the main plug
		MPlug mainPlug = p;
		while (mainPlug.isChild())
			mainPlug = mainPlug.parent();
		if (mainPlug.isElement())
			mainPlug = mainPlug.array();
		MStringArray stringArray;
		// name contains node.attributeName, so we have to get rid of the nodeName
		mainPlug.name().split('.', stringArray);
		MString plugName = stringArray[stringArray.length() - 1];
		if (!this->isAttributeValid(plugName))
			continue;
		getConnectedInNodes(p, objectList);
		makeUniqueArray(objectList);
	}
	objectArray = objectList;
}
Beispiel #10
0
bool ShadingNode::isAttributeValid(MString attributeName)
{
	MStatus stat;
	MFnDependencyNode depFn(this->mobject);
	MPlugArray pa;
	depFn.getConnections(pa);
	for (uint pId = 0; pId < pa.length(); pId++)
	{
		if (pa[pId].isDestination())
		{
			MPlug parentPlug = pa[pId];
			while (parentPlug.isChild())
				parentPlug = parentPlug.parent();
			MString plugName = getAttributeNameFromPlug(parentPlug);
			if (plugName == attributeName)
			{
				for (size_t inattrId = 0; inattrId < this->inputAttributes.size(); inattrId++)
				{
					if (attributeName == inputAttributes[inattrId].name.c_str())
						return true;
				}
			}
		}
	}

	return false;
}
Beispiel #11
0
MObject getOtherSideSourceNode(MString& plugName, MObject& thisObject, bool checkChildren, MString& outPlugName)
{
	MStatus stat;
	MObject result = MObject::kNullObj;
	MFnDependencyNode depFn(thisObject, &stat);	if (stat != MStatus::kSuccess) return result;
	MPlugArray pa;
	depFn.getConnections(pa);
	MPlug connectedPlug;
	for (uint pId = 0; pId < pa.length(); pId++)
	{
		MPlug plug = pa[pId];
		if (!plug.isDestination())
			continue;
		while (plug.isChild())
		{
			plug = plug.parent();
		}
		if (getAttributeNameFromPlug(plug) == plugName)
		{
			connectedPlug = pa[pId];
		}
	}
	if (connectedPlug.isNull())
		return result;
	connectedPlug.connectedTo(pa, true, false, &stat); if (stat != MStatus::kSuccess) return result;
	if (pa.length() == 0)
		return result;
	MPlug otherSidePlug = pa[0];
	result = otherSidePlug.node();
	outPlugName = getAttributeNameFromPlug(otherSidePlug);
	if (otherSidePlug.isChild())
		outPlugName = getAttributeNameFromPlug(otherSidePlug.parent());
	return result;
}
Beispiel #12
0
void LuxRenderer::createAreaLightMesh(mtlu_MayaObject *obj)
{
	MString meshName("");
	MFnDependencyNode depFn(obj->mobject);
	MObject otherSideObj = getOtherSideNode(MString("mtlu_areaLight_geo"), obj->mobject);
	if( otherSideObj != MObject::kNullObj)
	{


	}else{
		int indices[6] = {0,1,2,2,3,0};
		float floatPointArray[12] = {-1, -1, 0,
									 -1,  1, 0,
									  1,  1, 0,
									  1, -1, 0};

		float floatNormalArray[12] = {0,0,-1,
									  0,0,-1,
									  0,0,-1,
									  0,0,-1};

		ParamSet triParams = CreateParamSet();
		triParams->AddInt("indices", indices, 6);
		triParams->AddPoint("P", floatPointArray, 4);
		triParams->AddNormal("N", floatNormalArray, 4);
		
		lux->transformBegin();
		float fm[16];
		MMatrix tm = obj->transformMatrices[0];
		setZUp(tm, fm);
		this->lux->transform(fm);
		this->lux->shape("trianglemesh", boost::get_pointer(triParams));
		lux->transformEnd();
	}
}
Beispiel #13
0
MObject getConnectedShadingEngine(MObject node)
{
	MObject se = MObject::kNullObj;

	MFnDependencyNode depFn(node);
	MPlugArray plugArray;
	depFn.getConnections(plugArray);
	for( uint i = 0; i < plugArray.length(); i++)
	{
		if( plugArray[i].isSource() )
		{
			MPlugArray desArray;
			plugArray[i].connectedTo(desArray, false, true);
			for(uint k = 0; k < desArray.length(); k++)
			{
				if( desArray[k].node().hasFn(MFn::kShadingEngine))
				{
					se = desArray[k].node();
				}
			}
		}
	}

	return se;
}
Beispiel #14
0
// to check if shape is connected, simply test for the common shape inputs, nurbs: create mesh: inMesh
bool MayaObject::isShapeConnected()
{
	MStatus stat;
	bool returnValue = false;
	MPlug inPlug;
	MFnDependencyNode depFn(this->mobject, &stat);
	if(stat)
	{
		MFn::Type type = this->mobject.apiType();
		switch(type)
		{
		case MFn::kMesh:
			inPlug = depFn.findPlug(MString("inMesh"), &stat);
			if( stat)
				if( inPlug.isConnected())
					returnValue = true;
			break;
		case MFn::kNurbsSurface:
			inPlug = depFn.findPlug(MString("create"), &stat);
			if( stat)
				if( inPlug.isConnected())
					returnValue = true;
			break;
		case MFn::kNurbsCurve:
			inPlug = depFn.findPlug(MString("create"), &stat);
			if( stat)
				if( inPlug.isConnected())
					returnValue = true;
			break;
		}
	}

	return returnValue;
}
Beispiel #15
0
bool
MayaPrimWriter::writePrimAttrs(const MDagPath &dagT, const UsdTimeCode &usdTime, UsdGeomImageable &primSchema) 
{
    MStatus status;
    MFnDependencyNode depFn(getDagPath().node());
    MFnDependencyNode depFn2(dagT.node()); // optionally also scan a shape's transform if merging transforms

    if (getArgs().exportVisibility) {
        bool isVisible  = true;   // if BOTH shape or xform is animated, then visible
        bool isAnimated = false;  // if either shape or xform is animated, then animated

        PxrUsdMayaUtil::getPlugValue(depFn, "visibility", &isVisible, &isAnimated);

        if ( dagT.isValid() ) {
            bool isVis, isAnim;
            if (PxrUsdMayaUtil::getPlugValue(depFn2, "visibility", &isVis, &isAnim)){
                isVisible = isVisible and isVis;
                isAnimated = isAnimated or isAnim;
            }
        }

        TfToken const &visibilityTok = (isVisible ? UsdGeomTokens->inherited : 
                                        UsdGeomTokens->invisible);
        if (usdTime.IsDefault() != isAnimated ) {
            if (usdTime.IsDefault())
                primSchema.CreateVisibilityAttr(VtValue(visibilityTok), true);
            else
                primSchema.CreateVisibilityAttr().Set(visibilityTok, usdTime);
        }
    }

    UsdPrim usdPrim = primSchema.GetPrim();

    // There is no Gprim abstraction in this module, so process the few
    // gprim attrs here.
    UsdGeomGprim gprim = UsdGeomGprim(usdPrim);
    if (gprim and usdTime.IsDefault()){

        PxrUsdMayaPrimWriterContext* unused = NULL;
        PxrUsdMayaTranslatorGprim::Write(
                getDagPath().node(),
                gprim,
                unused);

    }

    _writeUsdInfo(dagT, usdTime, usdPrim);
    
    // Write user-tagged export attributes. Write attributes on the transform
    // first, and then attributes on the shape node. This means that attribute
    // name collisions will always be handled by taking the shape node's value
    // if we're merging transforms and shapes.
    if (dagT.isValid() and !(dagT == getDagPath())) {
        PxrUsdMayaWriteUtil::WriteUserExportedAttributes(dagT, usdPrim, usdTime);
    }
    PxrUsdMayaWriteUtil::WriteUserExportedAttributes(getDagPath(), usdPrim, usdTime);

    return true;
}
Beispiel #16
0
MString getObjectName(const MObject& mobject)
{
    if (mobject == MObject::kNullObj)
        return "";

    MFnDependencyNode depFn(mobject);
    return depFn.name();
}
Beispiel #17
0
bool hasPlug(MObject& thisObject, MString& plugName)
{
	MStatus stat;
	MFnDependencyNode depFn(thisObject, &stat);	if( stat != MStatus::kSuccess) return false;
	MPlug plug = depFn.findPlug(plugName, &stat);	
	if( stat != MStatus::kSuccess) 
		return false;
	else
		return true;
	return false;
}
void 
_WritePrefixedAttrs(
        const UsdTimeCode &usdTime, 
        const _PrimEntry& entry)
{
    MStatus status;
    MFnDependencyNode depFn(entry.mayaDagPath.node());
    for (const auto& attrEntry : entry.attrs) {
        MPlug plg = depFn.findPlug(attrEntry.mayaAttributeName.c_str(), true);
        UsdAttribute usdAttr;

        if (attrEntry.isPrimvar) {
            // Treat as custom primvar.
            TfToken interpolation = _GetPrimvarInterpolation(
                    depFn, attrEntry.mayaAttributeName);
            UsdGeomImageable imageable(entry.usdPrim);
            if (!imageable) {
                TF_RUNTIME_ERROR(
                        "Cannot create primvar for non-UsdGeomImageable "
                        "USD prim <%s>",
                        entry.usdPrim.GetPath().GetText());
                continue;
            }
            UsdGeomPrimvar primvar = UsdMayaWriteUtil::GetOrCreatePrimvar(
                    plg,
                    imageable,
                    attrEntry.usdAttributeName,
                    interpolation,
                    -1,
                    false);
            if (primvar) {
                usdAttr = primvar.GetAttr();
            }
        }
        else {
            // Treat as custom attribute.
            usdAttr = UsdMayaWriteUtil::GetOrCreateUsdAttr(
                    plg, entry.usdPrim, attrEntry.usdAttributeName, true);
        }

        if (usdAttr) {
            UsdMayaWriteUtil::SetUsdAttr(plg, usdAttr, usdTime);
        }
        else {
            TF_RUNTIME_ERROR(
                    "Could not create attribute '%s' for "
                    "USD prim <%s>",
                    attrEntry.usdAttributeName.c_str(),
                    entry.usdPrim.GetPath().GetText());
            continue;
        }
    }
}
Beispiel #19
0
RoundCorners::RoundCorners(MObject shaderObject)
{
	MFnDependencyNode depFn(shaderObject);
	radius = getFloatAttr("radius", depFn, 0.0f);
	samplesCount = getIntAttr("samples", depFn, 10);
	float globalScaleFactor = 1.0f;
	if (MayaTo::getWorldPtr()->worldRenderGlobalsPtr != nullptr)
		globalScaleFactor = MayaTo::getWorldPtr()->worldRenderGlobalsPtr->scaleFactor;
	else
		globalScaleFactor = MayaTo::getWorldPtr()->scaleFactor;
	radius *= globalScaleFactor;
};
Beispiel #20
0
bool getConnectedOutPlugs(MObject& thisObject, MPlugArray& outPlugs)
{
	MStatus stat;
	bool result = false;
	MFnDependencyNode depFn(thisObject, &stat);	if( stat != MStatus::kSuccess) return result;
	MPlugArray pa;
	depFn.getConnections(pa);
	for( uint i = 0; i < pa.length(); i++)
		if( pa[i].isSource() )
			outPlugs.append(pa[i]);

	return true;
}
Beispiel #21
0
bool getOtherSidePlugName(MString& plugName, MObject& thisObject, MString& otherSidePlugName)
{
	MStatus stat;
	MFnDependencyNode depFn(thisObject, &stat);	if( stat != MStatus::kSuccess) return false;
	MPlug plug = depFn.findPlug(plugName, &stat);	if( stat != MStatus::kSuccess) return false;
	MPlugArray plugArray;
	plug.connectedTo(plugArray, 1, 0, &stat);if( stat != MStatus::kSuccess) return false;
	if( plugArray.length() == 0)
		return false;
	MPlug otherSidePlug = plugArray[0];
	otherSidePlugName = otherSidePlug.name();
	return true;
}
Beispiel #22
0
bool getConnectedFileTexturePath(MString& plugName, MString& nodeName, MString& value, MObject& outFileNode)
{
	MStatus stat;
	MObject obj = objectFromName(nodeName);
	if( obj == MObject::kNullObj)
		return false;

	MFnDependencyNode depFn(obj);
	MPlug plug = depFn.findPlug(plugName, &stat);
	if( !stat )
		return false;
	
	//MGlobal::displayInfo(MString("is plug connected: ") + plug.name());
	if( !plug.isConnected())
	{
		//MGlobal::displayInfo(MString("plug is NOT connected: ") + plug.name());
		return false;
	}
	MPlugArray parray;
	plug.connectedTo(parray, true, false, &stat);
	if( !stat )
		return false;

	if( parray.length() == 0 )
		return false;

	MPlug destPlug = parray[0];
	MObject fileNode = destPlug.node();
	std::cout << "filenode: " << getObjectName(fileNode).asChar() << " plug name " << destPlug.name() << "\n";
	
	if( !fileNode.hasFn(MFn::kFileTexture) )
	{
		std::cout << "node is not from type fileTexture.\n";
		return false;
	}

	MFnDependencyNode fileDepFn(fileNode);
	MPlug ftn = fileDepFn.findPlug("fileTextureName", &stat);

	if(!stat)
	{
		std::cout << "fileTextureName not found at fileTexNode.\n";
		return false;
	}
	
	MString fileTextureName = ftn.asString();
	std::cout << "fileTextureName value: " << fileTextureName.asChar() <<"\n";
	value = fileTextureName;
	outFileNode = fileNode;
	return true;
}
Beispiel #23
0
//
// simply get the node wich is connected to the named plug.
// If we have no connection, a kNullObject is returned.
//
MObject getOtherSideNode(MString& plugName, MObject& thisObject)
{
	MStatus stat;
	MObject result = MObject::kNullObj;
	MFnDependencyNode depFn(thisObject, &stat);	if( stat != MStatus::kSuccess) return result;
	MPlug plug = depFn.findPlug(plugName, &stat);	if( stat != MStatus::kSuccess) return result;
	MPlugArray plugArray;
	plug.connectedTo(plugArray, 1, 0, &stat);if( stat != MStatus::kSuccess) return result;
	if( plugArray.length() == 0)
		return result;
	MPlug otherSidePlug = plugArray[0];
	result = otherSidePlug.node();
	return result;
}
Beispiel #24
0
MObject getConnectedInNode(MObject& thisObject, const char *attrName)
{
	MObject result = MObject::kNullObj;
	MFnDependencyNode depFn(thisObject);
	MPlug inPlug = depFn.findPlug(attrName);
	if( !inPlug.isConnected())
		return result;

	MPlugArray connectedPlugs;
	inPlug.connectedTo(connectedPlugs, true, false);
	if( connectedPlugs.length() == 0)
		return result;
	
	return connectedPlugs[0].node();
}
Beispiel #25
0
bool getConnectedPlugs(MString& plugName, MObject& thisObject, MPlug& inPlug, MPlug& outPlug)
{
	MStatus stat;
	bool result = false;
	MFnDependencyNode depFn(thisObject, &stat);	if( stat != MStatus::kSuccess) return result;
	MPlug plug = depFn.findPlug(plugName, &stat);	if( stat != MStatus::kSuccess) return result;
	MPlugArray plugArray;
	plug.connectedTo(plugArray, 1, 0, &stat);if( stat != MStatus::kSuccess) return result;
	if( plugArray.length() == 0)
		return result;
	MPlug otherSidePlug = plugArray[0];
	inPlug = plug;
	outPlug = otherSidePlug;
	return true;
}
Beispiel #26
0
void findConnectedNodeTypes(uint nodeId, MObject thisObject, MObjectArray& connectedElements, MPlugArray& completeList, bool upstream)
{

	MGlobal::displayInfo(MString("thisNode: ") + getObjectName(thisObject));

	MString name = getObjectName(thisObject);

	MFnDependencyNode depFn(thisObject);
	if(depFn.typeId().id() == nodeId)
	{
		connectedElements.append(thisObject);
		MGlobal::displayInfo(MString("found object with correct id: ") + depFn.name());
		return;
	}

	bool downstream = !upstream;

	MPlugArray plugArray;
	depFn.getConnections(plugArray);

	int numc = plugArray.length();

	for( uint plugId = 0; plugId < plugArray.length(); plugId++)
	{
		MPlug plug = plugArray[plugId];
		if( isPlugInList(plug, completeList))
			continue;

		completeList.append(plug);

		MString pn = plug.name();
		if( upstream && plug.isDestination())
			continue;
		if( downstream && plug.isSource())
			continue;
		
		MPlugArray otherSidePlugs;
		bool asDest = plug.isDestination();
		bool asSrc = plug.isSource();
		MGlobal::displayInfo(MString("findConnectedNodeTypes: checking plug ") + plug.name());
		plug.connectedTo(otherSidePlugs, asDest, asSrc);
		for( uint cplugId = 0; cplugId < otherSidePlugs.length(); cplugId++)
		{
			findConnectedNodeTypes(nodeId, otherSidePlugs[cplugId].node(), connectedElements, completeList, upstream);
		}		
	}

}
void CoronaRenderer::setRenderStats(Corona::IMaterialSet& ms, std::shared_ptr<MayaObject> obj)
{
	MFnDependencyNode depFn(obj->mobject);

	if (!getBoolAttr("primaryVisibility", depFn, true))
		ms.visibility.direct = false;

	if (!getBoolAttr("visibleInReflections", depFn, true))
		ms.visibility.reflect = false;

	if (!getBoolAttr("visibleInRefractions", depFn, true))
		ms.visibility.refract = false;

	if (!getBoolAttr("mtco_visibleInGI", depFn, true))
		ms.visibility.normal = false;
}
Beispiel #28
0
bool MayaObject::isLight()
{
	if( this->mobject.hasFn(MFn::kLight))
		return true;
	MFnDependencyNode depFn(this->mobject);
	uint nodeId = depFn.typeId().id();
	for( uint lId = 0; lId < lightIdentifier.size(); lId++)
	{
		if( nodeId == lightIdentifier[lId])
		{
			Logging::debug(MString("Found external lighttype: ") + depFn.name());
			return true;
		}
	}
	return false;
}
Beispiel #29
0
bool IsTemplated(MFnDagNode& node)
{
    MStatus status;

    MFnDependencyNode depFn(node.object());
    bool isTemplate = false;
    getBool(MString("template"), depFn, isTemplate);
    if (isTemplate)
        return true;
    int intTempl = 0;
    getInt(MString("overrideDisplayType"), depFn, intTempl);
    if (intTempl == 1)
        return true;

    return false;
}
// #### updateAttributes
//
//      Called by openSubdivShaderOverride in updateDG.
//      Pulls values for all non-internal attributes.
//
void
OpenSubdivShader::updateAttributes() 
{
    MObject object = thisMObject();
    MFnDependencyNode depFn(object);

    // Retrieve non-internal attributes
    _diffuse = getColor(object, aDiffuse);
    _ambient = getColor(object, aAmbient);
    _specular = getColor(object, aSpecular);

    getAttribute(object, aWireframe, &_wireframe);
    getAttribute(object, aShininess, &_shininess);

    // Pull on any plugs that might be connected
    getAttribute(object, aDiffuseMapFile, &_diffuseMapFile);
}