void lrutils::createFKCtlFromLocation(MVectorArray location, MObject joint, MString prefix, unsigned int num, MString icon, MString color, MObject parent, MObject& fkCtlObj, MObject& fkCtlGroupObj, MString layerName, MObject metaDataNode) {
    MStatus status;
    MDGModifier dgMod;
    //used for holding results from executed commands
    MStringArray result;
    MFnDependencyNode depMetaDataNodeFn(metaDataNode);
    //used for creating metaParent attributes for objects
    MFnMessageAttribute mAttr;
    MFnTransform jointFn(joint);
    
    //create the control object and set its color
    status = MGlobal::executeCommand( "python(\"control = rig101().rig101WCGetByName('" + icon + "')\");" );
    status = MGlobal::executeCommand( "python(\"Utils.setControllerColor(control, '" + color + "')\");" );
    status = MGlobal::executeCommand( MString("python(\"control.fullPath()\");"), result );
    //get the MObject for the controller
    status = lrutils::getObjFromName(result[0], fkCtlObj);
    MyCheckStatus(status, "lrutils::getObjFromName() failed");
    MFnTransform fkCtlFn( fkCtlObj );
    lrutils::setLocation(fkCtlObj, location, MFnTransform::MFnTransform(), false, false, true);
    //set controller name
    MString fkCtlName = prefix + "_FK_"+num+"_CTL";
    dgMod.renameNode(fkCtlObj, fkCtlName);
    //add the metaParent attribute to the controller
    MObject controlAttr = mAttr.create("metaParent", "metaParent");
    fkCtlFn.addAttribute(controlAttr);
    //connect the controller's metaParent to the MDSpine node
    status = dgMod.connect( depMetaDataNodeFn.findPlug("FKControllers"), fkCtlFn.findPlug("metaParent") );
    dgMod.doIt();
    
    //create the fk control null
    lrutils::makeHomeNull(fkCtlObj, MFnTransform(), fkCtlGroupObj);
    lrutils::setLocation(fkCtlGroupObj, location, MFnTransform::MFnTransform(), true, true, false);
    MFnTransform fkCtlGroupFn( fkCtlGroupObj );
    if(!parent.isNull()) {
        MFnTransform parentFn(parent);
        MGlobal::executeCommand("parent " + fkCtlGroupFn.fullPathName() + " " + parentFn.fullPathName() + ";");
    }
    //add the metaParent attribute to the controller group
    fkCtlGroupFn.addAttribute(mAttr.create("metaParent", "metaParent"));
    //connect the controller group's metaParent to the MDGlobal node
    status = dgMod.connect( depMetaDataNodeFn.findPlug("FKControllerGroups"), fkCtlGroupFn.findPlug("metaParent") );
    MyCheckStatus(status, "connect failed"); 
    dgMod.doIt();

    MGlobal::executeCommand("parentConstraint -mo " + fkCtlFn.fullPathName() + " " + jointFn.fullPathName() + ";",result);
    MObject jointParentConstraintObj;
    status = lrutils::getObjFromName(result[0], jointParentConstraintObj);
    MyCheckStatus(status, "lrutils::getObjFromName() failed");
    MFnTransform jointParentConstraintFn(jointParentConstraintObj);
    jointParentConstraintFn.addAttribute(mAttr.create("metaParent", "metaParent"));
    status = dgMod.connect( depMetaDataNodeFn.findPlug("FKJointParentConstraints"), jointParentConstraintFn.findPlug("metaParent"));
    dgMod.doIt();

    //set the display layers for the controller and controller group
    MGlobal::executeCommand("editDisplayLayerMembers -noRecurse "+ layerName+" "+ fkCtlFn.fullPathName()+";");
    MGlobal::executeCommand("editDisplayLayerMembers -noRecurse "+ layerName+" "+ fkCtlGroupFn.fullPathName()+";");
    MGlobal::executeCommand("select -cl;");
}
Пример #2
0
MStatus EntityNode::Initialize()
{
    MAYA_START_EXCEPTION_HANDLING();

    MStatus stat;

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // Create a string attribute "ArtFilePath" 
    MFnTypedAttribute tAttr;

    s_ArtFilePath = tAttr.create("ArtFilePath", "afp", MFnData::kString, &stat);
    MCheckErr(stat, "Unable to create attr: ArtFilePath");

    tAttr.setReadable(true);
    tAttr.setWritable(false);

    stat = addAttribute(s_ArtFilePath);
    MCheckErr(stat, "Unable to add attr: ArtFilePath");

    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // Create an array attribute "ImportNodes"
    MFnMessageAttribute mAttr;

    m_ImportNodes = mAttr.create( "ImortObjects", "ios", &stat );
    MCheckErr(stat, "Unable to create attr: ImportNodes");

    mAttr.setArray( true );

    stat = addAttribute(m_ImportNodes);
    MCheckErr(stat, "Unable to add attr: ImportNodes");

    MAYA_FINISH_EXCEPTION_HANDLING();

    return MS::kSuccess;
}
Пример #3
0
MStatus inverseSkinCluster::initialize()
{
	MStatus   status;

	MFnNumericAttribute nAttr;
	MFnMatrixAttribute mAttr;
	MFnMessageAttribute msgAttr;
	MFnTypedAttribute tAttr;

	aInMesh = tAttr.create( "inMesh", "inMesh", MFnData::kMesh );
	tAttr.setStorable( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInMesh ) );

	aGeomMatrix = mAttr.create( "geomMatrix", "geomMatrix" );
	tAttr.setCached( false );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGeomMatrix ) );

	aMatrix = mAttr.create( "matrix", "matrix" );
	mAttr.setArray( true );
	mAttr.setStorable( true );
	mAttr.setUsesArrayDataBuilder( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aMatrix ) );

	aBindPreMatrix = mAttr.create( "bindPreMatrix", "bindPreMatrix" );
	mAttr.setArray( true );
	mAttr.setStorable( true );
	mAttr.setUsesArrayDataBuilder( true );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aBindPreMatrix ) );

	aUpdateMatrix = nAttr.create( "updateMatrix", "updateMatrix", MFnNumericData::kBoolean, false );
	nAttr.setStorable( false );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aUpdateMatrix ) );

	aTargetSkinCluster = msgAttr.create( "targetSkinCluster", "targetSkinCluster" );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aTargetSkinCluster ) );

	aUpdateWeightList = nAttr.create( "updateWeightList", "updateWeightList", MFnNumericData::kBoolean, false );
	nAttr.setStorable( false );
	CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aUpdateWeightList ) );

	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInMesh, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGeomMatrix, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aMatrix, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aBindPreMatrix, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aUpdateMatrix, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aUpdateWeightList, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aTargetSkinCluster, outputGeom ) );
	CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aMatrix, outputGeom ) );

	return MS::kSuccess;
}
std::vector<MObject> lrutils::buildSkeletonFromGuide(std::vector<MVectorArray> locations, MString prefix, MPlug metaDataPlug, MObject metaParentJoint, MString layerName) {
    MDGModifier dgMod;
    MStatus status;
    std::vector<MObject> joints;
    MFnMessageAttribute mAttr;

    MObject parentJoint;
    unsigned int jointNum = 0;

    for (std::vector<MVectorArray>::iterator it = locations.begin(); it != locations.end(); ++it) {
        MVectorArray location = *it;
        MObject joint = createJointFromLocation(location, prefix, jointNum, parentJoint);
        joints.push_back(joint);

        MFnTransform jointFn( joint );
        //add metaParent attributes to joint
        if(!metaDataPlug.isNull()) {
            MObject jointAttr = mAttr.create("metaParent", "metaParent");
            jointFn.addAttribute(jointAttr);
            //connect the metaparent attribute to the MDSpine node
            status = dgMod.connect( metaDataPlug, jointFn.findPlug("metaParent") );
            MyCheckStatus(status, "connect failed");
            dgMod.doIt();
        }

        //if layer name is provided, add the joint to that display layer
        if(layerName != "") {
            MGlobal::executeCommand("editDisplayLayerMembers -noRecurse "+ layerName+" "+ jointFn.name()+";");
        }

        parentJoint = joint;
        jointNum++;
    }
    //orient the joint chain
    MFnTransform topJointFn(joints.at(0));
    MGlobal::executeCommand("joint -e -zso -oj \"xyz\" -sao \"yup\" -ch " + topJointFn.fullPathName() + ";");

    //if meta parent joint is not null, parent first joint to it
    if(!metaParentJoint.isNull()) {
        MFnTransform firstJointFn(joints.at(0));

        MFnTransform metaParentJointFn(metaParentJoint);
        MGlobal::executeCommand("parent " + firstJointFn.fullPathName() + " " + metaParentJointFn.fullPathName() + ";");
        //orient the parent joint
        MGlobal::executeCommand("joint -e -zso -oj \"xyz\" -sao \"yup\" -ch " + metaParentJointFn.fullPathName() + ";");
    }

    return joints;
}
Пример #5
0
MStatus nailConstraintNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;

    ia_rigidBody = fnMsgAttr.create("inRigidBody", "inrb", &status);
    MCHECKSTATUS(status, "creating inRigidBody attribute")
    status = addAttribute(ia_rigidBody);
    MCHECKSTATUS(status, "adding inRigidBody attribute")

    ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating damping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_damping);
    MCHECKSTATUS(status, "adding damping attribute")

    ca_constraint = fnNumericAttr.create("ca_constraint", "caco", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraint attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraint);
    MCHECKSTATUS(status, "adding ca_constraint attribute")

    ca_constraintParam = fnNumericAttr.create("ca_constraintParam", "cacop", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraintParam attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraintParam);
    MCHECKSTATUS(status, "adding ca_constraintParam attribute")


    status = attributeAffects(ia_rigidBody, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraint)")

    status = attributeAffects(ia_rigidBody, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraintParam)")

    status = attributeAffects(ia_damping, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")

    return MS::kSuccess;
}
Пример #6
0
MStatus	MayaRenderGlobalsNode::initialize()
{
	
	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat = MStatus::kSuccess;

	filtertype = eAttr.create("filtertype", "filtertype", 0, &stat);
	CHECK_MSTATUS(addAttribute( filtertype ));

	imageFormat = eAttr.create("imageFormat", "imageFormat", 0, &stat);
	CHECK_MSTATUS(addAttribute( imageFormat ));

	sceneScale = nAttr.create("sceneScale", "sceneScale",  MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( sceneScale ));

	useSunLightConnection = nAttr.create("useSunLightConnection", "useSunLightConnection",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( useSunLightConnection ));

	exportSceneFile = nAttr.create("exportSceneFile", "exportSceneFile",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( exportSceneFile ));

	exportSceneFileName = tAttr.create("exportSceneFileName", "exportSceneFileName",  MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	CHECK_MSTATUS(addAttribute( exportSceneFileName ));

	// sampling adaptive
	minSamples = nAttr.create("minSamples", "minSamples", MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( minSamples ));
	maxSamples = nAttr.create("maxSamples", "maxSamples", MFnNumericData::kInt, 16);
	CHECK_MSTATUS(addAttribute( maxSamples ));
	
	// sampling raster based
	samplesX = nAttr.create("samplesX", "samplesX", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( samplesX ));
	samplesY = nAttr.create("samplesY", "samplesY", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( samplesY ));

	doMotionBlur = nAttr.create("doMotionBlur", "doMotionBlur", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( doMotionBlur ));
	motionBlurRange = nAttr.create("motionBlurRange", "motionBlurRange", MFnNumericData::kFloat, 0.4);
	CHECK_MSTATUS(addAttribute( motionBlurRange ));
	
	motionBlurType = eAttr.create("motionBlurType", "motionBlurType", 0, &stat);
	stat = eAttr.addField( "Center", 0 );
	stat = eAttr.addField( "FrameStart", 1 );
	stat = eAttr.addField( "FrameEnd", 2 );
	CHECK_MSTATUS(addAttribute( motionBlurType ));
	
	doDof = nAttr.create("doDof", "doDof", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( doDof ));

	xftimesamples = nAttr.create("xftimesamples", "xftimesamples", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute(xftimesamples));
	geotimesamples = nAttr.create("geotimesamples", "geotimesamples", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute(geotimesamples));


	MString numCpu = getenv("NUMBER_OF_PROCESSORS");
	int numberOfProcessors = numCpu.asInt();
	threads = nAttr.create("threads", "threads", MFnNumericData::kInt, numberOfProcessors);
	nAttr.setMin(1);
	CHECK_MSTATUS(addAttribute( threads ));

	translatorVerbosity = eAttr.create("translatorVerbosity", "translatorVerbosity", 2, &stat);
	stat = eAttr.addField( "Info", 0 );
	stat = eAttr.addField( "Error", 1 );
	stat = eAttr.addField( "Warning", 2 );
	stat = eAttr.addField( "Progress", 3 );
	stat = eAttr.addField( "Debug", 4 );
	stat = eAttr.addField( "None", 5 );
	CHECK_MSTATUS(addAttribute( translatorVerbosity ));

	rendererVerbosity = nAttr.create("rendererVerbosity", "rendererVerbosity", MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute( rendererVerbosity ));

	detectShapeDeform = nAttr.create("detectShapeDeform", "detectShapeDeform", MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( detectShapeDeform ));

	filtersize = nAttr.create("filtersize", "filtersize", MFnNumericData::kInt, 3);
	CHECK_MSTATUS(addAttribute( filtersize ));

	tilesize = nAttr.create("tilesize", "tilesize", MFnNumericData::kInt, 64);
	CHECK_MSTATUS(addAttribute( tilesize ));

	basePath = tAttr.create("basePath", "basePath", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( basePath ));

	imagePath = tAttr.create("imagePath", "imagePath", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( imagePath ));

	imageName = tAttr.create("imageName", "imageName", MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( imageName ));

	gamma = nAttr.create("gamma", "gamma", MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( gamma ));

	maxTraceDepth = nAttr.create("maxTraceDepth", "maxTraceDepth", MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( maxTraceDepth ));

	sunLightConnection = mAttr.create("sunLightConnection", "sunLightConnection");
	CHECK_MSTATUS(addAttribute( sunLightConnection ));

	adaptiveSampling = nAttr.create("adaptiveSampling", "adaptiveSampling", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( adaptiveSampling ));

	optimizedTexturePath = tAttr.create("optimizedTexturePath", "optimizedTexturePath",  MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	CHECK_MSTATUS(addAttribute( optimizedTexturePath ));

	useOptimizedTextures = nAttr.create("useOptimizedTextures", "useOptimizedTextures", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( useOptimizedTextures ));

	exrDataTypeHalf = nAttr.create("exrDataTypeHalf", "exrDataTypeHalf", MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute(exrDataTypeHalf));

	exrMergeChannels = nAttr.create("exrMergeChannels", "exrMergeChannels", MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute(exrMergeChannels));
	
	return MStatus::kSuccess;
}
Пример #7
0
MStatus mtmEnvLight::initialize()
{
    MFnTypedAttribute tAttr; 
    MFnNumericAttribute nAttr; 
    MFnLightDataAttribute lAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat;

    //aColor = nAttr.createColor( "color", "c" );
    //CHECK_MSTATUS ( nAttr.setKeyable(true) );
    //CHECK_MSTATUS ( nAttr.setStorable(true) );
    //CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.58824f, 0.644f) );

    aLightColor = nAttr.createColor( "lightColor", "lightColor" );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    nAttr.setDefault(0.7f, 0.58824f, 0.344f);

	aShadowColor = nAttr.createColor( "shadowColor", "sc" );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.0f, 0.0f) );

    aPosition = nAttr.createPoint( "position", "pos" );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );

    aInputDirection = nAttr.createPoint( "inputDirection", "id" );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setDefault(-1.0f, 0.0f, 0.0f) );

    aInputAmbient = nAttr.create( "ambientOn", "an", MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setDefault(true) );

    aInputDiffuse = nAttr.create( "emitDiffuse", "dn", MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setDefault(true) );

    aInputSpecular = nAttr.create( "emitSpecular", "sn", MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setDefault(true) );

    aIntensity = nAttr.create( "intensity", "i", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f) );

	samplingquality = nAttr.create( "samplingquality", "samplingquality", MFnNumericData::kFloat, 1.0);
	envmap = tAttr.create( "envmap", "envmap", MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	areamap = tAttr.create( "areamap", "areamap", MFnNumericData::kString);
	tAttr.setUsedAsFilename(true);
	areafullsphere = nAttr.create( "areafullsphere", "areafullsphere", MFnNumericData::kBoolean, true);
	envintensity = nAttr.createColor( "envintensity", "envintensity" );
	nAttr.setDefault(1.0f, 1.0f, 1.0f);
	raybackground = nAttr.create( "raybackground", "raybackground", MFnNumericData::kBoolean, false);
	castshadow = nAttr.create( "castshadow", "castshadow", MFnNumericData::kBoolean, true);
	envtype = eAttr.create( "envtype", "envtype", 0, &stat);
	stat = eAttr.addField( "Direct Lighting", 0 );
	stat = eAttr.addField( "Ambient Occlusion", 1 );
	stat = eAttr.addField( "Full Irradiance", 2 );
	stat = eAttr.addField( "Raytrace Background", 3 );
	eAttr.setDefault(0);		
	doraysamples = nAttr.create( "doraysamples", "doraysamples", MFnNumericData::kBoolean, false);
	doadaptive = nAttr.create( "doadaptive", "doadaptive", MFnNumericData::kBoolean, false);
	domaxdist = nAttr.create( "domaxdist", "domaxdist", MFnNumericData::kBoolean, false);
	maxdist = nAttr.create( "maxdist", "maxdist", MFnNumericData::kFloat, 10.0);
	coneangle = nAttr.create( "coneangle", "coneangle", MFnNumericData::kFloat, 45.0);
	envtint = nAttr.createColor( "envtint", "envtint" );
	nAttr.setDefault(1.0f, 1.0f, 1.0f);
	shadowI = nAttr.create( "shadowI", "shadowI", MFnNumericData::kFloat, 1.0);
	samples = nAttr.create( "samples", "samples", MFnNumericData::kInt, 32);
	MFnStringData fnStringData;
	MObject defaultObjectMask;
	defaultObjectMask = fnStringData.create( "*" );
	objectmask = tAttr.create( "objectmask", "objectmask", MFnNumericData::kString, defaultObjectMask);
	usePortalGeometry = nAttr.create( "usePortalGeometry", "usePortalGeometry", MFnNumericData::kBoolean, false);
	portalGeometry = mAttr.create( "portalGeometry", "portalGeometry");
	mAttr.setConnectable(true);
	mAttr.accepts(MFnData::kAny);
	
// Outputs

    aLightDirection = nAttr.createPoint( "lightDirection", "ld" );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(-1.0f, 0.0f, 0.0f) );

    aLightIntensity = nAttr.createColor( "lightIntensity", "li" );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 0.5f, 0.2f) );

    aLightAmbient = nAttr.create( "lightAmbient", "la", 
								  MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    nAttr.setDefault(true);

    aLightDiffuse = nAttr.create( "lightDiffuse", "ldf",
								  MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(true) );

    aLightSpecular = nAttr.create( "lightSpecular", "ls", 
								   MFnNumericData::kBoolean);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(true) );

    aLightShadowFraction = nAttr.create("lightShadowFraction","lsf",
										MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(0.0f) );

    aPreShadowIntensity = nAttr.create("preShadowIntensity","psi",
									   MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(0.0f) );

    aLightBlindData = nAttr.createAddr("lightBlindData","lbld");
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );

    aLightData = lAttr.create( "lightData", "ltd", 
                               aLightDirection, aLightIntensity, 
							   aLightAmbient, 
                               aLightDiffuse, aLightSpecular, 
							   aLightShadowFraction,
                               aPreShadowIntensity, aLightBlindData);
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS ( lAttr.setStorable(false) );
    CHECK_MSTATUS ( lAttr.setHidden(true) );
    lAttr.setDefault(-1.0f, 0.0f, 0.0f, 1.0f, 0.5f, 0.2f, true, true,
					 true, 0.0f, 1.0f, NULL);

    CHECK_MSTATUS ( addAttribute(coneangle) );
    CHECK_MSTATUS ( addAttribute(samples) );
    CHECK_MSTATUS ( addAttribute(objectmask) );
    CHECK_MSTATUS ( addAttribute(shadowI) );
    CHECK_MSTATUS ( addAttribute(envtint) );
    CHECK_MSTATUS ( addAttribute(maxdist) );
    CHECK_MSTATUS ( addAttribute(domaxdist) );
    CHECK_MSTATUS ( addAttribute(doadaptive) );
    CHECK_MSTATUS ( addAttribute(doraysamples) );
    CHECK_MSTATUS ( addAttribute(envtype) );
    CHECK_MSTATUS ( addAttribute(castshadow) );
    CHECK_MSTATUS ( addAttribute(raybackground) );
    CHECK_MSTATUS ( addAttribute(envintensity) );
    CHECK_MSTATUS ( addAttribute(areafullsphere) );
    CHECK_MSTATUS ( addAttribute(areamap) );
    CHECK_MSTATUS ( addAttribute(envmap) );
    CHECK_MSTATUS ( addAttribute(samplingquality) );
    CHECK_MSTATUS ( addAttribute(usePortalGeometry) );
    CHECK_MSTATUS ( addAttribute(portalGeometry) );
	

    //CHECK_MSTATUS ( addAttribute(aColor) );
    CHECK_MSTATUS ( addAttribute(aLightColor) );
    CHECK_MSTATUS ( addAttribute(aShadowColor) );
    CHECK_MSTATUS ( addAttribute(aPosition) );
    CHECK_MSTATUS ( addAttribute(aInputDirection) );
    CHECK_MSTATUS ( addAttribute(aInputAmbient) );
    CHECK_MSTATUS ( addAttribute(aInputDiffuse) );
    CHECK_MSTATUS ( addAttribute(aInputSpecular) );
    CHECK_MSTATUS ( addAttribute(aIntensity) );
	
    CHECK_MSTATUS ( addAttribute(aLightData) );

    CHECK_MSTATUS ( attributeAffects (aLightIntensity, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightDirection, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightAmbient, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightDiffuse, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightSpecular, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightShadowFraction, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aPreShadowIntensity, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightBlindData, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aLightData, aLightData) );

    //CHECK_MSTATUS ( attributeAffects (aColor, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aPosition, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aInputDirection, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aInputAmbient, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aInputDiffuse, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aInputSpecular, aLightData) );
    CHECK_MSTATUS ( attributeAffects (aIntensity, aLightData) );

    return MS::kSuccess;
}
Пример #8
0
MStatus hingeConstraintNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;

    ia_rigidBody = fnMsgAttr.create("inRigidBody", "inrb", &status);
    MCHECKSTATUS(status, "creating inRigidBody attribute")
    status = addAttribute(ia_rigidBody);
    MCHECKSTATUS(status, "adding inRigidBody attribute")

    ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating damping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_damping);
    MCHECKSTATUS(status, "adding damping attribute")

    ia_lowerLimit = fnNumericAttr.create("lowerLimit", "llmt", MFnNumericData::kDouble, -1.57, &status);
    MCHECKSTATUS(status, "creating lower limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerLimit);
    MCHECKSTATUS(status, "adding lower limit attribute")

	ia_upperLimit = fnNumericAttr.create("upperLimit", "ulmt", MFnNumericData::kDouble, 1.57, &status);
    MCHECKSTATUS(status, "creating upper limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperLimit);
    MCHECKSTATUS(status, "adding upper limit attribute")

	ia_limitSoftness = fnNumericAttr.create("limitSoftness", "lmSo", MFnNumericData::kDouble, 0.9, &status);
    MCHECKSTATUS(status, "creating limitSoftness attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_limitSoftness);
    MCHECKSTATUS(status, "adding limitSoftness attribute")

	ia_biasFactor = fnNumericAttr.create("biasFactor", "biFa", MFnNumericData::kDouble, 0.3, &status);
    MCHECKSTATUS(status, "creating biasFactor attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_biasFactor);
    MCHECKSTATUS(status, "adding biasFactor attribute")

	ia_relaxationFactor = fnNumericAttr.create("relaxationFactor", "reFa", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating relaxationFactor attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_relaxationFactor);
    MCHECKSTATUS(status, "adding relaxationFactor attribute")

	ia_hingeAxis = fnNumericAttr.createPoint("hingeAxis", "hgAx", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 1.0);
    MCHECKSTATUS(status, "creating hingeAxis attribute")
    status = addAttribute(ia_hingeAxis);
    MCHECKSTATUS(status, "adding hingeAxis attribute")

	//------------------------------------------------------------------------------
	
	ia_enableAngularMotor = fnNumericAttr.create("enableAngularMotor", "enAM", MFnNumericData::kBoolean, false, &status);
    MCHECKSTATUS(status, "creating enableAngularMotor attribute")
    status = addAttribute(ia_enableAngularMotor);
    MCHECKSTATUS(status, "adding enableAngularMotor attribute")

    ia_motorTargetVelocity = fnNumericAttr.create("motorTargetVelocity", "mTV", MFnNumericData::kDouble, 1, &status);
    MCHECKSTATUS(status, "creating motorTargetVelocity attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_motorTargetVelocity);
    MCHECKSTATUS(status, "adding motorTargetVelocity attribute")

	ia_maxMotorImpulse = fnNumericAttr.create("maxMotorImpulse", "mMI", MFnNumericData::kDouble, 1, &status);
    MCHECKSTATUS(status, "creating maxMotorImpulse attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_maxMotorImpulse);
    MCHECKSTATUS(status, "adding maxMotorImpulse attribute")

	//------------------------------------------------------------------------------

	ca_constraint = fnNumericAttr.create("ca_constraint", "caco", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraint attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraint);
    MCHECKSTATUS(status, "adding ca_constraint attribute")

    ca_constraintParam = fnNumericAttr.create("ca_constraintParam", "cacop", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraintParam attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraintParam);
    MCHECKSTATUS(status, "adding ca_constraintParam attribute")


    status = attributeAffects(ia_rigidBody, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraint)")

    status = attributeAffects(ia_rigidBody, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBody, ca_constraintParam)")

    status = attributeAffects(ia_damping, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")

    status = attributeAffects(ia_lowerLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_lowerLimit, ca_constraintParam)")

	status = attributeAffects(ia_upperLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_upperLimit, ca_constraintParam)")

	status = attributeAffects(ia_limitSoftness, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_limitSoftness, ca_constraintParam)")
	status = attributeAffects(ia_biasFactor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_biasFactor, ca_constraintParam)")
	status = attributeAffects(ia_relaxationFactor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_relaxationFactor, ca_constraintParam)")

	status = attributeAffects(ia_hingeAxis, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_hingeAxis, ca_constraintParam)")

	status = attributeAffects(ia_enableAngularMotor, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_enableAngularMotor, ca_constraintParam)")
	status = attributeAffects(ia_motorTargetVelocity, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_motorTargetVelocity, ca_constraintParam)")
	status = attributeAffects(ia_maxMotorImpulse, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_maxMotorImpulse, ca_constraintParam)")

	return MS::kSuccess;
}
Пример #9
0
MStatus Layered::initialize()
{
	MFnNumericAttribute nAttr;
	MFnLightDataAttribute lAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

    MStatus status; // Status will be used to hold the MStatus value
                    // returned by each api function call. It is important
                    // to check the status returned by a call to aid in
                    // debugging. Failed API calls can result in subtle
                    // errors that can be difficult to track down, you may
                    // wish to use the CHECK_MSTATUS macro for any API
                    // call where you do not need to provide your own
                    // error handling.
                    //

	baseShader = nAttr.createColor("baseShader", "baseShader");
	CHECK_MSTATUS(addAttribute(baseShader));

	layerWeight = nAttr.create("layerWeight", "layerWeight", MFnNumericData::kFloat, 0, &status);
	nAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerWeight));

	layerTexture = mAttr.create("layerTexture", "layerTexture");
	mAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerTexture));

	layerShader = nAttr.createColor("layerShader", "layerShader");
	nAttr.setArray(true);
	CHECK_MSTATUS(addAttribute(layerShader));

	outColor = nAttr.createColor("outColor", "outColor");
	CHECK_MSTATUS(addAttribute(outColor));

//---------------------------- automatically created attributes start ------------------------------------
//---------------------------- automatically created attributes end ------------------------------------


	aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(0.0f));

	aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(0.8f));

	aColor = nAttr.createColor("color", "c", &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.58824f, 0.644f));

	aIncandescence = nAttr.createColor("incandescence", "ic", &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.0f, 0.0f));

	aInTransparency = nAttr.createColor("transparency", "it", &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setKeyable(true));
	CHECK_MSTATUS(nAttr.setStorable(true));
	CHECK_MSTATUS(nAttr.setDefault(0.0f, 0.0f, 0.0f));

	CHECK_MSTATUS(nAttr.setHidden(false));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));

	aOutTransparency = nAttr.createColor("outTransparency", "ot", &status);
	CHECK_MSTATUS(status);

	CHECK_MSTATUS(nAttr.setHidden(false));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));

	// Camera Normals
	//
	aNormalCameraX = nAttr.create("normalCameraX", "nx",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aNormalCameraY = nAttr.create("normalCameraY", "ny",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aNormalCameraZ = nAttr.create("normalCameraZ", "nz",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aNormalCamera = nAttr.create("normalCamera", "n", aNormalCameraX,
		aNormalCameraY, aNormalCameraZ, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f));
	CHECK_MSTATUS(nAttr.setHidden(true));


	// Light Direction
	//
	aLightDirectionX = nAttr.create("lightDirectionX", "ldx",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightDirectionY = nAttr.create("lightDirectionY", "ldy",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightDirectionZ = nAttr.create("lightDirectionZ", "ldz",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightDirection = nAttr.create("lightDirection", "ld",
		aLightDirectionX, aLightDirectionY, aLightDirectionZ,
		&status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f));


	// Light Intensity
	//
	aLightIntensityR = nAttr.create("lightIntensityR", "lir",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightIntensityG = nAttr.create("lightIntensityG", "lig",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightIntensityB = nAttr.create("lightIntensityB", "lib",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightIntensity = nAttr.create("lightIntensity", "li",
		aLightIntensityR, aLightIntensityG, aLightIntensityB,
		&status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f));


	// Light
	//
	aLightAmbient = nAttr.create("lightAmbient", "la",
		MFnNumericData::kBoolean, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(true));

	aLightDiffuse = nAttr.create("lightDiffuse", "ldf",
		MFnNumericData::kBoolean, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(true));

	aLightSpecular = nAttr.create("lightSpecular", "ls",
		MFnNumericData::kBoolean, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(false));

	aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aPreShadowIntensity = nAttr.create("preShadowIntensity", "psi",
		MFnNumericData::kFloat, 0, &status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));
	CHECK_MSTATUS(nAttr.setDefault(1.0f));

	aLightBlindData = nAttr.createAddr("lightBlindData", "lbld",
		&status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(nAttr.setStorable(false));
	CHECK_MSTATUS(nAttr.setHidden(true));
	CHECK_MSTATUS(nAttr.setReadable(true));
	CHECK_MSTATUS(nAttr.setWritable(false));

	aLightData = lAttr.create("lightDataArray", "ltd", aLightDirection,
		aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular,
		aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
		&status);
	CHECK_MSTATUS(status);
	CHECK_MSTATUS(lAttr.setArray(true));
	CHECK_MSTATUS(lAttr.setStorable(false));
	CHECK_MSTATUS(lAttr.setHidden(true));
	CHECK_MSTATUS(lAttr.setDefault(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
		true, true, false, 1.0f, 1.0f, NULL));


	// Next we will add the attributes we have defined to the node
	//
	CHECK_MSTATUS(addAttribute(aTranslucenceCoeff));
	CHECK_MSTATUS(addAttribute(aDiffuseReflectivity));
	CHECK_MSTATUS(addAttribute(aColor));
	CHECK_MSTATUS(addAttribute(aIncandescence));
	CHECK_MSTATUS(addAttribute(aInTransparency));
	CHECK_MSTATUS(addAttribute(outColor));
	CHECK_MSTATUS(addAttribute(aOutTransparency));
	CHECK_MSTATUS(addAttribute(aNormalCamera));

	// Only add the parent of the compound
	CHECK_MSTATUS(addAttribute(aLightData));


	CHECK_MSTATUS(attributeAffects(layerTexture, outColor));
	CHECK_MSTATUS(attributeAffects(layerWeight, outColor));

	CHECK_MSTATUS(attributeAffects(aTranslucenceCoeff, outColor));
	CHECK_MSTATUS(attributeAffects(aDiffuseReflectivity, outColor));
	CHECK_MSTATUS(attributeAffects(aColor, outColor));
	CHECK_MSTATUS(attributeAffects(aInTransparency, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aInTransparency, outColor));
	CHECK_MSTATUS(attributeAffects(aIncandescence, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityR, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityB, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensityG, outColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensity, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraX, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraY, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCameraZ, outColor));
	CHECK_MSTATUS(attributeAffects(aNormalCamera, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionX, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionY, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirectionZ, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDirection, outColor));
	CHECK_MSTATUS(attributeAffects(aLightAmbient, outColor));
	CHECK_MSTATUS(attributeAffects(aLightSpecular, outColor));
	CHECK_MSTATUS(attributeAffects(aLightDiffuse, outColor));
	CHECK_MSTATUS(attributeAffects(aLightShadowFraction, outColor));
	CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, outColor));
	CHECK_MSTATUS(attributeAffects(aLightBlindData, outColor));
	CHECK_MSTATUS(attributeAffects(aLightData, outColor));


    return( MS::kSuccess );
}
Пример #10
0
MStatus liqDisplacementNode::initialize()
{
  MFnTypedAttribute   tAttr;
  MFnStringData       tDefault;
  MFnNumericAttribute nAttr;
  MFnMessageAttribute mAttr;
  MFnEnumAttribute    eAttr;
  MStatus status;

  // Create input attributes

  aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLif = tAttr.create(  MString("rmanShaderLif"),  MString("lif"), MFnData::kString, aRmanShaderLif, &status );
  MAKE_INPUT(tAttr);

  aRmanParams = tAttr.create(  MString("rmanParams"),  MString("rpr"), MFnData::kStringArray, aRmanParams, &status );
  MAKE_INPUT(tAttr);

  aRmanDetails = tAttr.create(  MString("rmanDetails"),  MString("rdt"), MFnData::kStringArray, aRmanDetails, &status );
  MAKE_INPUT(tAttr);

  aRmanTypes = tAttr.create(  MString("rmanTypes"),  MString("rty"), MFnData::kStringArray, aRmanTypes, &status );
  MAKE_INPUT(tAttr);

  aRmanDefaults = tAttr.create(  MString("rmanDefaults"),  MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status );
  MAKE_INPUT(tAttr);

  aRmanArraySizes = tAttr.create(  MString("rmanArraySizes"),  MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status );
  MAKE_INPUT(tAttr);

  aRmanLifCmds = tAttr.create(  MString("rmanLifCmds"),  MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status );
  MAKE_INPUT(tAttr);

  aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status );
  eAttr.addField( "Sphere",   0 );
  eAttr.addField( "Cube",     1 );
  eAttr.addField( "Cylinder", 2 );
  eAttr.addField( "Torus",    3 );
  eAttr.addField( "Plane",    4 );
  eAttr.addField( "Teapot",   5 );
  eAttr.addField( "Custom",   6 );
  eAttr.addField( "(globals)",7 );
  MAKE_NONKEYABLE_INPUT(eAttr);
  CHECK_MSTATUS(eAttr.setConnectable(false));

  aPreviewCustomPrimitive = tAttr.create(  MString("previewCustomPrimitive"),  MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status );
  MAKE_INPUT(tAttr);

  aPreviewCustomBackplane = tAttr.create(  MString("previewCustomBackplane"),  MString("pcb"), MFnData::kString, aPreviewCustomBackplane, &status );
  MAKE_INPUT(tAttr);

  aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewPixelSamples = nAttr.create("previewPixelSamples", "pxs",  MFnNumericData::kInt, 3, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));


  aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status );
  MAKE_INPUT(tAttr);

  aDisplacementBound = nAttr.create("displacementBound", "db", MFnNumericData::kDouble, 0.0, &status);
  MAKE_INPUT(nAttr);

  MObject defaultSpaceObj = tDefault.create( MString("shader"), &status);
  aDisplacementBoundSpace = tAttr.create( MString("displacementBoundSpace"), MString("dbs"), MFnData::kString, defaultSpaceObj, &status );
  MAKE_INPUT(tAttr);

  aOutputInShadow = nAttr.create("outputInShadow", "ois",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);

  // refreshPreview must be true to allow refresh
  aRefreshPreview = nAttr.create("refreshPreview", "rfp",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setHidden(true));

  // Create output attributes
  aDisplacement = nAttr.create("displacement", "d", MFnNumericData::kFloat, 0.0, &status);
  MAKE_OUTPUT(nAttr);
  aOutColor = nAttr.createColor("outColor", "oc");
  MAKE_OUTPUT(nAttr);
  aAssignedObjects = mAttr.create("liqAssignedObjects", "ao");
  MAKE_OUTPUT(mAttr);

  CHECK_MSTATUS(addAttribute(aRmanShader));
  CHECK_MSTATUS(addAttribute(aRmanShaderLong));
  CHECK_MSTATUS(addAttribute(aRmanShaderLif));
  CHECK_MSTATUS(addAttribute(aRmanParams));
  CHECK_MSTATUS(addAttribute(aRmanDetails));
  CHECK_MSTATUS(addAttribute(aRmanTypes));
  CHECK_MSTATUS(addAttribute(aRmanDefaults));
  CHECK_MSTATUS(addAttribute(aRmanArraySizes));
  CHECK_MSTATUS(addAttribute(aRmanLifCmds));

  CHECK_MSTATUS(addAttribute(aPreviewPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewCustomPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewCustomBackplane));
  CHECK_MSTATUS(addAttribute(aPreviewObjectSize));
  CHECK_MSTATUS(addAttribute(aPreviewPixelSamples));
  CHECK_MSTATUS(addAttribute(aPreviewShadingRate));
  CHECK_MSTATUS(addAttribute(aPreviewBackplane));
  CHECK_MSTATUS(addAttribute(aShaderSpace));
  CHECK_MSTATUS(addAttribute(aDisplacementBound));
  CHECK_MSTATUS(addAttribute(aDisplacementBoundSpace));
  CHECK_MSTATUS(addAttribute(aOutputInShadow));
  CHECK_MSTATUS(addAttribute(aRefreshPreview));

  CHECK_MSTATUS(addAttribute(aAssignedObjects));
  CHECK_MSTATUS(addAttribute(aDisplacement));
  CHECK_MSTATUS(addAttribute(aOutColor));

  CHECK_MSTATUS(attributeAffects(aRmanShaderLong, aDisplacement));
  CHECK_MSTATUS(attributeAffects(aRmanShaderLif, aDisplacement));

  return MS::kSuccess;
}
Пример #11
0
MStatus	MayaToAppleseedGlobals::initialize()
{
	MayaRenderGlobalsNode::initialize();

	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat = MStatus::kSuccess;

	sampling_mode = eAttr.create("sampling_mode", "sampling_mode", 0, &stat);
	stat = eAttr.addField("qmc", 0);
	stat = eAttr.addField("rng", 1);
	CHECK_MSTATUS(addAttribute(sampling_mode));

	tile_ordering = eAttr.create("tile_ordering", "tile_ordering", 2, &stat);
	stat = eAttr.addField("linear", 0);
	stat = eAttr.addField("spiral", 1);
	stat = eAttr.addField("hilbert", 2);
	stat = eAttr.addField("random", 3);
	CHECK_MSTATUS(addAttribute(tile_ordering));

	bitdepth = eAttr.create( "bitdepth", "bitdepth", 3, &stat);
	stat = eAttr.addField( "8bit  Integer", 0 );
	stat = eAttr.addField( "16bit Integer", 1 );
	stat = eAttr.addField( "32bit Integer", 2 );
	stat = eAttr.addField( "16bit Float(Half)", 3 );
	stat = eAttr.addField( "32bit Float", 4 );
	stat = eAttr.addField( "64bit Double", 5 );
	CHECK_MSTATUS(addAttribute( bitdepth ));

	pixel_renderer = eAttr.create( "pixel_renderer", "pixel_renderer", 0, &stat);
	stat = eAttr.addField( "adaptive", 0 );
	stat = eAttr.addField( "uniform", 1 );
	CHECK_MSTATUS(addAttribute( pixel_renderer ));

	colorSpace = eAttr.create( "colorSpace", "colorSpace", 0, &stat);
	stat = eAttr.addField( "linear_rgb", 0 );
	stat = eAttr.addField( "srgb", 1 );
	stat = eAttr.addField( "ciexyz", 2 );
	CHECK_MSTATUS(addAttribute( colorSpace ));

	lightingEngine = eAttr.create( "lightingEngine", "lightingEngine", 0, &stat);
	stat = eAttr.addField( "Unidirectional Path tracing", 0 );
	stat = eAttr.addField( "Distributed Raytracing", 1 );
	stat = eAttr.addField( "Stochastic Progressive Photon Mapping", 2 );
	CHECK_MSTATUS(addAttribute( lightingEngine ));

	clamping = nAttr.create("clamping", "clamping",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( clamping ));

	maxError = nAttr.create("maxError", "maxError",  MFnNumericData::kFloat, 0.01f);
	CHECK_MSTATUS(addAttribute( maxError ));

	adaptiveQuality = nAttr.create("adaptiveQuality", "adaptiveQuality",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( adaptiveQuality ));
	
	enable_caustics = nAttr.create("enable_caustics", "enable_caustics",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( enable_caustics ));

	enable_dl = nAttr.create("enable_dl", "enable_ibl",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( enable_dl ));

	enable_diagnostics = nAttr.create("enable_diagnostics", "enable_diagnostics",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( enable_diagnostics ));

	diffuseDepth = nAttr.create("diffuseDepth", "diffuseDepth",  MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( diffuseDepth ));

	texCacheSize = nAttr.create("texCacheSize", "texCacheSize",  MFnNumericData::kInt, 512);
	CHECK_MSTATUS(addAttribute( texCacheSize ));

	frameRendererPasses = nAttr.create("frameRendererPasses", "frameRendererPasses",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( frameRendererPasses ));

	glossyDepth = nAttr.create("glossyDepth", "glossyDepth",  MFnNumericData::kInt, 4);
	CHECK_MSTATUS(addAttribute( glossyDepth ));

	environmentSamples = nAttr.create("environmentSamples", "environmentSamples",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( environmentSamples ));

	bsdfSamples = nAttr.create("bsdfSamples", "bsdfSamples",  MFnNumericData::kInt, 1);
	CHECK_MSTATUS(addAttribute( bsdfSamples ));

	next_event_estimation = nAttr.create("next_event_estimation", "next_event_estimation",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( next_event_estimation ));

	assemblySBVH = nAttr.create("assemblySBVH", "assemblySBVH",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( assemblySBVH ));

	max_path_length = nAttr.create("max_path_length", "max_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(max_path_length));

	rr_min_path_length = nAttr.create("rr_min_path_length", "rr_min_path_length",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( rr_min_path_length ));

	path_tracing_max_path_length = nAttr.create("path_tracing_max_path_length", "path_tracing_max_path_length", MFnNumericData::kFloat, 0.0f);
	CHECK_MSTATUS(addAttribute(path_tracing_max_path_length));

	path_tracing_rr_min_path_length = nAttr.create("path_tracing_rr_min_path_length", "path_tracing_rr_min_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(path_tracing_rr_min_path_length));

	photon_tracing_max_path_length = nAttr.create("photon_tracing_max_path_length", "photon_tracing_max_path_length", MFnNumericData::kFloat, 8.0f);
	CHECK_MSTATUS(addAttribute(photon_tracing_max_path_length));

	photon_tracing_rr_min_path_length = nAttr.create("photon_tracing_rr_min_path_length", "photon_tracing_rr_min_path_length", MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute(photon_tracing_rr_min_path_length));

	max_ray_intensity = nAttr.create("max_ray_intensity", "max_ray_intensity",  MFnNumericData::kFloat, 0.0f);
	CHECK_MSTATUS(addAttribute( max_ray_intensity ));

	// reduced to auto because we do not need the others (I hope) remove the whole attribute in the next release
	assemblyExportType = eAttr.create( "assemblyExportType", "assemblyExportType", 0, &stat);
	stat = eAttr.addField( "Auto", 0 );
	CHECK_MSTATUS(addAttribute( assemblyExportType ));

	assemblyPolyTheshold = nAttr.create("assemblyPolyTheshold", "assemblyPolyTheshold",  MFnNumericData::kInt, 10000);
	CHECK_MSTATUS(addAttribute( assemblyPolyTheshold ));

	environmentType = eAttr.create( "environmentType", "environmentType", 0, &stat);
	stat = eAttr.addField("Constant", 0);
	stat = eAttr.addField("ConstantHemisphere", 1);
	stat = eAttr.addField("Gradient", 2);
	stat = eAttr.addField("Latitude Longitude", 3 );
	stat = eAttr.addField("Mirror Ball", 4 );
	stat = eAttr.addField("Physical Sky", 5);
	stat = eAttr.addField("OSL Environment", 6);
	CHECK_MSTATUS(addAttribute(environmentType));

	environmentColor = nAttr.createColor("environmentColor", "environmentColor");
	nAttr.setDefault(0.6f, 0.7f, 0.9f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( environmentColor ));

	gradientHorizon = nAttr.createColor("gradientHorizon", "gradientHorizon");
	nAttr.setDefault(0.8f, 0.8f, 0.9f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( gradientHorizon ));

	gradientZenit = nAttr.createColor("gradientZenit", "gradientZenit");
	nAttr.setDefault(0.2f, 0.3f, 0.6f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( gradientZenit ));

	environmentMap = nAttr.createColor("environmentMap", "environmentMap");
	nAttr.setDefault(0.6f, 0.7f, 0.9f);
	CHECK_MSTATUS(addAttribute( environmentMap ));

	environmentIntensity = nAttr.create("environmentIntensity", "environmentIntensity",  MFnNumericData::kFloat, 1.0f);
	nAttr.setConnectable(false);
	CHECK_MSTATUS(addAttribute( environmentIntensity ));

	directLightSamples = nAttr.create("directLightSamples", "directLightSamples",  MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( directLightSamples ));

	latlongHoShift = nAttr.create("latlongHoShift", "latlongHoShift",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( latlongHoShift ));

	latlongVeShift = nAttr.create("latlongVeShift", "latlongVeShift",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( latlongVeShift ));

	AOVs = mAttr.create("AOVs", "AOVs");
	mAttr.setArray(true);
	mAttr.indexMatters(false);
	CHECK_MSTATUS(addAttribute( AOVs ));

	ground_albedo = nAttr.create("ground_albedo", "ground_albedo",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( ground_albedo ));

	horizon_shift = nAttr.create("horizon_shift", "horizon_shift",  MFnNumericData::kFloat, -0.05f);
	CHECK_MSTATUS(addAttribute( horizon_shift ));

	luminance_multiplier = nAttr.create("luminance_multiplier", "luminance_multiplier",  MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( luminance_multiplier ));

	saturation_multiplier = nAttr.create("saturation_multiplier", "saturation_multiplier",  MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( saturation_multiplier ));

	sun_phi = nAttr.create("sun_phi", "sun_phi",  MFnNumericData::kFloat, .0f);
	CHECK_MSTATUS(addAttribute( sun_phi ));

	sun_theta = nAttr.create("sun_theta", "sun_theta",  MFnNumericData::kFloat, 60.0f);
	CHECK_MSTATUS(addAttribute( sun_theta ));

	turbidity = nAttr.create("turbidity", "turbidity",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity ));

	turbidity_max = nAttr.create("turbidity_max", "turbidity_max",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity_max ));

	turbidity_min = nAttr.create("turbidity_min", "turbidity_min",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( turbidity_min ));

	skyModel = eAttr.create( "skyModel", "skyModel", 0, &stat);
	stat = eAttr.addField( "Preetham", 0 );
	stat = eAttr.addField( "Hosek", 1 );
	CHECK_MSTATUS(addAttribute( skyModel ));

	physicalSun = nAttr.create("physicalSun", "physicalSun",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( physicalSun ));

	physicalSunConnection = mAttr.create("physicalSunConnection", "physicalSunConnection");
	CHECK_MSTATUS(addAttribute( physicalSunConnection ));

	sunTurbidity = nAttr.create("sunTurbidity", "sunTurbidity",  MFnNumericData::kFloat, 3.0f);
	CHECK_MSTATUS(addAttribute( sunTurbidity ));

	sunExitanceMultiplier = nAttr.create("sunExitanceMultiplier", "sunExitanceMultiplier",  MFnNumericData::kFloat, 1.0f);
	CHECK_MSTATUS(addAttribute( sunExitanceMultiplier ));

	sppmAlpha = nAttr.create("sppmAlpha", "sppmAlpha",  MFnNumericData::kFloat, .8f);
	CHECK_MSTATUS(addAttribute( sppmAlpha ));

	dl_mode = eAttr.create("dl_mode", "dl_mode", 0, &stat);
	stat = eAttr.addField("RT Direct Lighting", 0);
	stat = eAttr.addField("SPPM Direct Lighting", 1);
	stat = eAttr.addField("No Direct Lighting", 2);
	CHECK_MSTATUS(addAttribute(dl_mode));

	env_photons_per_pass = nAttr.create("env_photons_per_pass", "env_photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( env_photons_per_pass ));

	initial_radius = nAttr.create("initial_radius", "initial_radius",  MFnNumericData::kFloat, .5f);
	CHECK_MSTATUS(addAttribute( initial_radius ));

	light_photons_per_pass = nAttr.create("light_photons_per_pass", "light_photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( light_photons_per_pass ));

	max_photons_per_estimate = nAttr.create("max_photons_per_estimate", "max_photons_per_estimate",  MFnNumericData::kInt, 100);
	CHECK_MSTATUS(addAttribute( max_photons_per_estimate ));

	photons_per_pass = nAttr.create("photons_per_pass", "photons_per_pass",  MFnNumericData::kInt, 100000);
	CHECK_MSTATUS(addAttribute( photons_per_pass ));

	photon_type = eAttr.create("photon_type", "photon_type", 1, &stat);
	stat = eAttr.addField("Monochromatic", 0);
	stat = eAttr.addField("Polychromatic", 1);
	CHECK_MSTATUS(addAttribute(photon_type));

	return stat;

}
Пример #12
0
MStatus dSolverNode::initialize()
{ 
    MStatus                 status;
    MFnEnumAttribute        fnEnumAttr;
    MFnMessageAttribute     fnMsgAttr;
    MFnUnitAttribute        fnUnitAttr;
    MFnNumericAttribute     fnNumericAttr;

    //
    ssSolverType = fnEnumAttr.create( "ssSolverType", "ssst", 0, &status );
    MCHECKSTATUS(status, "creating ssSolverType attribute")
    fnEnumAttr.addField( "Bullet Physics", 0 );
    fnEnumAttr.addField( "Ageia PhysX", 1 );
    fnEnumAttr.addField( "Stanford PhysBAM", 2 );
    status = addAttribute(ssSolverType);
    MCHECKSTATUS(status, "adding ssSolverType attribute")

    //
    ia_time = fnUnitAttr.create( "inTime", "it", MFnUnitAttribute::kTime, 0.0, &status );
    MCHECKSTATUS(status, "creating ia_time attribute")
    fnUnitAttr.setHidden(true);
    status = addAttribute(ia_time);
    MCHECKSTATUS(status, "adding ia_time attribute")

    ia_startTime = fnUnitAttr.create( "startTime", "stm", MFnUnitAttribute::kTime, 1.0, &status );
    MCHECKSTATUS(status, "creating ia_startTime attribute")
    status = addAttribute(ia_startTime);
    MCHECKSTATUS(status, "adding ia_startTime attribute")

    oa_rigidBodies = fnMsgAttr.create("rigidBodies", "rbds", &status);
    MCHECKSTATUS(status, "creating oa_rigidBodies attribute")
    status = addAttribute(oa_rigidBodies);
    MCHECKSTATUS(status, "adding oa_rigidBodies attribute")

    ia_gravity = fnNumericAttr.createPoint("gravity", "grvt", &status);
    MCHECKSTATUS(status, "creating gravity attribute")
    fnNumericAttr.setDefault(0.0, -9.81, 0.0);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_gravity);
    MCHECKSTATUS(status, "adding ia_gravity attribute")

    ia_substeps = fnNumericAttr.create("substeps", "sbs", MFnNumericData::kInt, 1, &status);
    MCHECKSTATUS(status, "creating substeps attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_substeps);
    MCHECKSTATUS(status, "adding ia_substeps attribute")

    ia_enabled = fnNumericAttr.create("enabled", "enbl", MFnNumericData::kBoolean, true, &status);
    MCHECKSTATUS(status, "creating enabled attribute")
    status = addAttribute(ia_enabled);
    MCHECKSTATUS(status, "adding ia_enabled attribute")

    ia_splitImpulse = fnNumericAttr.create("splitImpulse", "spli", MFnNumericData::kBoolean, false, &status);
    MCHECKSTATUS(status, "creating splitImpulse attribute")
    status = addAttribute(ia_splitImpulse);
    MCHECKSTATUS(status, "adding ia_splitImpulse attribute")

    status = attributeAffects(ia_time, oa_rigidBodies);
    MCHECKSTATUS(status, "adding attributeAffects(ia_time, oa_rigidBodies)")

    status = attributeAffects(ia_enabled, oa_rigidBodies);
    MCHECKSTATUS(status, "adding attributeAffects(ia_enabled, oa_rigidBodies)")

    return MS::kSuccess;
}
Пример #13
0
MStatus sixdofConstraintNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;

    ia_rigidBodyA = fnMsgAttr.create("inRigidBodyA", "inrbA", &status);
    MCHECKSTATUS(status, "creating inRigidBodyA attribute")
    status = addAttribute(ia_rigidBodyA);
    MCHECKSTATUS(status, "adding inRigidBody attribute")

    ia_rigidBodyB = fnMsgAttr.create("inRigidBodyB", "inrbB", &status);
    MCHECKSTATUS(status, "creating inRigidBodyB attribute")
    status = addAttribute(ia_rigidBodyB);
    MCHECKSTATUS(status, "adding inRigidBodyB attribute")

	ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating damping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_damping);
    MCHECKSTATUS(status, "adding damping attribute")

	ia_breakThreshold = fnNumericAttr.create("breakThreshold", "brkThrsh", MFnNumericData::kDouble, 100.0, &status);
    MCHECKSTATUS(status, "creating breakThreshold attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_breakThreshold);
    MCHECKSTATUS(status, "adding breakThreshold attribute")

	ia_disableCollide = fnNumericAttr.create("disableCollide", "dsblColl", MFnNumericData::kBoolean, true, &status);
    MCHECKSTATUS(status, "creating disableCollide attribute")
	fnNumericAttr.setHidden(true);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_disableCollide);
    MCHECKSTATUS(status, "adding disableCollide attribute")

    ia_lowerLinLimit = fnNumericAttr.createPoint("lowerLinLimit", "lllt", &status);
    MCHECKSTATUS(status, "creating lower linear limit attribute")
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerLinLimit);
    MCHECKSTATUS(status, "adding lower linear limit attribute")

	ia_upperLinLimit = fnNumericAttr.createPoint("upperLinLimit", "ullt", &status);
    MCHECKSTATUS(status, "creating upper linear limit attribute")
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperLinLimit);
    MCHECKSTATUS(status, "adding upper linear limit attribute")

    ia_lowerAngLimit = fnNumericAttr.createPoint("lowerAngLimit", "lalt", &status);
    MCHECKSTATUS(status, "creating lower angular limit attribute")
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerAngLimit);
    MCHECKSTATUS(status, "adding lower angular limit attribute")

	ia_upperAngLimit = fnNumericAttr.createPoint("upperAngLimit", "ualt", &status);
    MCHECKSTATUS(status, "creating upper angular limit attribute")
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperAngLimit);
    MCHECKSTATUS(status, "adding upper angular limit attribute")

	ca_constraint = fnNumericAttr.create("ca_constraint", "caco", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraint attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraint);
    MCHECKSTATUS(status, "adding ca_constraint attribute")


    ca_constraintParam = fnNumericAttr.create("ca_constraintParam", "cacop", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraintParam attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraintParam);
    MCHECKSTATUS(status, "adding ca_constraintParam attribute")

	ia_rotationInA = fnNumericAttr.createPoint("rotationInA", "hgRotA", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    MCHECKSTATUS(status, "creating rotationInA attribute")
    status = addAttribute(ia_rotationInA);
    MCHECKSTATUS(status, "adding rotationInA attribute")

	ia_rotationInB = fnNumericAttr.createPoint("rotationInB", "hgRotB", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    MCHECKSTATUS(status, "creating rotationInB attribute")
    status = addAttribute(ia_rotationInB);
    MCHECKSTATUS(status, "adding rotationInB attribute")

	ia_pivotInA = fnNumericAttr.createPoint("pivotInA", "pivinA", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    MCHECKSTATUS(status, "creating pivotInA attribute")
    status = addAttribute(ia_pivotInA);
    MCHECKSTATUS(status, "adding pivotInA attribute")

	ia_pivotInB = fnNumericAttr.createPoint("pivotInB", "pivinB", &status);
	status = fnNumericAttr.setDefault((double) 0.0, (double) 0.0, (double) 0.0);
    MCHECKSTATUS(status, "creating pivotInB attribute")
    status = addAttribute(ia_pivotInB);
    MCHECKSTATUS(status, "adding pivotInB attribute")


    status = attributeAffects(ia_rigidBodyA, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraint)")

    status = attributeAffects(ia_rigidBodyA, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraintParam)")

    status = attributeAffects(ia_rigidBodyB, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraint)")

    status = attributeAffects(ia_rigidBodyB, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraintParam)")

	status = attributeAffects(ia_damping, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")

	status = attributeAffects(ia_breakThreshold, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_breakThreshold, ca_constraintParam)")

	status = attributeAffects(ia_disableCollide, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_disableCollide, ca_constraint)")

    status = attributeAffects(ia_lowerLinLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_lowerLinLimit, ca_constraintParam)")

	status = attributeAffects(ia_upperLinLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_upperLinLimit, ca_constraintParam)")

    status = attributeAffects(ia_lowerAngLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_lowerAngLimit, ca_constraintParam)")

	status = attributeAffects(ia_upperAngLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_upperAngLimit, ca_constraintParam)")

	status = attributeAffects(ia_rotationInA, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rotationInA, ca_constraintParam)")
	status = attributeAffects(ia_rotationInB, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rotationInB, ca_constraintParam)")

	status = attributeAffects(ia_pivotInA, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_pivotInA, ca_constraintParam)")
	status = attributeAffects(ia_pivotInB, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_pivotInB, ca_constraintParam)")


	return MS::kSuccess;
}
Пример #14
0
MStatus SoftBodyNode::initialize()
{
	MFnMessageAttribute fnMsgAttr;
	MStatus status = MStatus::kSuccess;

	ia_solver = fnMsgAttr.create("solver", "solv", &status);
	MCHECKSTATUS(status, "creating solver attribute")
		status = addAttribute(ia_solver);
	MCHECKSTATUS(status, "adding solver attribute")

		MFnNumericAttribute fnNumericAttr;
	ca_solver = fnNumericAttr.create("ca_solver", "caso", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_solver attribute")
		fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_solver);
	MCHECKSTATUS(status, "adding ca_solver attribute")

		ca_softBody = fnNumericAttr.create("ca_softBody", "casb", MFnNumericData::kBoolean, 0, &status);   
	MCHECKSTATUS(status, "creating ca_softBody attribute")
		fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_softBody);
	MCHECKSTATUS(status, "adding ca_softBody attribute")

		inputMesh = fnMsgAttr.create("inMesh", "inmsh", &status);
	MCHECKSTATUS(status, "creating inMesh attribute")
		status = addAttribute(inputMesh);
	MCHECKSTATUS(status, "adding inMesh attribute")

		outputMesh = fnMsgAttr.create("outMesh", "outmsh", &status);
	MCHECKSTATUS(status, "creating outMesh attribute")
		status = addAttribute(outputMesh);
	MCHECKSTATUS(status, "adding outMesh attribute")
		/*
		Note that these initial* attributes are not in use for soft bodies at the moment
		*/
		ia_initialPosition = fnNumericAttr.createPoint("initialPosition", "inpo", &status);
	MCHECKSTATUS(status, "creating initialPosition attribute")
		status = addAttribute(ia_initialPosition);
	MCHECKSTATUS(status, "adding initialPosition attribute")

		ia_initialRotation = fnNumericAttr.createPoint("initialRotation", "inro", &status);
	MCHECKSTATUS(status, "creating initialRotation attribute")
		status = addAttribute(ia_initialRotation);
	MCHECKSTATUS(status, "adding initialRotation attribute")

		ia_initialVelocity = fnNumericAttr.createPoint("initialVelocity", "inve", &status);
	MCHECKSTATUS(status, "creating initialVelocity attribute")
		status = addAttribute(ia_initialVelocity);
	MCHECKSTATUS(status, "adding initialVelocity attribute")

		ia_initialSpin = fnNumericAttr.createPoint("initialSpin", "insp", &status);
	MCHECKSTATUS(status, "creating initialSpin attribute")
		status = addAttribute(ia_initialSpin);
	MCHECKSTATUS(status, "adding initialSpin attribute")

		// total soft body mass
		ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, DEFAULT_MASS, &status);
	MCHECKSTATUS(status, "creating mass attribute")
		fnNumericAttr.setKeyable(true);
	status = addAttribute(ia_mass);
	MCHECKSTATUS(status, "adding mass attribute")

		// create dynamic friction coefficient attribute
		ia_dynamicFrictionCoeff = fnNumericAttr.create("dynamicfrictioncoeff", "dfc", MFnNumericData::kDouble, DEFAULT_DFC, &status);
	MCHECKSTATUS(status, "creating dynamicfrictioncoeff attribute")
		fnNumericAttr.setKeyable(true);
	status = addAttribute(ia_dynamicFrictionCoeff);
	MCHECKSTATUS(status, "adding dynamicfrictioncoeff attribute")

		// create collision margin attribute
		ia_collisionMargin = fnNumericAttr.create("collisionmargin", "cmargin", MFnNumericData::kFloat, DEFAULT_CMARGIN, &status);
	MCHECKSTATUS(status, "creating collisionmargin attribute")
		fnNumericAttr.setKeyable(false);
	status = addAttribute(ia_collisionMargin);
	MCHECKSTATUS(status, "adding collision attribute")

		// collision clusters attribute
		ia_numClusters = fnNumericAttr.create("numclusters", "nclust", MFnNumericData::kInt, DEFAULT_CLUSTERS, &status);
	MCHECKSTATUS(status, "creating numclusters attribute")
		fnNumericAttr.setKeyable(false);
	status = addAttribute(ia_numClusters);
	MCHECKSTATUS(status, "adding numclusters attribute")

		ca_softBodyParam = fnNumericAttr.create("ca_softBodyParam", "casbp", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_softBodyParam attribute")
		fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_softBodyParam);
	MCHECKSTATUS(status, "adding ca_softBodyParam attribute")

		status = attributeAffects(inputMesh, ca_softBody);
	MCHECKSTATUS(status, "adding attributeAffects(inputMesh, ca_softBody)")

		status = attributeAffects(ia_solver, ca_solver);
	MCHECKSTATUS(status, "adding attributeAffects(ia_solver, ca_solver)")

		// connect soft body parameters to ca_softBodyParam connection
		status = attributeAffects(ia_mass, ca_softBodyParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_softBodyParam)")

		status = attributeAffects(ia_dynamicFrictionCoeff, ca_softBodyParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_dynamicFrictionCoeff, ca_softBodyParam)")

		status = attributeAffects(ia_collisionMargin, ca_softBodyParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_collisionMargin, ca_softBodyParam)")

		status = attributeAffects(ia_numClusters, ca_softBodyParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_numClusters, ca_softBodyParam)")
		return status;
}
Пример #15
0
MStatus boidsBrain::initialize()
{
	MStatus status;
	
	MFnNumericAttribute		nAttr;
	MFnTypedAttribute		tAttr;
	MFnEnumAttribute		eAttr;
	MFnMessageAttribute		mAttr;
	// MFnUnitAttribute		uAttr;

	// MString				attrOpt;
	
	printf("initializing Boidz Locator node\n");
	MGlobal:: displayInfo("initializing Boidz Locator node");

	nodeCreateAttrNum(simulationLength, sl, kInt, BDZ_SIMLEN );
	nodeCreateAttrNum(framesPerSecond, fps, kInt, BDZ_FPS );
	nodeCreateAttrNum(startFrame, stf, kInt, BDZ_STF );
	particleSystem = mAttr.create("particleSystem", "ps");
	nodeAddAttribute(particleSystem);
	nodeCreateAttrNum(boidsNumber, bn, kInt, BDZ_NUM );
	
	nodeCreateAttrTyp(logFilePath, lp);
	nodeCreateAttrTyp(logFileName, ln);
	// inputSurface = tAttr.create( "inputSurface", "is",MFnData::kNurbsSurface,&stat );
	// nodeCreateAttrTyped(logFileName, ln, BDZ_LOGNAME);
	logFileType = eAttr.create("logFileType", "lt", BDZ_LOGTYPE);
	eAttr.addField("nCache file", 0);
	eAttr.addField("log file", 1);
	eAttr.addField("XML file", 2);
	// eAttr.setStorable(true);
	// nodeCreateAttrNum(logFileType, lt, kDouble, BDZ_LOGTYPE);
	nodeAddAttribute(logFileType);
	
	nodeCreateRuleAttributes(alignment, a)
	nodeCreateRuleAttributes(cohesion, c)
	nodeCreateRuleAttributes(separation, s)
	nodeCreateRuleAttributes(follow, f)
	/*
	nodeCreateAttrNum(distance, d, kDouble, BDZ_DIST)
	nodeCreateAttrNum(repulsionFactor, rf, kDouble, BDZ_REPULSION)
	nodeCreateAttrNum(cohesionFactor, cf, kDouble, BDZ_COHESION)
	nodeCreateAttrNum(separationFactor, sf, kDouble, BDZ_SEPARATION)
	nodeCreateAttrNum(approachFactor, af, kDouble, BDZ_APPROACH)
	*/
	locomotionMode = eAttr.create("locomotionMode", "lm", BDZ_LOCMODE);
	eAttr.addField("physical", 0);
	eAttr.addField("simple", 1);
	nodeAddAttribute(locomotionMode);
	// nodeCreateAttrNum(locomotionMode, lm, kInt, BDZ_LOCMODE)
	nodeCreateAttrNum(maxSpeed, ms, kDouble, BDZ_MAXSPEED)
	nodeCreateAttrNum(maxForce, mf, kDouble, BDZ_MAXACCEL)
	// nodeCreateAttrNum(mass, mss, kDouble, BDZ_MASS)

	// check for error
	if( status != MS::kSuccess ) {
		status.perror("Unable to attach one or more attributes to the boidsBrain node");
		return status;
	}
	
	MGlobal:: displayInfo("boidsBrain node attributes applied");

	return MS::kSuccess;
}
Пример #16
0
MStatus rigidBodyNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;
	MFnTypedAttribute typedAttr;

    ia_collisionShape = fnMsgAttr.create("inCollisionShape", "incs", &status);
    MCHECKSTATUS(status, "creating inCollisionShape attribute")
    status = addAttribute(ia_collisionShape);
    MCHECKSTATUS(status, "adding inCollisionShape attribute")

    ia_solver = fnMsgAttr.create("solver", "solv", &status);
    MCHECKSTATUS(status, "creating solver attribute")
    status = addAttribute(ia_solver);
    MCHECKSTATUS(status, "adding solver attribute")

    ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating mass attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_mass);
    MCHECKSTATUS(status, "adding mass attribute")

    ia_restitution = fnNumericAttr.create("restitution", "rst", MFnNumericData::kDouble, 0.1, &status);
    MCHECKSTATUS(status, "creating restitution attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_restitution);
    MCHECKSTATUS(status, "adding restitution attribute")

    ia_friction = fnNumericAttr.create("friction", "fc", MFnNumericData::kDouble, 0.5, &status);
    MCHECKSTATUS(status, "creating friction attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_friction);
    MCHECKSTATUS(status, "adding friction attribute")

    ia_linearDamping = fnNumericAttr.create("linearDamping", "ld", MFnNumericData::kDouble, 0.3, &status);
    MCHECKSTATUS(status, "creating linearDamping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_linearDamping);
    MCHECKSTATUS(status, "adding linearDamping attribute")

    ia_angularDamping = fnNumericAttr.create("angularDamping", "ad", MFnNumericData::kDouble, 0.3, &status);
    MCHECKSTATUS(status, "creating angularDamping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_angularDamping);
    MCHECKSTATUS(status, "adding angularDamping attribute")

    ia_initialPosition = fnNumericAttr.createPoint("initialPosition", "inpo", &status);
    MCHECKSTATUS(status, "creating initialPosition attribute")
    status = addAttribute(ia_initialPosition);
    MCHECKSTATUS(status, "adding initialPosition attribute")

    ia_initialRotation = fnNumericAttr.createPoint("initialRotation", "inro", &status);
    MCHECKSTATUS(status, "creating initialRotation attribute")
    status = addAttribute(ia_initialRotation);
    MCHECKSTATUS(status, "adding initialRotation attribute")

    ia_initialVelocity = fnNumericAttr.createPoint("initialVelocity", "inve", &status);
    MCHECKSTATUS(status, "creating initialVelocity attribute")
    status = addAttribute(ia_initialVelocity);
    MCHECKSTATUS(status, "adding initialVelocity attribute")

    ia_initialSpin = fnNumericAttr.createPoint("initialSpin", "insp", &status);
    MCHECKSTATUS(status, "creating initialSpin attribute")
    status = addAttribute(ia_initialSpin);
    MCHECKSTATUS(status, "adding initialSpin attribute")

	ia_externalForce = fnNumericAttr.createPoint("externalForce", "exfo", &status);
    MCHECKSTATUS(status, "creating externalForce attribute")
    status = addAttribute(ia_externalForce);
    MCHECKSTATUS(status, "adding externalForce attribute")

	ia_externalTorque = fnNumericAttr.createPoint("externalTorque", "exto", &status);
    MCHECKSTATUS(status, "creating externalTorque attribute")
    status = addAttribute(ia_externalTorque);
    MCHECKSTATUS(status, "adding externalTorque attribute")

    ca_rigidBody = fnNumericAttr.create("ca_rigidBody", "carb", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_rigidBody attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_rigidBody);
    MCHECKSTATUS(status, "adding ca_rigidBody attribute")

    ca_rigidBodyParam = fnNumericAttr.create("ca_rigidBodyParam", "carbp", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_rigidBodyParam attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding ca_rigidBodyParam attribute")

    ca_solver = fnNumericAttr.create("ca_solver", "caso", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_solver attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_solver);
    MCHECKSTATUS(status, "adding ca_solver attribute")

	oa_contactCount = fnNumericAttr.create("contactCount", "contactCount", MFnNumericData::kInt, 0, &status);
    MCHECKSTATUS(status, "creating oa_contactCount attribute")
    fnNumericAttr.setConnectable(true);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(oa_contactCount);
    MCHECKSTATUS(status, "adding oa_contactCount attribute");

	MFnStringArrayData stringArrayData;
	oa_contactName = typedAttr.create("contactName", "contactName", MFnData::kStringArray, stringArrayData.create(), &status);
	MCHECKSTATUS(status, "creating oa_contactName attribute")
	typedAttr.setHidden(true);
	status = addAttribute(oa_contactName);
	MCHECKSTATUS(status, "adding oa_contactName attribute");

	oa_contactPosition = typedAttr.create("contactPosition", "contactPosition", MFnVectorArrayData::kVectorArray, &status);	 
	MCHECKSTATUS(status, "creating oa_contactPosition attribute")
	typedAttr.setHidden(true);
    status = addAttribute(oa_contactPosition);
	MCHECKSTATUS(status, "adding oa_contactPosition attribute");

	status = attributeAffects(ia_mass, ca_rigidBody);
    MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)")

    status = attributeAffects(ia_collisionShape, ca_rigidBody);
    MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBody)")

    status = attributeAffects(ia_collisionShape, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBodyParam)")

    status = attributeAffects(ia_mass, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)")

    status = attributeAffects(ia_restitution, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_restitution, ca_rigidBodyParam)")

    status = attributeAffects(ia_friction, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_friction, ca_rigidBodyParam)")

    status = attributeAffects(ia_linearDamping, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_linearDamping, ca_rigidBodyParam)")

    status = attributeAffects(ia_angularDamping, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_angularDamping, ca_rigidBodyParam)")

    status = attributeAffects(ia_initialPosition, ca_rigidBodyParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_initialPosition, ca_rigidBodyParam)")

    status = attributeAffects(ia_solver, ca_solver);
    MCHECKSTATUS(status, "adding attributeAffects(ia_solver, ca_solver)")


    return MS::kSuccess;
}
Пример #17
0
MStatus liqSurfaceNode::initialize()
{
  MFnTypedAttribute   tAttr;
  MFnStringData       tDefault;
  MFnNumericAttribute nAttr;
  MFnEnumAttribute    eAttr;
  MFnMessageAttribute mAttr;
  MFnLightDataAttribute lAttr;
  MStatus status;

  // Create input attributes

  aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status );
  MAKE_INPUT(tAttr);

  aRmanShaderLif = tAttr.create(  MString("rmanShaderLif"),  MString("lif"), MFnData::kString, aRmanShaderLif, &status );
  MAKE_INPUT(tAttr);

  aRmanParams = tAttr.create(  MString("rmanParams"),  MString("rpr"), MFnData::kStringArray, aRmanParams, &status );
  MAKE_INPUT(tAttr);

  aRmanDetails = tAttr.create(  MString("rmanDetails"),  MString("rdt"), MFnData::kStringArray, aRmanDetails, &status );
  MAKE_INPUT(tAttr);

  aRmanTypes = tAttr.create(  MString("rmanTypes"),  MString("rty"), MFnData::kStringArray, aRmanTypes, &status );
  MAKE_INPUT(tAttr);

  aRmanDefaults = tAttr.create(  MString("rmanDefaults"),  MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status );
  MAKE_INPUT(tAttr);

  aRmanArraySizes = tAttr.create(  MString("rmanArraySizes"),  MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status );
  MAKE_INPUT(tAttr);

  aRmanLifCmds = tAttr.create(  MString("rmanLifCmds"),  MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status );
  MAKE_INPUT(tAttr);

  aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status );
  eAttr.addField( "Sphere",   0 );
  eAttr.addField( "Cube",     1 );
  eAttr.addField( "Cylinder", 2 );
  eAttr.addField( "Torus",    3 );
  eAttr.addField( "Plane",    4 );
  eAttr.addField( "Teapot",   5 );
  eAttr.addField( "Custom",   6 );
  eAttr.addField( "(globals)",7 );
  MAKE_NONKEYABLE_INPUT(eAttr);
  CHECK_MSTATUS(eAttr.setConnectable(false));

  aPreviewCustomPrimitive = tAttr.create(  MString("previewCustomPrimitive"),  MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status );
  MAKE_INPUT(tAttr);

  aPreviewCustomBackplane = tAttr.create(  MString("previewCustomBackplane"),  MString("pcb"), MFnData::kString, aPreviewCustomBackplane, &status );
  MAKE_INPUT(tAttr);

  aPreviewCustomLightRig = tAttr.create(  MString("previewCustomLights"),  MString("pcl"), MFnData::kString, aPreviewCustomLightRig, &status );
  MAKE_INPUT(tAttr);

  aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewPixelSamples = nAttr.create("previewPixelSamples", "pxs",  MFnNumericData::kInt, 3, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aPreviewIntensity = nAttr.create("previewIntensity", "pi", MFnNumericData::kDouble, 1.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setConnectable(false));

  aGLPreviewTexture = nAttr.createColor("GLPreviewTexture", "gpt");
  nAttr.setDefault( -1.0, -1.0, -1.0 );
  nAttr.setDisconnectBehavior( MFnAttribute::kReset );
  MAKE_INPUT(nAttr);



  aColor = nAttr.createColor("color", "cs");
  nAttr.setDefault( 1.0, 1.0, 1.0 );
  nAttr.setDisconnectBehavior( MFnAttribute::kReset );
  MAKE_INPUT(nAttr);

  aOpacity = nAttr.createColor("opacity", "os");
  nAttr.setDefault( 1.0, 1.0, 1.0 );
  MAKE_INPUT(nAttr);

  aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status );
  MAKE_INPUT(tAttr);

  aDisplacementBound = nAttr.create("displacementBound", "db", MFnNumericData::kDouble, 0.0, &status);
  MAKE_INPUT(nAttr);

  MObject defaultSpaceObj = tDefault.create( MString("shader"), &status);
  aDisplacementBoundSpace = tAttr.create( MString("displacementBoundSpace"), MString("dbs"), MFnData::kString, defaultSpaceObj, &status );
  MAKE_INPUT(tAttr);

  aOutputInShadow = nAttr.create("outputInShadow", "ois",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);

  // resolution attribute for maya's hardware renderer
  aResolution = nAttr.create("resolution", "res",  MFnNumericData::kInt, 8, &status);
  CHECK_MSTATUS(nAttr.setStorable( true ));
  CHECK_MSTATUS(nAttr.setReadable( true ));
  CHECK_MSTATUS(nAttr.setWritable( true ));
  CHECK_MSTATUS(nAttr.setHidden( true ));

  // refreshPreview must be true to allow refresh
  aRefreshPreview = nAttr.create("refreshPreview", "rfp",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_NONKEYABLE_INPUT(nAttr);
  CHECK_MSTATUS(nAttr.setHidden(true));

  // dynamic shader attr
  aCi = nAttr.createColor("Ci", "ci");
  nAttr.setDefault( 1.0, 1.0, 1.0 );
  MAKE_INPUT(nAttr);

  aOi = nAttr.createColor("Oi", "oi");
  nAttr.setDefault( 1.0, 1.0, 1.0 );
  MAKE_INPUT(nAttr);


  // create attributes for maya renderer

  // lambertian control
  aMayaIgnoreLights = nAttr.create("mayaIgnoreLights", "mil",  MFnNumericData::kBoolean, 0.0, &status);
  MAKE_INPUT(nAttr);
  aMayaKa = nAttr.create("mayaKa", "mka", MFnNumericData::kFloat, 0.2, &status);
  MAKE_INPUT(nAttr);
  aMayaKd = nAttr.create("mayaKd", "mkd", MFnNumericData::kFloat, 0.8, &status);
  MAKE_INPUT(nAttr);

  // Camera Normals
  aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aNormalCameraY = nAttr.create( "normalCameraY", "ny", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aNormalCameraZ = nAttr.create( "normalCameraZ", "nz", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX, aNormalCameraY, aNormalCameraZ, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );

  // Light Direction
  aLightDirectionX = nAttr.create( "lightDirectionX", "ldx", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightDirectionY = nAttr.create( "lightDirectionY", "ldy", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightDirection = nAttr.create( "lightDirection", "ld", aLightDirectionX, aLightDirectionY, aLightDirectionZ, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );

  // Light Intensity
  aLightIntensityR = nAttr.create( "lightIntensityR", "lir", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightIntensityG = nAttr.create( "lightIntensityG", "lig", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightIntensityB = nAttr.create( "lightIntensityB", "lib", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aLightIntensity = nAttr.create( "lightIntensity", "li", aLightIntensityR, aLightIntensityG, aLightIntensityB, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );

  // Light
  aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( true ) );
  aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( true ) );
  aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( false ) );
  aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setReadable( true ) );
  CHECK_MSTATUS( nAttr.setWritable( true ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );
  aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi", MFnNumericData::kFloat, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

  #if MAYA_API_VERSION >= 800
  aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld", 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( (void*) 0 ) );
  #else
  aLightBlindData = nAttr.create( "lightBlindData", "lbld", MFnNumericData::kLong, 0, &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( nAttr.setStorable( false ) );
  CHECK_MSTATUS( nAttr.setHidden( true ) );
  CHECK_MSTATUS( nAttr.setReadable( false ) );
  CHECK_MSTATUS( nAttr.setDefault( 0 ) );
  #endif
  aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection,
                              aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular,
                              aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
                              &status );
  CHECK_MSTATUS( status );
  CHECK_MSTATUS( lAttr.setArray( true ) );
  CHECK_MSTATUS( lAttr.setStorable( false ) );
  CHECK_MSTATUS( lAttr.setHidden( true ) );
  CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 1.0f, 1.0f, 0 ) );

  // Create output attributes
  aOutColor = nAttr.createColor("outColor", "oc");
  MAKE_OUTPUT(nAttr);
  aOutTransparency = nAttr.createColor("outTransparency", "ot");
  MAKE_OUTPUT(nAttr);
  aAssignedObjects = mAttr.create("liqAssignedObjects", "ao");
  MAKE_OUTPUT(mAttr);


  CHECK_MSTATUS(addAttribute(aRmanShader));
  CHECK_MSTATUS(addAttribute(aRmanShaderLong));
  CHECK_MSTATUS(addAttribute(aRmanShaderLif));
  CHECK_MSTATUS(addAttribute(aRmanParams));
  CHECK_MSTATUS(addAttribute(aRmanDetails));
  CHECK_MSTATUS(addAttribute(aRmanTypes));
  CHECK_MSTATUS(addAttribute(aRmanDefaults));
  CHECK_MSTATUS(addAttribute(aRmanArraySizes));
  CHECK_MSTATUS(addAttribute(aRmanLifCmds));

  CHECK_MSTATUS(addAttribute(aPreviewPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewCustomPrimitive));
  CHECK_MSTATUS(addAttribute(aPreviewCustomBackplane));
  CHECK_MSTATUS(addAttribute(aPreviewCustomLightRig));
  CHECK_MSTATUS(addAttribute(aPreviewObjectSize));
  CHECK_MSTATUS(addAttribute(aPreviewPixelSamples));
  CHECK_MSTATUS(addAttribute(aPreviewShadingRate));
  CHECK_MSTATUS(addAttribute(aPreviewBackplane));
  CHECK_MSTATUS(addAttribute(aPreviewIntensity));
  CHECK_MSTATUS(addAttribute(aGLPreviewTexture));
  CHECK_MSTATUS(addAttribute(aCi));
  CHECK_MSTATUS(addAttribute(aOi));

  CHECK_MSTATUS(addAttribute(aColor));
  CHECK_MSTATUS(addAttribute(aOpacity));
  CHECK_MSTATUS(addAttribute(aShaderSpace));
  CHECK_MSTATUS(addAttribute(aDisplacementBound));
  CHECK_MSTATUS(addAttribute(aDisplacementBoundSpace));
  CHECK_MSTATUS(addAttribute(aOutputInShadow));
  CHECK_MSTATUS(addAttribute(aResolution));
  CHECK_MSTATUS(addAttribute(aRefreshPreview));
  CHECK_MSTATUS(addAttribute(aMayaIgnoreLights));
  CHECK_MSTATUS(addAttribute(aMayaKa));
  CHECK_MSTATUS(addAttribute(aMayaKd));
  CHECK_MSTATUS(addAttribute(aNormalCamera));
  CHECK_MSTATUS(addAttribute(aLightData));
  CHECK_MSTATUS(addAttribute(aAssignedObjects));
  CHECK_MSTATUS(addAttribute(aOutColor));
  CHECK_MSTATUS(addAttribute(aOutTransparency));

  CHECK_MSTATUS(attributeAffects( aColor,               aOutColor ));
  CHECK_MSTATUS(attributeAffects( aOpacity,             aOutColor ));
  CHECK_MSTATUS(attributeAffects( aGLPreviewTexture,    aOutColor ));
  CHECK_MSTATUS(attributeAffects( aMayaIgnoreLights,    aOutColor ));
  CHECK_MSTATUS(attributeAffects( aMayaKa,              aOutColor ));
  CHECK_MSTATUS(attributeAffects( aMayaKd,              aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightIntensityR,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightIntensityB,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightIntensityG,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightIntensity,      aOutColor ));
  CHECK_MSTATUS(attributeAffects( aNormalCameraX,       aOutColor ));
  CHECK_MSTATUS(attributeAffects( aNormalCameraY,       aOutColor ));
  CHECK_MSTATUS(attributeAffects( aNormalCameraZ,       aOutColor ));
  CHECK_MSTATUS(attributeAffects( aNormalCamera,        aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightDirectionX,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightDirectionY,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightDirectionZ,     aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightDirection,      aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightAmbient,        aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightSpecular,       aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightDiffuse,        aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightShadowFraction, aOutColor ));
  CHECK_MSTATUS(attributeAffects( aPreShadowIntensity,  aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightBlindData,      aOutColor ));
  CHECK_MSTATUS(attributeAffects( aLightData,           aOutColor ));

  return MS::kSuccess;
}
Пример #18
0
MStatus sixdofConstraintNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnMatrixAttribute fnMatrixAttr;

    ia_rigidBodyA = fnMsgAttr.create("inRigidBodyA", "inrbA", &status);
    MCHECKSTATUS(status, "creating inRigidBodyA attribute")
    status = addAttribute(ia_rigidBodyA);
    MCHECKSTATUS(status, "adding inRigidBody attribute")

    ia_rigidBodyB = fnMsgAttr.create("inRigidBodyB", "inrbB", &status);
    MCHECKSTATUS(status, "creating inRigidBodyB attribute")
    status = addAttribute(ia_rigidBodyB);
    MCHECKSTATUS(status, "adding inRigidBodyB attribute")

	ia_damping = fnNumericAttr.create("damping", "dmp", MFnNumericData::kDouble, 1.0, &status);
    MCHECKSTATUS(status, "creating damping attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_damping);
    MCHECKSTATUS(status, "adding damping attribute")

    ia_lowerLinLimit = fnNumericAttr.create("lowerLinLimit", "lllt", MFnNumericData::kDouble, 1, &status);
    MCHECKSTATUS(status, "creating lower linear limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerLinLimit);
    MCHECKSTATUS(status, "adding lower linear limit attribute")

	ia_upperLinLimit = fnNumericAttr.create("upperLinLimit", "ullt", MFnNumericData::kDouble, -1, &status);
    MCHECKSTATUS(status, "creating upper linear limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperLinLimit);
    MCHECKSTATUS(status, "adding upper linear limit attribute")

    ia_lowerAngLimit = fnNumericAttr.create("lowerAngLimit", "lalt", MFnNumericData::kDouble, 0, &status);
    MCHECKSTATUS(status, "creating lower angular limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_lowerAngLimit);
    MCHECKSTATUS(status, "adding lower angular limit attribute")

	ia_upperAngLimit = fnNumericAttr.create("upperAngLimit", "ualt", MFnNumericData::kDouble, 0, &status);
    MCHECKSTATUS(status, "creating upper angular limit attribute")
    fnNumericAttr.setKeyable(true);
    status = addAttribute(ia_upperAngLimit);
    MCHECKSTATUS(status, "adding upper angular limit attribute")

	ca_constraint = fnNumericAttr.create("ca_constraint", "caco", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraint attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraint);
    MCHECKSTATUS(status, "adding ca_constraint attribute")

    ca_constraintParam = fnNumericAttr.create("ca_constraintParam", "cacop", MFnNumericData::kBoolean, 0, &status);
    MCHECKSTATUS(status, "creating ca_constraintParam attribute")
    fnNumericAttr.setConnectable(false);
    fnNumericAttr.setHidden(true);
    fnNumericAttr.setStorable(false);
    fnNumericAttr.setKeyable(false);
    status = addAttribute(ca_constraintParam);
    MCHECKSTATUS(status, "adding ca_constraintParam attribute")


    status = attributeAffects(ia_rigidBodyA, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraint)")

    status = attributeAffects(ia_rigidBodyA, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyA, ca_constraintParam)")

    status = attributeAffects(ia_rigidBodyB, ca_constraint);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraint)")

    status = attributeAffects(ia_rigidBodyB, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_rigidBodyB, ca_constraintParam)")

	status = attributeAffects(ia_damping, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_damping, ca_constraintParam)")

    status = attributeAffects(ia_lowerLinLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_lowerLinLimit, ca_constraintParam)")

	status = attributeAffects(ia_upperLinLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_upperLinLimit, ca_constraintParam)")

    status = attributeAffects(ia_lowerAngLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_lowerAngLimit, ca_constraintParam)")

	status = attributeAffects(ia_upperAngLimit, ca_constraintParam);
    MCHECKSTATUS(status, "adding attributeAffects(ia_upperAngLimit, ca_constraintParam)")

	return MS::kSuccess;
}
Пример #19
0
MStatus	MayaToIndigoGlobals::initialize()
{
	MayaRenderGlobalsNode::initialize();

	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

	MStatus stat = MStatus::kSuccess;

//	------------- automatically created attributes start ----------- // 

	white_point = eAttr.create("white_point", "white_point", 4, &stat);
	stat = eAttr.addField( "User", 0 );
	stat = eAttr.addField( "A", 1 );
	stat = eAttr.addField( "B", 2 );
	stat = eAttr.addField( "C", 3 );
	stat = eAttr.addField( "D50", 4 );
	stat = eAttr.addField( "D55", 5 );
	stat = eAttr.addField( "D65", 6 );
	stat = eAttr.addField( "D75", 7 );
	stat = eAttr.addField( "E", 8 );
	stat = eAttr.addField( "F1", 9 );
	stat = eAttr.addField( "F2", 10 );
	stat = eAttr.addField( "F3", 11 );
	stat = eAttr.addField( "F4", 12 );
	stat = eAttr.addField( "F5", 13 );
	stat = eAttr.addField( "F6", 14 );
	stat = eAttr.addField( "F7", 15 );
	stat = eAttr.addField( "F8", 16 );
	stat = eAttr.addField( "F9", 17 );
	stat = eAttr.addField( "F10", 18 );
	stat = eAttr.addField( "F11", 19 );
	stat = eAttr.addField( "F12", 20 );
	CHECK_MSTATUS(addAttribute( white_point ));

	white_pointX = nAttr.create("white_pointX", "white_pointX",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( white_pointX ));

	white_pointY = nAttr.create("white_pointY", "white_pointY",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( white_pointY ));

	bih_tri_threshold = nAttr.create("bih_tri_threshold", "bih_tri_threshold",  MFnNumericData::kInt, 1100000);
	CHECK_MSTATUS(addAttribute( bih_tri_threshold ));

	metropolis = nAttr.create("metropolis", "metropolis",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( metropolis ));

	large_mutation_prob = nAttr.create("large_mutation_prob", "large_mutation_prob",  MFnNumericData::kFloat, 0.1);
	CHECK_MSTATUS(addAttribute( large_mutation_prob ));

	max_change = nAttr.create("max_change", "max_change",  MFnNumericData::kFloat, .01);
	CHECK_MSTATUS(addAttribute( max_change ));

	max_num_consec_rejections = nAttr.create("max_num_consec_rejections", "max_num_consec_rejections",  MFnNumericData::kInt, 1000);
	CHECK_MSTATUS(addAttribute( max_num_consec_rejections ));

	logging = nAttr.create("logging", "logging",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( logging ));

	path_tracing = eAttr.create("path_tracing", "path_tracing", 0, &stat);
	stat = eAttr.addField( "bidirectional", 0 );
	stat = eAttr.addField( "backwards", 1 );
	CHECK_MSTATUS(addAttribute( path_tracing ));

	tone_mapper = eAttr.create("tone_mapper", "tone_mapper", 1, &stat);
	stat = eAttr.addField( "linear", 0 );
	stat = eAttr.addField( "reinhard", 1 );
	stat = eAttr.addField( "camera", 2 );
	CHECK_MSTATUS(addAttribute( tone_mapper ));

	tone_linearScale = nAttr.create("tone_linearScale", "tone_linearScale",  MFnNumericData::kFloat, 1.0);
	nAttr.setMin(0.0001);
	nAttr.setMax(100);
	CHECK_MSTATUS(addAttribute( tone_linearScale ));

	tone_reinhardPreScale = nAttr.create("tone_reinhardPreScale", "tone_reinhardPreScale",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( tone_reinhardPreScale ));

	tone_reinhardPostScale = nAttr.create("tone_reinhardPostScale", "tone_reinhardPostScale",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( tone_reinhardPostScale ));

	tone_reinhardBurn = nAttr.create("tone_reinhardBurn", "tone_reinhardBurn",  MFnNumericData::kFloat, 10.0);
	CHECK_MSTATUS(addAttribute( tone_reinhardBurn ));

	tone_cameraResponse_function_path = tAttr.create("tone_cameraResponse_function_path", "tone_cameraResponse_function_path",  MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( tone_cameraResponse_function_path ));

	tone_cameraEv_adjust = nAttr.create("tone_cameraEv_adjust", "tone_cameraEv_adjust",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( tone_cameraEv_adjust ));

	tone_cameraFilm_iso = nAttr.create("tone_cameraFilm_iso", "tone_cameraFilm_iso",  MFnNumericData::kFloat, 200.0);
	CHECK_MSTATUS(addAttribute( tone_cameraFilm_iso ));

	save_untonemapped_exr = nAttr.create("save_untonemapped_exr", "save_untonemapped_exr",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( save_untonemapped_exr ));

	save_tonemapped_exr = nAttr.create("save_tonemapped_exr", "save_tonemapped_exr",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( save_tonemapped_exr ));

	save_igi = nAttr.create("save_igi", "save_igi",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( save_igi ));

	image_save_period = nAttr.create("image_save_period", "image_save_period",  MFnNumericData::kFloat, 60);
	CHECK_MSTATUS(addAttribute( image_save_period ));

	halt_time = nAttr.create("halt_time", "halt_time",  MFnNumericData::kFloat, -1);
	CHECK_MSTATUS(addAttribute( halt_time ));

	halt_samples_per_pixel = nAttr.create("halt_samples_per_pixel", "halt_samples_per_pixel",  MFnNumericData::kInt, -1);
	CHECK_MSTATUS(addAttribute( halt_samples_per_pixel ));

	hybrid = nAttr.create("hybrid", "hybrid",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( hybrid ));

	auto_choose_num_threads = nAttr.create("auto_choose_num_threads", "auto_choose_num_threads",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( auto_choose_num_threads ));

	num_threads = nAttr.create("num_threads", "num_threads",  MFnNumericData::kBoolean, 1);
	CHECK_MSTATUS(addAttribute( num_threads ));

	super_sample_factor = nAttr.create("super_sample_factor", "super_sample_factor",  MFnNumericData::kInt, 2);
	CHECK_MSTATUS(addAttribute( super_sample_factor ));

	watermark = nAttr.create("watermark", "watermark",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( watermark ));

	info_overlay = nAttr.create("info_overlay", "info_overlay",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( info_overlay ));

	cache_trees = nAttr.create("cache_trees", "cache_trees",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( cache_trees ));

	aperture_diffraction = nAttr.create("aperture_diffraction", "aperture_diffraction",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( aperture_diffraction ));

	post_process_diffraction = nAttr.create("post_process_diffraction", "post_process_diffraction",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( post_process_diffraction ));

	render_foreground_alpha = nAttr.create("render_foreground_alpha", "render_foreground_alpha",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( render_foreground_alpha ));

	splat_filter = eAttr.create("splat_filter", "splat_filter", 0, &stat);
	stat = eAttr.addField( "fastbox", 0 );
	stat = eAttr.addField( "radial", 1 );
	stat = eAttr.addField( "mn_cubic", 2 );
	CHECK_MSTATUS(addAttribute( splat_filter ));

	splat_filter_cubic_b = nAttr.create("splat_filter_cubic_b", "splat_filter_cubic_b",  MFnNumericData::kFloat, 0.6);
	CHECK_MSTATUS(addAttribute( splat_filter_cubic_b ));

	splat_filter_cubic_ring = nAttr.create("splat_filter_cubic_ring", "splat_filter_cubic_ring",  MFnNumericData::kFloat, 0.2);
	CHECK_MSTATUS(addAttribute( splat_filter_cubic_ring ));

	downsize_filter = eAttr.create("downsize_filter", "downsize_filter", 0, &stat);
	stat = eAttr.addField( "mn_cubic", 0 );
	stat = eAttr.addField( "gauss", 1 );
	stat = eAttr.addField( "sharp", 2 );
	CHECK_MSTATUS(addAttribute( downsize_filter ));

	downsize_filter_cubic_radius = nAttr.create("downsize_filter_cubic_radius", "downsize_filter_cubic_radius",  MFnNumericData::kFloat, 2);
	CHECK_MSTATUS(addAttribute( downsize_filter_cubic_radius ));

	vignetting = nAttr.create("vignetting", "vignetting",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( vignetting ));

	gpu = nAttr.create("gpu", "gpu",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( gpu ));

	selected_gpu_device = eAttr.create("selected_gpu_device", "selected_gpu_device", 0, &stat);
	stat = eAttr.addField( "CUDA", 0 );
	stat = eAttr.addField( "OPEN_CL", 1 );
	CHECK_MSTATUS(addAttribute( selected_gpu_device ));

	glass_acceleration = nAttr.create("glass_acceleration", "glass_acceleration",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( glass_acceleration ));

	environmentType = eAttr.create("environmentType", "environmentType", 1, &stat);
	stat = eAttr.addField( "Off", 0 );
	stat = eAttr.addField( "Color/Map", 1 );
	stat = eAttr.addField( "Sun", 2 );
	CHECK_MSTATUS(addAttribute( environmentType ));

	environmentColor = nAttr.createColor("environmentColor", "environmentColor");
	nAttr.setDefault(0.4,0.4,1.0);
	CHECK_MSTATUS(addAttribute( environmentColor ));

	environmentSun = mAttr.create("environmentSun", "environmentSun");
	CHECK_MSTATUS(addAttribute( environmentSun ));

	turbidity = nAttr.create("turbidity", "turbidity",  MFnNumericData::kFloat, 2.0);
	CHECK_MSTATUS(addAttribute( turbidity ));

	extra_atmospheric = nAttr.create("extra_atmospheric", "extra_atmospheric",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( extra_atmospheric ));

	sun_layer = nAttr.create("sun_layer", "sun_layer",  MFnNumericData::kInt, 0);
	CHECK_MSTATUS(addAttribute( sun_layer ));

	sky_layer = nAttr.create("sky_layer", "sky_layer",  MFnNumericData::kInt, 0);
	CHECK_MSTATUS(addAttribute( sky_layer ));

	sky_model = eAttr.create("sky_model", "sky_model", 0, &stat);
	stat = eAttr.addField( "original", 0 );
	stat = eAttr.addField( "captured-simulation", 1 );
	CHECK_MSTATUS(addAttribute( sky_model ));

	environmentMapType = eAttr.create("environmentMapType", "environmentMapType", 0, &stat);
	stat = eAttr.addField( "Spherical", 0 );
	stat = eAttr.addField( "Lat-Long", 1 );
	CHECK_MSTATUS(addAttribute( environmentMapType ));

	environmentMapMultiplier = nAttr.create("environmentMapMultiplier", "environmentMapMultiplier",  MFnNumericData::kFloat, 1.0);
	CHECK_MSTATUS(addAttribute( environmentMapMultiplier ));

	MFnStringData	fnStringData;
	MObject	defaultString;

	defaultString = fnStringData.create( "notepad.exe" );
	preferredTextEditor = tAttr.create("preferredTextEditor", "preferredTextEditor",  MFnNumericData::kString, defaultString);
	CHECK_MSTATUS(addAttribute( preferredTextEditor ));

//	------------- automatically created attributes end ----------- // 

	return stat;

}
MStatus lrutils::loadGeoReference(MString geoFilePath, MString geoName, MString & name, MObject & geoObj) {
    MStatus status = MS::kFailure;

    MString projPath = MGlobal::executeCommandStringResult(MString("workspace -q -rd;"),false,false);
    MString relativePath = geoFilePath.substring(2,geoFilePath.numChars() - 1);

    //assemble the full file path of the geometry file
    MString fullGeoPath = projPath + relativePath;

    //load the geometry file as a reference into the current scene
    //check to see if the referenced file has already been used
    MStringArray refNodeList;
    status = MFileIO::getReferences(refNodeList, true);
    MyCheckStatus(status, "getReferences failed");
    int numReferences = 0;
    for(unsigned int i = 0; i < refNodeList.length(); i++) {
        MString tmp = refNodeList[i];
        string tmp1 = tmp.asChar();
        string tmp2 = fullGeoPath.asChar();
        if(std::string::npos != tmp1.find(tmp2))
            numReferences++;
    }
    string str (geoFilePath.asChar());
    string key ("/");
    size_t found = str.rfind(key);
    string fileName = str.substr(found+1,str.length()-found-4);
    string fileNamespace;
    if(numReferences > 0) {
        stringstream tmp;
        tmp << fileName << (numReferences+1);
        fileNamespace = tmp.str();
    } else { fileNamespace = fileName; }

    {
        stringstream tmp;
        tmp << "file -r -type \"mayaAscii\" -gl -loadReferenceDepth \"all\" -namespace \"" << fileNamespace.c_str() << "\" -options \"v=0\" \"" << fullGeoPath.asChar() << "\";";
        MString referenceCommand = MString(tmp.str().c_str());
        MGlobal::executeCommand(referenceCommand);
    }
    
    //get the referenced geometry transform node and add the metaParent
    //attribute to it
    MSelectionList selection;
    if(numReferences > 0) {
        name += (boost::lexical_cast<string>(numReferences+1)).c_str();
    }
    stringstream geoRefName;
    geoRefName << fileNamespace << ":" << geoName;
    MString mGeoRefName = MString(geoRefName.str().c_str());
    status = selection.add( mGeoRefName, true );
    MyCheckStatusReturn(status, "add geoRefName "+mGeoRefName+" to selection failed.");

    if(selection.length() )
        selection.getDependNode(0, geoObj);

    MFnTransform transformFn;
    transformFn.setObject(geoObj);
    MFnMessageAttribute mAttr;
    MObject transformAttr = mAttr.create("metaParent", "metaParent");
    transformFn.addAttribute(transformAttr);

    if( !geoObj.isNull() )
        status = MS::kSuccess;

    return status;
}
Пример #21
0
MStatus collisionShapeNode::initialize()
{
	MStatus status;
	MFnMessageAttribute fnMsgAttr;
	MFnNumericAttribute fnNumericAttr;
	MFnEnumAttribute fnEnumAttr;

	ia_type = fnEnumAttr.create("type", "tp", 7, &status);
	MCHECKSTATUS(status, "creating type attribute")
		fnEnumAttr.addField("Convex Hull", 0);
	fnEnumAttr.addField("Mesh", 1);
	fnEnumAttr.addField("Cylinder", 2);
	fnEnumAttr.addField("Capsule", 3);
	fnEnumAttr.addField("Box", 4);
	fnEnumAttr.addField("Sphere", 5);
	fnEnumAttr.addField("Plane", 6);
	fnEnumAttr.addField("BvhMesh", 7);
	fnEnumAttr.addField("HACD", 8);
	fnEnumAttr.setKeyable(true);
	status = addAttribute(ia_type);
	MCHECKSTATUS(status, "adding type attribute")

		ia_scale = fnNumericAttr.createPoint("scale", "sc", &status);
	MCHECKSTATUS(status, "creating ia_scale attribute")
		fnNumericAttr.setDefault(1.0, 1.0, 1.0);
	fnNumericAttr.setKeyable(true);
	status = addAttribute(ia_scale);
	MCHECKSTATUS(status, "adding ia_scale attribute")

		oa_collisionShape = fnMsgAttr.create("outCollisionShape", "oucs", &status);
	MCHECKSTATUS(status, "creating outCollisionShape attribute")
		status = addAttribute(oa_collisionShape);
	MCHECKSTATUS(status, "adding outCollisionShape attribute")

		ia_shape = fnMsgAttr.create("inShape", "insh", &status);
	MCHECKSTATUS(status, "creating inShape attribute")
		status = addAttribute(ia_shape);
	MCHECKSTATUS(status, "adding inShape attribute")

		ca_collisionShape = fnNumericAttr.create("ca_collisionShape", "ccs", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_collisionShape attribute")
		fnNumericAttr.setWorldSpace(true);
	fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_collisionShape);
	MCHECKSTATUS(status, "adding ca_collisionShape attribute")

		ca_collisionShapeParam = fnNumericAttr.create("collisionShapeParam", "cspm", MFnNumericData::kBoolean, 0, &status);
	MCHECKSTATUS(status, "creating ca_collisionShapeParam attribute")
		fnNumericAttr.setConnectable(false);
	fnNumericAttr.setHidden(true);
	fnNumericAttr.setStorable(false);
	fnNumericAttr.setKeyable(false);
	status = addAttribute(ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding ca_collisionShapeParam attribute")

		//
		status = attributeAffects(ia_shape, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShape)")

		status = attributeAffects(ia_type, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShape)")

		status = attributeAffects(ia_scale, oa_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShape)")

		//
		status = attributeAffects(ia_shape, ca_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")

		status = attributeAffects(ia_type, ca_collisionShape);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, ca_collisionShape)")

		//
		status = attributeAffects(ia_shape, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_shape, oa_collisionShapeParam)")

		status = attributeAffects(ia_scale, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_scale, oa_collisionShapeParam)")

		status = attributeAffects(ia_type, ca_collisionShapeParam);
	MCHECKSTATUS(status, "adding attributeAffects(ia_type, oa_collisionShapeParam)")

		return MS::kSuccess;
}
MObject GlobalComponent::loadComponent(MDGModifier & dgMod) {
    MStatus status = MS::kFailure;
    this->m_metaDataNode = dgMod.createNode( "MDGlobalNode", &status );
    MyCheckStatus(status, "createNode failed");

    MString metaNodeName = "MGN_";
    metaNodeName += this->m_rigName + "_";
    metaNodeName += this->m_pCompGuide->getName();
    dgMod.renameNode(this->m_metaDataNode, metaNodeName);

    MFnDependencyNode depMetaDataNodeFn(this->m_metaDataNode);
    status = dgMod.newPlugValueFloat( depMetaDataNodeFn.findPlug("version"), this->m_pCompGuide->getVersion() );
    MyCheckStatus(status, "newPlugValueFloat() failed");
    status = dgMod.newPlugValueString( depMetaDataNodeFn.findPlug("rigId"), this->m_pCompGuide->getRigId() );
    MyCheckStatus(status, "newPlugValueInt() failed");

    GlobalComponentGuidePtr globalGuide = boost::dynamic_pointer_cast<GlobalComponentGuide>(this->m_pCompGuide);
    MString ctlColor = globalGuide->getColor();
    MString ctlIcon = globalGuide->getIcon();

    status = MGlobal::executeCommand( "python(\"control = rig101().rig101WCGetByName('" + ctlIcon + "')\");" );
    status = MGlobal::executeCommand( "python(\"Utils.setControllerColor(control, '" + ctlColor + "')\");" );
    MCommandResult res;
    status = MGlobal::executeCommand( MString("python(\"control.fullPath()\");"), res );
    int resType = res.resultType();
    if( resType == MCommandResult::kString ) {
        MString sResult;
        res.getResult(sResult);
        MObject ctlObj;
        status = lrutils::getObjFromName(sResult, ctlObj);
        MyCheckStatus(status, "lrutils::getObjFromName() failed");

        MVectorArray ctlLocation = this->m_pCompGuide->getLocation(0);
        MFnTransform transformFn( ctlObj );
        lrutils::setLocation(ctlObj, ctlLocation, MFnTransform::MFnTransform(), false, false, true);

        MString ctlName = this->m_rigName + "_" + this->m_pCompGuide->getName() + "_CTL";
        dgMod.renameNode(ctlObj, ctlName);
        dgMod.doIt();

        //add the metaParent attribute to the controller
        MFnMessageAttribute mAttr;
        MObject transformAttr = mAttr.create("metaParent", "metaParent");
        transformFn.addAttribute(transformAttr);
        //connect the controller's metaParent to the MDGlobal node
        status = dgMod.connect( depMetaDataNodeFn.findPlug("controller"), transformFn.findPlug("metaParent") );

        MObject ctlGroupObj;
        lrutils::makeHomeNull(ctlObj, MFnTransform(), ctlGroupObj);
        lrutils::setLocation(ctlGroupObj, ctlLocation, MFnTransform::MFnTransform(), true, true, false);
        MFnTransform ctlGroupFn( ctlGroupObj );
        //add the metaParent attribute to the controller group
        ctlGroupFn.addAttribute(mAttr.create("metaParent", "metaParent"));
        //connect the controller group's metaParent to the MDGlobal node
        status = dgMod.connect( depMetaDataNodeFn.findPlug("controllerGroup"), ctlGroupFn.findPlug("metaParent") );
        MyCheckStatus(status, "connect failed"); 
        MObject metaRootObj;
        status = lrutils::getMetaRootByName(metaRootObj, this->m_rigName);
        MyCheckStatus(status, "lrutils::getMetaRootByName() failed");
        MObject rigCtlGroupObj;
        status = lrutils::getMetaNodeConnection(metaRootObj, rigCtlGroupObj, "ctlGroup");
        MyCheckStatus(status, "lrutils::getMetaNodeConnection() failed");
        MFnTransform rigCtlGroupFn( rigCtlGroupObj );
        rigCtlGroupFn.addChild( ctlGroupObj );

        //add controller to controller display layer
        MObject controlLayerObj;
        status = lrutils::getMetaNodeConnection(metaRootObj, controlLayerObj, "ctlLayer");
        MyCheckStatus(status, "lrutils::getMetaNodeConnection() failed");
        MFnDependencyNode controlLayerFn(controlLayerObj);
        MString controlLayerName = controlLayerFn.name();
        MGlobal::executeCommand("editDisplayLayerMembers -noRecurse "+controlLayerName+" "+rigCtlGroupFn.name()+";");
        //create parent constraints from the global controller to the rig group
        MObject rigRigGroupObj;
        status = lrutils::getMetaNodeConnection(metaRootObj, rigRigGroupObj, "rigGroup");
        MFnTransform rigRigGroupFn( rigRigGroupObj );
        MGlobal::executeCommand("parentConstraint -mo "+transformFn.name()+" "+rigRigGroupFn.name()+";", res);
        //connect the parent constraint object to the component's metadata node
        MStringArray sResults;
        res.getResult(sResults);
        status = lrutils::getObjFromName(sResults[0], this->m_rigParentConstraint);
        MyCheckStatus(status, "lrutils::getObjFromName() failed");
        MFnTransform rigParentConstraintFn( this->m_rigParentConstraint);
        rigParentConstraintFn.addAttribute(mAttr.create("metaParent", "metaParent"));
        status = dgMod.connect( depMetaDataNodeFn.findPlug("rigParentConstraint"), rigParentConstraintFn.findPlug("metaParent"));
        //create the scale constraint from the global controller to the rig group
        MGlobal::executeCommand("scaleConstraint -mo "+transformFn.name()+" "+rigRigGroupFn.name()+";", res);
        //connect the scale constraint object to the component's metadata node
        res.getResult(sResults);
        status = lrutils::getObjFromName(sResults[0], this->m_rigScaleConstraint);
        MyCheckStatus(status, "lrutils::getObjFromName() failed");
        MFnTransform rigScaleConstraintFn( this->m_rigScaleConstraint );
        rigScaleConstraintFn.addAttribute(mAttr.create("metaParent", "metaParent"));
        status = dgMod.connect( depMetaDataNodeFn.findPlug("rigScaleConstraint"), rigScaleConstraintFn.findPlug("metaParent"));
        //create scale constraint from the global controller to the noTransform group
        MObject rigNoTransformGroupObj;
        status = lrutils::getMetaNodeConnection(metaRootObj, rigNoTransformGroupObj, "noTransformGroup");
        MFnTransform rigNoTransformGroupFn( rigNoTransformGroupObj );
        MGlobal::executeCommand("scaleConstraint -mo "+transformFn.name()+" "+rigNoTransformGroupFn.name()+";", res);
        //connect the scale constraint object to the component's metadata node
        res.getResult(sResults);
        status = lrutils::getObjFromName(sResults[0], this->m_noTransformScaleConstraint);
        MyCheckStatus(status, "lrutils::getObjFromName() failed");
        MFnTransform noTransformScaleConstraintFn( this->m_noTransformScaleConstraint);
        noTransformScaleConstraintFn.addAttribute(mAttr.create("metaParent", "metaParent"));
        status = dgMod.connect( depMetaDataNodeFn.findPlug("noTransformScaleConstraint"), noTransformScaleConstraintFn.findPlug("metaParent"));
    }

    return this->m_metaDataNode;
}
Пример #23
0
void EntityNode::AddImportNode( const MObject& object )
{
    MStatus stat;
    MObjectHandle handle( object );
    if( !handle.isValid() )
    {
        return;
    }

    MFnDependencyNode nodeFn( object, &stat );
    MCheckNoErr( stat, "Unable to create depenency node fn set" );
    nodeFn.setDoNotWrite( true );

    //MItDependencyGraph childrenIt (MItDependencyGraph::kUpstream);
    //for ( childrenIt.reset( nodeFn.object() ); !childrenIt.isDone(); childrenIt.next() )
    //{
    //  MFnDependencyNode( childrenIt.item() ).setDoNotWrite( true );
    //}

    MString name = nodeFn.name( &stat );
    MCheckNoErr( stat, "Unable to get node name" );

    if( name == "" )
    {
        return;
    }

    // don't connect dag nodes to the ImportNodes attributeb array
    if( object.hasFn( MFn::kDagNode ) )
    {
        return;
    }

#ifdef _DEBUG
    std::cout << "Adding: " << name.asTChar() << std::endl;
#endif

    //create ImportMessage attrib on the imported object if necessary
    if( !nodeFn.hasAttribute( "ImportMessage", &stat ) )
    {
        MFnMessageAttribute mAttr;
        MObject importMessage = mAttr.create( "ImportMessage", "imp", &stat );
        MCheckNoErr(stat, "Unable to create attr: ImportMessage");

        stat = nodeFn.addAttribute( importMessage );
        MCheckNoErr(stat, "Unable to add attr: ImportNodes"); 
    }

    MPlug importMsg = nodeFn.findPlug( "ImportMessage", &stat );
    MCheckNoErr(stat, "Unable to find attr: ImportMessage");

    MPlug importPlug( thisMObject(), m_ImportNodes );
    u32 currentIdx = importPlug.numConnectedElements();
    MPlug importElement = importPlug.elementByLogicalIndex( currentIdx );

    MDGModifier mod;

    //if it's currently connected, disconnect it
    if( importMsg.isConnected() )
    {
        MPlugArray plugs;
        importMsg.connectedTo( plugs, true, false );
        if( plugs.length() == 1 )
        {
            mod.disconnect( importMsg, plugs[0] );
        }
    }
    stat = mod.connect( importMsg, importElement );
    mod.doIt();
}
Пример #24
0
MStatus inSpecular::initialize()
{
	MFnNumericAttribute nAttr;
	MFnLightDataAttribute lAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

    MStatus status; // Status will be used to hold the MStatus value
                    // returned by each api function call. It is important
                    // to check the status returned by a call to aid in
                    // debugging. Failed API calls can result in subtle
                    // errors that can be difficult to track down, you may
                    // wish to use the CHECK_MSTATUS macro for any API
                    // call where you do not need to provide your own
                    // error handling.
                    //

//---------------------------- automatically created attributes start ------------------------------------
	backface_emit = nAttr.create("backface_emit", "backface_emit",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( backface_emit ));

	layer = nAttr.create("layer", "layer",  MFnNumericData::kInt, 0);
	CHECK_MSTATUS(addAttribute( layer ));

	iesProfile = tAttr.create("iesProfile", "iesProfile",  MFnNumericData::kString);
	CHECK_MSTATUS(addAttribute( iesProfile ));

	internal_medium_name = mAttr.create("internal_medium_name", "internal_medium_name");
	CHECK_MSTATUS(addAttribute( internal_medium_name ));

	bump = nAttr.create("bump", "bump",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( bump ));

	base_emission = nAttr.createColor("base_emission", "base_emission");
	nAttr.setDefault(0.0,0.0,0.0);
	CHECK_MSTATUS(addAttribute( base_emission ));

	displacement = nAttr.create("displacement", "displacement",  MFnNumericData::kFloat, 0.0);
	CHECK_MSTATUS(addAttribute( displacement ));

	emission = nAttr.createColor("emission", "emission");
	nAttr.setDefault(0.0,0.0,0.0);
	CHECK_MSTATUS(addAttribute( emission ));

	normalMap = nAttr.createColor("normalMap", "normalMap");
	nAttr.setDefault(0,0,0);
	CHECK_MSTATUS(addAttribute( normalMap ));

	transparent = nAttr.create("transparent", "transparent",  MFnNumericData::kBoolean, false);
	CHECK_MSTATUS(addAttribute( transparent ));

//---------------------------- automatically created attributes end ------------------------------------

    // Input Attributes
    //
    aTranslucenceCoeff = nAttr.create( "translucenceCoeff", "tc",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

    aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.8f ) );

    aColor = nAttr.createColor( "color", "c", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) );

    aIncandescence = nAttr.createColor( "incandescence", "ic", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );

    aInTransparency = nAttr.createColor( "transparency", "it", &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );

    // Color Output
    //
    aOutColor = nAttr.createColor( "outColor", "oc", &status );
    CHECK_MSTATUS( status );

    CHECK_MSTATUS( nAttr.setHidden( false ) );
    CHECK_MSTATUS( nAttr.setReadable( true ) );
    CHECK_MSTATUS( nAttr.setWritable( false ) );

    aOutTransparency = nAttr.createColor( "outTransparency", "ot", &status );
    CHECK_MSTATUS( status );

    CHECK_MSTATUS( nAttr.setHidden( false ) );
    CHECK_MSTATUS( nAttr.setReadable( true ) );
    CHECK_MSTATUS( nAttr.setWritable( false ) );

    // Camera Normals
    //
    aNormalCameraX = nAttr.create( "normalCameraX", "nx",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCameraY = nAttr.create( "normalCameraY", "ny",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCameraZ = nAttr.create( "normalCameraZ", "nz",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX,
            aNormalCameraY, aNormalCameraZ, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable( false ) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );
    CHECK_MSTATUS( nAttr.setHidden( true ) );


    // Light Direction
    //
    aLightDirectionX = nAttr.create( "lightDirectionX", "ldx",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirectionY = nAttr.create( "lightDirectionY", "ldy",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightDirection = nAttr.create( "lightDirection", "ld",
            aLightDirectionX, aLightDirectionY, aLightDirectionZ,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );


    // Light Intensity
    //
    aLightIntensityR = nAttr.create( "lightIntensityR", "lir",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensityG = nAttr.create( "lightIntensityG", "lig",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensityB = nAttr.create( "lightIntensityB", "lib",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightIntensity = nAttr.create( "lightIntensity", "li",
            aLightIntensityR, aLightIntensityG, aLightIntensityB,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) );


    // Light
    //
    aLightAmbient = nAttr.create( "lightAmbient", "la",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( true ) );

    aLightDiffuse = nAttr.create( "lightDiffuse", "ldf",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( true ) );

    aLightSpecular = nAttr.create( "lightSpecular", "ls",
            MFnNumericData::kBoolean, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( false ) );

    aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi",
            MFnNumericData::kFloat, 0, &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );
    CHECK_MSTATUS( nAttr.setDefault( 1.0f ) );

    aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld",
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );

    aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection,
            aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular,
            aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
            &status );
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( lAttr.setArray( true ) );
    CHECK_MSTATUS( lAttr.setStorable( false ) );
    CHECK_MSTATUS( lAttr.setHidden( true ) );
    CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
            true, true, false, 1.0f, 1.0f, NULL ) );


    // Next we will add the attributes we have defined to the node
    //
    CHECK_MSTATUS( addAttribute( aTranslucenceCoeff ) );
    CHECK_MSTATUS( addAttribute( aDiffuseReflectivity ) );
    CHECK_MSTATUS( addAttribute( aColor ) );
    CHECK_MSTATUS( addAttribute( aIncandescence ) );
    CHECK_MSTATUS( addAttribute( aInTransparency ) );
    CHECK_MSTATUS( addAttribute( aOutColor ) );
    CHECK_MSTATUS( addAttribute( aOutTransparency ) );
    CHECK_MSTATUS( addAttribute( aNormalCamera ) );

    // Only add the parent of the compound
    CHECK_MSTATUS( addAttribute( aLightData ) );

    // The attributeAffects() method is used to indicate when the input
    // attribute affects the output attribute. This knowledge allows Maya
    // to optimize dependencies in the graph in more complex nodes where
    // there may be several inputs and outputs, but not all the inputs
    // affect all the outputs.
    //
    CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aColor, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) );
    CHECK_MSTATUS( attributeAffects( aInTransparency, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aIncandescence, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightIntensity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraX, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraY, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCameraZ, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aNormalCamera, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDirection, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightAmbient, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightSpecular, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightDiffuse, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightBlindData, aOutColor ) );
    CHECK_MSTATUS( attributeAffects( aLightData, aOutColor ) );

    return( MS::kSuccess );
}