コード例 #1
0
ファイル: gammaShader.cpp プロジェクト: BigRoy/Maya-devkit
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus Gamma::initialize()
{
    MFnNumericAttribute		nAttr;

    // Input attributes

    aColor = nAttr.createColor( "color", "c" );
    MAKE_INPUT(nAttr);

	aGamma = nAttr.createPoint( "gamma", "g" );
    MAKE_INPUT(nAttr);
	CHECK_MSTATUS ( nAttr.setDefault(1.f, 1.f, 1.f) );

	// Output attributes

    aOutColor= nAttr.createColor( "outColor", "oc" );
    MAKE_OUTPUT(nAttr);

	//  Add attributes to the node database.
    CHECK_MSTATUS ( addAttribute(aColor) );
    CHECK_MSTATUS ( addAttribute(aGamma) );
    CHECK_MSTATUS ( addAttribute(aOutColor) );

    // All input affect the output color
    CHECK_MSTATUS ( attributeAffects( aColor, aOutColor ));
    CHECK_MSTATUS ( attributeAffects( aGamma, aOutColor ));

    return MS::kSuccess;
}
コード例 #2
0
ファイル: depthShader.cpp プロジェクト: BigRoy/Maya-devkit
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus depthShader::initialize()
{
    MFnNumericAttribute nAttr;

    // Create input attributes

	aColorNear = nAttr.createColor("color", "c");
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS(nAttr.setDefault(0., 1., 0.));			// Green

	aColorFar = nAttr.createColor("colorFar", "cf");
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS(nAttr.setDefault(0., 0., 1.));			// Blue

    aNear = nAttr.create("near", "n", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS(nAttr.setMin(0.0f));
	CHECK_MSTATUS(nAttr.setSoftMax(1000.0f));

    aFar = nAttr.create("far", "f", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS(nAttr.setMin(0.0f));
	CHECK_MSTATUS(nAttr.setSoftMax(1000.0f));
    CHECK_MSTATUS(nAttr.setDefault(2.0f));

    aPointCamera = nAttr.createPoint("pointCamera", "p");
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setHidden(true));

	// Create output attributes
    aOutColor = nAttr.createColor("outColor", "oc");
	MAKE_OUTPUT(nAttr);

    CHECK_MSTATUS(addAttribute(aColorNear));
    CHECK_MSTATUS(addAttribute(aColorFar));
    CHECK_MSTATUS(addAttribute(aNear) );
    CHECK_MSTATUS(addAttribute(aFar));
    CHECK_MSTATUS(addAttribute(aPointCamera));
    CHECK_MSTATUS(addAttribute(aOutColor));

    CHECK_MSTATUS(attributeAffects(aColorNear, aOutColor));
    CHECK_MSTATUS(attributeAffects(aColorFar, aOutColor));
    CHECK_MSTATUS(attributeAffects(aNear, aOutColor));
    CHECK_MSTATUS(attributeAffects(aFar, aOutColor));
    CHECK_MSTATUS(attributeAffects(aPointCamera, aOutColor));

    return MS::kSuccess;
}
コード例 #3
0
MPlug BoxParameterHandler<T>::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const
{
	typename IECore::TypedParameter<Box<T> >::ConstPtr p = IECore::runTimeCast<const IECore::TypedParameter<Box<T > > >( parameter );
	if( !p )
	{
		return MPlug();
	}

	MFnNumericAttribute fnNAttr;
	MFnCompoundAttribute fnCAttr;
	MObject oMin, oMax;
	switch( T::dimensions() )
	{
		case 2 :
			{
				MObject oMinX = fnNAttr.create( plugName + "MinX", plugName + "MinX", NumericTraits<T>::baseDataType() );
				MObject oMinY = fnNAttr.create( plugName + "MinY", plugName + "MinY", NumericTraits<T>::baseDataType() );
				oMin = fnNAttr.create( plugName + "Min", plugName + "Min", oMinX, oMinY );

				MObject oMaxX = fnNAttr.create( plugName + "MaxX", plugName + "MaxX", NumericTraits<T>::baseDataType() );
				MObject oMaxY = fnNAttr.create( plugName + "MaxY", plugName + "MaxY", NumericTraits<T>::baseDataType() );
				oMax = fnNAttr.create( plugName + "Max", plugName + "Max", oMaxX, oMaxY );
			}
			break;
		case 3 :
			oMin = fnNAttr.createPoint( plugName + "Min", plugName + "Min" );
			oMax = fnNAttr.createPoint( plugName + "Max", plugName + "Max" );
			break;
		default :
			return MPlug();
	}

	MObject attribute = fnCAttr.create( plugName, plugName );
	fnCAttr.addChild( oMin );
	fnCAttr.addChild( oMax );

	MPlug result = finishCreating( parameter, attribute, node );
	doUpdate( parameter, result );

	return result;
}
コード例 #4
0
ファイル: dynExprField.cpp プロジェクト: BigRoy/Maya-devkit
MStatus dynExprField::initialize()
//
//	Descriptions:
//		Initialize the node, attributes.
//
{
	MStatus status;
	MFnNumericAttribute numAttr;

	// create the field basic attributes.
	//
	mDirection = numAttr.createPoint("direction","dir");
	numAttr.setDefault( 0.0, 1.0, 0.0 );
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setReadable(true);
	numAttr.setWritable(true);
	status = addAttribute( mDirection );
	attributeAffects(mDirection, mOutputForce);

	return( MS::kSuccess );
}
コード例 #5
0
ファイル: slopeShaderNode.cpp プロジェクト: DimondTheCat/xray
MStatus slopeShaderNode::initialize()
//
//	Description:
//		Initializes the attributes for this node.
//
{
     MFnNumericAttribute nAttr; 
	 MFnMatrixAttribute nMAttr;
	 MFnTypedAttribute nTAttr;
	 MFnGenericAttribute nGAttr;


	// Input Attributes
	//
    aAngle = nAttr.create( "angle", "ang", MFnNumericData::kFloat);
    nAttr.setDefault(30.0f);
    nAttr.setMin(0.0f);
    nAttr.setMax(100.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

    aColor1 = nAttr.createColor( "walkableColor", "w" );
    nAttr.setDefault(0.0f, 1.0f, 0.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsedAsColor(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

    aColor2 = nAttr.createColor( "nonWalkableColor", "nw" );
    nAttr.setDefault(1.0f, 0.0f, 0.0f);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setUsedAsColor(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);


	// Surface Normal supplied by the render sampler
	//
    aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "n" );
    nAttr.setStorable(false);
    nAttr.setHidden(true);
    nAttr.setReadable(true);
    nAttr.setWritable(true);

	//View matrix from the camera into world space
	//
	aMatrixEyeToWorld = nMAttr.create( "matrixEyeToWorld", "mew",
									   MFnMatrixAttribute::kFloat );
	nAttr.setHidden(true);
	nMAttr.setWritable(true);

	// Output Attributes
	//
    aOutColor  = nAttr.createColor( "outColor", "oc" );
    nAttr.setStorable(false);
    nAttr.setHidden(false);
    nAttr.setReadable(true);
    nAttr.setWritable(false);

	//dummy plug for forcing evaluation
	//
	aDirtyShaderAttr = nGAttr.create( "dirtyShaderPlug", "dsp");
	nGAttr.setArray(true);
	nGAttr.setHidden(false);
	nGAttr.setUsesArrayDataBuilder(true);
	nGAttr.setReadable(false);
	nGAttr.setStorable(true);
	nGAttr.setIndexMatters(false);
	nGAttr.addAccept(MFnData::kMesh);

	//Add attribues
    addAttribute(aAngle);
    addAttribute(aColor1);
    addAttribute(aColor2);
    addAttribute(aTriangleNormalCamera);
    addAttribute(aOutColor);
	addAttribute(aMatrixEyeToWorld);
	addAttribute(aDirtyShaderAttr);

    attributeAffects (aAngle,  aOutColor);
    attributeAffects (aColor1, aOutColor);
    attributeAffects (aColor2, aOutColor);
    attributeAffects (aTriangleNormalCamera,  aOutColor);
	attributeAffects (aDirtyShaderAttr, aOutColor);

    return MS::kSuccess;
}
コード例 #6
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;
}
コード例 #7
0
// initializes attribute information
MStatus mySChecker::initialize()
{
    MFnMatrixAttribute mAttr; 
    MFnNumericAttribute nAttr; 
	MObject x, y, z;

	aColor1 = nAttr.createColor("color1", "c1");
	MAKE_INPUT(nAttr);
	nAttr.setDefault(0., .58824, .644);		// Light blue

	aColor2 = nAttr.createColor("color2", "c2");
	MAKE_INPUT(nAttr);
	nAttr.setDefault(1., 1., 1.);			// White

    aBias = nAttr.create( "bias", "b", MFnNumericData::k3Float);
	MAKE_INPUT(nAttr);
    nAttr.setMin(0.0f);
    nAttr.setMax(1.0f);
    nAttr.setDefault(0.5f, 0.5f, 0.5f);

    aPlaceMat = mAttr.create("placementMatrix", "pm",
							 MFnMatrixAttribute::kFloat);
    MAKE_INPUT(mAttr);

	// Internal shading attribute, implicitely connected.
    aPointWorld = nAttr.createPoint("pointWorld", "pw");
	MAKE_INPUT(nAttr);
    nAttr.setHidden(true);

	// Create output attributes
    aOutColor = nAttr.createColor("outColor", "oc");
	MAKE_OUTPUT(nAttr);

    aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
	MAKE_OUTPUT(nAttr);

    // Add the attributes here
    addAttribute(aColor1);
    addAttribute(aColor2);
    addAttribute(aPointWorld);
    addAttribute(aPlaceMat);
    addAttribute(aBias);

    addAttribute(aOutColor);
    addAttribute(aOutAlpha);

    // all input affect the output color and alpha
    attributeAffects (aColor1, aOutColor);
    attributeAffects (aColor1, aOutAlpha);

    attributeAffects (aColor2, aOutColor);
    attributeAffects (aColor2, aOutAlpha);

    attributeAffects (aPointWorld, aOutColor);
    attributeAffects (aPointWorld, aOutAlpha);

    attributeAffects (aPlaceMat, aOutColor);
    attributeAffects (aPlaceMat, aOutAlpha);

    attributeAffects (aBias, aOutColor);
    attributeAffects (aBias, aOutAlpha);

    return MS::kSuccess;
}
コード例 #8
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;
}
コード例 #9
0
ファイル: MG_dotProduct.cpp プロジェクト: bungnoid/MG_Tools
MStatus MG_dotProduct::initialize(){

//Input vector 1

		MFnNumericAttribute numericAttrFn;
		vector1 = numericAttrFn.createPoint("vector1","v1");
		addAttribute(vector1);
		numericAttrFn.setStorable(true);
 
		//Input vector 2

		vector2 = numericAttrFn.createPoint("vector2","v2");
		addAttribute(vector2);
		numericAttrFn.setStorable(true);


		//Projection axis attributes ,needs to be created as compound in order to set a default value 
		// X axis

		projAxisXa = numericAttrFn.create("xAxisProjectionX","xPrjx",MFnNumericData::kFloat,1);
		addAttribute(projAxisXa);
		numericAttrFn.setStorable(true);


		projAxisXb = numericAttrFn.create("xAxisProjectionY","xPrjy",MFnNumericData::kFloat,0);
		addAttribute(projAxisXa);
		numericAttrFn.setStorable(true);

		projAxisXc = numericAttrFn.create("xAxisProjectionZ","xPrjz",MFnNumericData::kFloat,0);
		addAttribute(projAxisXa);
		numericAttrFn.setStorable(true);



		MFnCompoundAttribute compund;
		projAxisX= compund.create("xAxisProjection","xproj");
		compund.addChild(projAxisXa);
		compund.addChild(projAxisXb);
		compund.addChild(projAxisXc);
		addAttribute(projAxisX);

		// Y axis

		projAxisYa = numericAttrFn.create("yAxisProjectionX","yPrjx",MFnNumericData::kFloat,0);
		addAttribute(projAxisYa);
		numericAttrFn.setStorable(true);


		projAxisYb = numericAttrFn.create("yAxisProjectionY","yPrjy",MFnNumericData::kFloat,1);
		addAttribute(projAxisYb);
		numericAttrFn.setStorable(true);

		projAxisYc = numericAttrFn.create("yAxisProjectionZ","yPrjz",MFnNumericData::kFloat,0);
		addAttribute(projAxisYc);
		numericAttrFn.setStorable(true);




		projAxisY= compund.create("yAxisProjection","yproj");
		compund.addChild(projAxisYa);
		compund.addChild(projAxisYb);
		compund.addChild(projAxisYc);
		addAttribute(projAxisY);

		// Z axis

		projAxisZa = numericAttrFn.create("zAxisProjectionX","zPrjx",MFnNumericData::kFloat,0);
		addAttribute(projAxisZa);
		numericAttrFn.setStorable(true);


		projAxisZb = numericAttrFn.create("zAxisProjectionY","zPrjy",MFnNumericData::kFloat,0);
		addAttribute(projAxisZb);
		numericAttrFn.setStorable(true);

		projAxisZc = numericAttrFn.create("zAxisProjectionZ","zPrjz",MFnNumericData::kFloat,1);
		addAttribute(projAxisZc);
		numericAttrFn.setStorable(true);




		projAxisZ= compund.create("zAxisProjection","zproj");
		compund.addChild(projAxisZa);
		compund.addChild(projAxisZb);
		compund.addChild(projAxisZc);
		addAttribute(projAxisZ);



		//normalize attribute 

		
		normalize=numericAttrFn.create("normalize","n",MFnNumericData::kBoolean );
		addAttribute(normalize);
		numericAttrFn.setStorable(true);


		//Output attribute that will hold the dot product value 

		dotProductA = numericAttrFn.create("dotProduct","dp",MFnNumericData::kFloat);
		addAttribute(dotProductA);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);

		//dot product max value

		dotProductMax = numericAttrFn.create("dotProductMaxValue","dpm",MFnNumericData::kFloat);
		addAttribute(dotProductMax);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);

		//Input vector1 projection on vector 2


		proj1on2 = numericAttrFn.createPoint("projectionV1onV2","pV1");
		addAttribute(proj1on2);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);


		//Input vector2 projection on vector 1


		proj2on1 = numericAttrFn.createPoint("projectionV2onV1","pV2");
		addAttribute(proj2on1);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);


		//angle inbetween

		angleInBetweenAttr = numericAttrFn.create("angleInBetween","aib",MFnNumericData::kFloat);
		addAttribute(angleInBetweenAttr);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);

		
		//Output attribute that will hold Xvalue of the angle inbetween
		angleX = numericAttrFn.create("angleX","ax",MFnNumericData::kFloat);
		addAttribute(angleX);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);

		//Output attribute that will hold Xvalue of the angle inbetween
		angleY = numericAttrFn.create("angleY","ay",MFnNumericData::kFloat);
		addAttribute(angleY);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);

		//Output attribute that will hold Xvalue of the angle inbetween
		angleZ = numericAttrFn.create("angleZ","az",MFnNumericData::kFloat);
		addAttribute(angleZ);
		numericAttrFn.setWritable(false);
		numericAttrFn.setStorable(false);
		

		//setting attribute affects
		attributeAffects(vector1,dotProductA);
		attributeAffects(vector2,dotProductA);
		attributeAffects(normalize,dotProductA);

		attributeAffects(vector1,dotProductMax);
		attributeAffects(vector2,dotProductMax);
		attributeAffects(normalize,dotProductMax);

		attributeAffects(vector1,proj1on2);
		attributeAffects(vector2,proj1on2);

		attributeAffects(vector1,proj2on1);
		attributeAffects(vector2,proj2on1);

		attributeAffects(vector1,angleInBetweenAttr);
		attributeAffects(vector2,angleInBetweenAttr);

		attributeAffects(vector1,angleX);
		attributeAffects(vector2,angleX);

		attributeAffects(vector1,angleY);
		attributeAffects(vector2,angleY);

		attributeAffects(vector1,angleZ);
		attributeAffects(vector2,angleZ);

		attributeAffects(projAxisXa,angleX);
		attributeAffects(projAxisXb,angleX);
		attributeAffects(projAxisXc,angleX);
		attributeAffects(projAxisYa,angleX);
		attributeAffects(projAxisYb,angleX);
		attributeAffects(projAxisYc,angleX);
		attributeAffects(projAxisZa,angleX);
		attributeAffects(projAxisZb,angleX);
		attributeAffects(projAxisZc,angleX);

		attributeAffects(projAxisXa,angleY);
		attributeAffects(projAxisXb,angleY);
		attributeAffects(projAxisXc,angleY);
		attributeAffects(projAxisYa,angleY);
		attributeAffects(projAxisYb,angleY);
		attributeAffects(projAxisYc,angleY);
		attributeAffects(projAxisZa,angleY);
		attributeAffects(projAxisZb,angleY);
		attributeAffects(projAxisZc,angleY);

		attributeAffects(projAxisXb,angleZ);
		attributeAffects(projAxisXc,angleZ);
		attributeAffects(projAxisYa,angleZ);
		attributeAffects(projAxisYb,angleZ);
		attributeAffects(projAxisYc,angleZ);
		attributeAffects(projAxisZa,angleZ);
		attributeAffects(projAxisZb,angleZ);
		attributeAffects(projAxisZc,angleZ);


		return MS::kSuccess;
	}
コード例 #10
0
ファイル: phongShader.cpp プロジェクト: BigRoy/Maya-devkit
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus PhongNode::initialize()
{
    MFnNumericAttribute nAttr;
    MFnLightDataAttribute lAttr;

    aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc",
									  MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);

    aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl",
										MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault(0.8f) );

    aColor = nAttr.createColor( "color", "c" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.58824f, 0.644f) );

    aIncandescence = nAttr.createColor( "incandescence", "ic" );
    MAKE_INPUT(nAttr);

    aOutColor = nAttr.createColor( "outColor", "oc" );
    MAKE_OUTPUT(nAttr);

    aPointCamera = nAttr.createPoint( "pointCamera", "pc" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );

    aPower = nAttr.create( "power", "pow", MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setMin(0.0f) );
    CHECK_MSTATUS ( nAttr.setMax(200.0f) );
    CHECK_MSTATUS ( nAttr.setDefault(10.0f) );

    aSpecularity = nAttr.create( "specularity", "spc", MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setMin(0.0f) );
    CHECK_MSTATUS ( nAttr.setMax(1.0f) ) ;
    CHECK_MSTATUS ( nAttr.setDefault(0.5f) );

    aReflectGain = nAttr.create( "reflectionGain", "rg", MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setMin(0.0f) );
    CHECK_MSTATUS ( nAttr.setMax(1.0f) );
    CHECK_MSTATUS ( nAttr.setDefault(0.5f) );

    aNormalCamera = nAttr.createPoint( "normalCamera", "n" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );

    aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "tn" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f));
    CHECK_MSTATUS ( nAttr.setHidden(true));

    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, 1.0f, 1.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, 1.0f, 1.0f) );

    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) );
    CHECK_MSTATUS ( nAttr.setHidden(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) );

    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) );

    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) );

    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) );

    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( "lightDataArray", "ltd",
                               aLightDirection, aLightIntensity, aLightAmbient,
                               aLightDiffuse, aLightSpecular,
							   aLightShadowFraction,
                               aPreShadowIntensity,
                               aLightBlindData);
    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, 0.0f, 1.0f, NULL) );

	// rayOrigin
	MObject RayX = nAttr.create( "rayOx", "rxo", MFnNumericData::kFloat, 0.0 );
	MObject RayY = nAttr.create( "rayOy", "ryo", MFnNumericData::kFloat, 0.0 );
	MObject RayZ = nAttr.create( "rayOz", "rzo", MFnNumericData::kFloat, 0.0 );
	aRayOrigin = nAttr.create( "rayOrigin", "rog", RayX, RayY, RayZ );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(false) );

	// rayDirection
	RayX = nAttr.create( "rayDirectionX", "rdx", MFnNumericData::kFloat, 1.0 );
	RayY = nAttr.create( "rayDirectionY", "rdy", MFnNumericData::kFloat, 0.0 );
	RayZ = nAttr.create( "rayDirectionZ", "rdz", MFnNumericData::kFloat, 0.0 );
	aRayDirection = nAttr.create( "rayDirection", "rad", RayX, RayY, RayZ );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(false) );

	// objectId
	aObjectId = nAttr.createAddr( "objectId", "oi" );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(false) );

	// raySampler
	aRaySampler = nAttr.createAddr("raySampler", "rtr");
    CHECK_MSTATUS ( nAttr.setStorable(false));
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(false) );

	// rayDepth
	aRayDepth = nAttr.create( "rayDepth", "rd", MFnNumericData::kShort, 0.0 );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS  (nAttr.setHidden(true) ) ;
    CHECK_MSTATUS ( nAttr.setReadable(false) );

    CHECK_MSTATUS ( addAttribute(aTranslucenceCoeff) );
    CHECK_MSTATUS ( addAttribute(aDiffuseReflectivity) );
    CHECK_MSTATUS ( addAttribute(aColor) );
    CHECK_MSTATUS ( addAttribute(aIncandescence) );
    CHECK_MSTATUS ( addAttribute(aPointCamera) );
    CHECK_MSTATUS ( addAttribute(aNormalCamera) );
    CHECK_MSTATUS ( addAttribute(aTriangleNormalCamera) );

    CHECK_MSTATUS ( addAttribute(aLightData) );

    CHECK_MSTATUS ( addAttribute(aPower) );
    CHECK_MSTATUS ( addAttribute(aSpecularity) );
    CHECK_MSTATUS ( addAttribute(aOutColor) );

	CHECK_MSTATUS ( addAttribute(aRayOrigin) );
	CHECK_MSTATUS ( addAttribute(aRayDirection) );
	CHECK_MSTATUS ( addAttribute(aObjectId) );
	CHECK_MSTATUS ( addAttribute(aRaySampler) );
	CHECK_MSTATUS ( addAttribute(aRayDepth) );
    CHECK_MSTATUS ( addAttribute(aReflectGain) );

    CHECK_MSTATUS ( attributeAffects (aTranslucenceCoeff, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aDiffuseReflectivity, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightIntensity, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aIncandescence, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aPointCamera, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aTriangleNormalCamera, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightData, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightAmbient, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightSpecular, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightDiffuse, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightDirection, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightShadowFraction, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aPreShadowIntensity, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aLightBlindData, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aPower, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aSpecularity, aOutColor));
    CHECK_MSTATUS ( attributeAffects (aColor, aOutColor));

	CHECK_MSTATUS ( attributeAffects (aRayOrigin,aOutColor));
	CHECK_MSTATUS ( attributeAffects (aRayDirection,aOutColor));
	CHECK_MSTATUS ( attributeAffects (aObjectId,aOutColor));
	CHECK_MSTATUS ( attributeAffects (aRaySampler,aOutColor));
	CHECK_MSTATUS ( attributeAffects (aRayDepth,aOutColor));
    CHECK_MSTATUS ( attributeAffects (aReflectGain,aOutColor) );

    return MS::kSuccess;
}
コード例 #11
0
MStatus VmIslandNode::initialize()
{
    fprintf( stderr, "VmIslandNode::initialize()...\n" );
    
    MStatus status;
    
    //Seed attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_seed = numericAttrFn.create( "seed", "sD", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 1000 );
        numericAttrFn.setDefault ( 0 );
        status = addAttribute( ia_seed );
        CHECK_MSTATUS( status );
    }
    
    //Roughness attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_roughness = numericAttrFn.create( "roughness", "rG", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 1 );
        numericAttrFn.setDefault ( 0.75 );
        status = addAttribute( ia_roughness );
        CHECK_MSTATUS( status );
    }
    
    //Plane Height attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_planeHeight = numericAttrFn.create( "planeHeight", "pH", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 2000 );
        numericAttrFn.setDefault ( 5 );
        status = addAttribute( ia_planeHeight );
        CHECK_MSTATUS( status );
    }

     //Plane smoothing attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_smooth = numericAttrFn.create( "smoothingStrength", "sS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setMax( 6 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_smooth );
        CHECK_MSTATUS( status );
    }
    
     //Plane resolution attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_resolution = numericAttrFn.create( "mayaResolution", "mR", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_resolution );
        CHECK_MSTATUS( status );
    }

    //Renderman resolution attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_rmanResolution = numericAttrFn.create( "rendermanResolution", "rR", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 6 );
        status = addAttribute( ia_rmanResolution );
        CHECK_MSTATUS( status );
    }

    //Plane size attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_planeSize = numericAttrFn.create( "planeSizeScale", "pS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 200 );
        numericAttrFn.setDefault ( 20 );
        status = addAttribute( ia_planeSize );
        CHECK_MSTATUS( status );
    }


     //Plane size attribute
    {
        MFnNumericAttribute numericAttrFn;
        ia_gridSize = numericAttrFn.create( "gridSize", "gS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 10 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_gridSize );
        CHECK_MSTATUS( status );
    }

     //Grass multiplier - Affects how many instances are spawned
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassMultiplier = numericAttrFn.create( "grassInstanceMultiplier", "gM", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 1 );
        numericAttrFn.setMax( 100 );
        numericAttrFn.setDefault ( 1 );
        status = addAttribute( ia_grassMultiplier );
        CHECK_MSTATUS( status );
    }


        //Grass multiplier - Affects how many instances are spawned
    {
        MFnNumericAttribute numericAttrFn;
        ia_baseWidth = numericAttrFn.create( "grassBaseWidth", "bW", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.01f );
        numericAttrFn.setMax( 2.0f ); 
        numericAttrFn.setDefault ( 0.6f );
        status = addAttribute( ia_baseWidth );
        CHECK_MSTATUS( status );
    }



    //Grass segment length - Length of segment pieces
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassSegmentLength = numericAttrFn.create( "grassSegmentLength", "gSL", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.001f );
        numericAttrFn.setMax( 10.0f );
        numericAttrFn.setDefault ( 1.0f );
        status = addAttribute( ia_grassSegmentLength );
        CHECK_MSTATUS( status );
    }

     //Number of segments per piece of grass
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassNumSegments = numericAttrFn.create( "numberOfGrassSegments", "nGS", MFnNumericData::kLong, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 3 );
        numericAttrFn.setMax( 20 );
        numericAttrFn.setDefault ( 5 );
        status = addAttribute( ia_grassNumSegments );
        CHECK_MSTATUS( status );
    }

    //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_windDirection = numericAttrFn.createPoint( "windDirection", "wDir");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(1.0f, 0.0f, 1.0f);
        status = addAttribute( ia_windDirection );
        CHECK_MSTATUS( status );
    }

    //Grass bend factor
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBendAmount = numericAttrFn.create( "grassBendFactor", "gBF", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.0f );
        numericAttrFn.setMax( 1.0f );
        numericAttrFn.setDefault ( 0.0f );
        status = addAttribute( ia_grassBendAmount );
        CHECK_MSTATUS( status );
    }

    //Wind strength
    {
        MFnNumericAttribute numericAttrFn;
        ia_windSpread = numericAttrFn.create( "windSpread", "wS", MFnNumericData::kFloat, 0, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0.01f );
        numericAttrFn.setMax( 10.0f );
        numericAttrFn.setDefault ( 5.0f );
        status = addAttribute( ia_windSpread );
        CHECK_MSTATUS( status );
    }



        //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBaseColour1 = numericAttrFn.createColor( "grassBaseColour1", "bCol1");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.0f,0.251f,0.167f);
        status = addAttribute( ia_grassBaseColour1 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassTipColour1 = numericAttrFn.createColor( "grassTipColour1", "tCol1");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.395f,0.551f,0.257f);
        status = addAttribute( ia_grassTipColour1 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassBaseColour2 = numericAttrFn.createColor( "grassBaseColour2", "bCol2");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.275f,0.243f,0.043f);
        status = addAttribute( ia_grassBaseColour2 );
        CHECK_MSTATUS( status );
    }

            //Initial grass bend direction
    {
        MFnNumericAttribute numericAttrFn;
        ia_grassTipColour2 = numericAttrFn.createColor( "grassTipColour2", "tCol2");
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( true );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setDefault(0.611f,0.587f,0.257f);
        status = addAttribute( ia_grassTipColour2 );
        CHECK_MSTATUS( status );
    }





     //Clock attribute. Passes maya frame counter into node
    {
        MFnNumericAttribute numericAttrFn;
        ia_clock = numericAttrFn.create( "clock", "clk", MFnNumericData::kLong, false, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( false );
        numericAttrFn.setKeyable( true );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( false );
        numericAttrFn.setMin( 0 );
        numericAttrFn.setDefault( 0 );
        status = addAttribute( ia_clock );
        CHECK_MSTATUS( status );
    }

    
    // "drawStyle"
    //
    // How we should draw in Maya.
    //
    // We will use this value in our Maya plug-in, but we
    // will NOT use it in Renderman. Note elsewhere that
    // this value will not be sent to Renderman, nor will
    // it have any effect on RIB generation.
    //
    // We think of this as an input attribute - hence the
    // prefix "ia_" for "input attribute". 
    {
        MFnEnumAttribute enumAttrFn;
        ia_drawStyle = enumAttrFn.create( "drawStyle", "ds", 1, & status );
        CHECK_MSTATUS( status );
        enumAttrFn.setReadable( true );
        enumAttrFn.setWritable( true );
        enumAttrFn.setStorable( true );
        enumAttrFn.setKeyable( true );
        enumAttrFn.setConnectable( true );
        enumAttrFn.setHidden( false );
        enumAttrFn.addField( "Bounds", 0 );
        enumAttrFn.addField( "Sub bounds", 1 );
        enumAttrFn.addField( "Geometry", 2 );
        enumAttrFn.addField( "Terrain slope normals", 3 );
        enumAttrFn.addField( "Point instances", 4 );
        enumAttrFn.addField( "Wind Velocity", 5 );
        enumAttrFn.addField( "All", 6 );
        enumAttrFn.setDefault(3);
        status = addAttribute( ia_drawStyle );
        CHECK_MSTATUS( status );
    }
    
    // "update"
    //
    // A 'dummy' attribute, and a powerful one. Although
    // the value of this attribute is actually meaningless,
    // when we ask for it we trigger an important computation
    // processs.
    //
    // We think of this as an input attribute - hence the
    // prefix "oa_" for "computation attribute". This signifies
    // that we don't really care about it's final value, but
    // that we know it's going to compute a lot of stuff. 
    {
        MFnNumericAttribute numericAttrFn;
        oa_update = numericAttrFn.create( "update", "upd", MFnNumericData::kBoolean, false, & status );
        CHECK_MSTATUS( status );
        numericAttrFn.setReadable( true );
        numericAttrFn.setWritable( true );
        numericAttrFn.setStorable( false );
        numericAttrFn.setKeyable( false );
        numericAttrFn.setConnectable( true );
        numericAttrFn.setHidden( true );
        status = addAttribute( oa_update );
        CHECK_MSTATUS( status );
    }


   
    
    
    // "rib"
    //
    // A string which contains all the attributes, and that
    //  we need to have (and indeed will see again) on the 
    // Renderman side of things.
    //
    // We think of this as an output attribute - hence the
    // prefix "oa_" for "output attribute". The value
    // computed for this attribute (the string) is important,
    // an is used by whatever is asking for it.
    {
        MFnTypedAttribute typedAttrFn;
        oa_rib = typedAttrFn.create( "rib", "rb", MFnData::kString, MObject::kNullObj, & status );
        CHECK_MSTATUS( status );
        typedAttrFn.setReadable( true );
        typedAttrFn.setWritable( true );
        typedAttrFn.setStorable( false );
        typedAttrFn.setKeyable( false );
        typedAttrFn.setConnectable( true );
        typedAttrFn.setHidden( true );
        status = addAttribute( oa_rib );
        CHECK_MSTATUS( status );
    }


    
    // This section tells Maya what attribute effects
    // which attribute. When input attributes change, 
    // make the attributes they effect "dirty". That 
    // means that, when Maya asks for a dirty attribute, 
    // it will need to be computed and "cleaned".
    //
    // Changing an effecting "input" attribute does not
    // trigger a computation of it's effected "output"
    // attribute. It just tells Maya that - if the effected
    // attribute is ever asked for, it will have to call
    // the compute method to calculate it.
    //
    // For complex relationships between attributes,
    // an attributeEffects() call must exist for each
    // relationship. If A effects B, and B effects C,
    // then we will need to make two attributeEffects()
    // calls - one for A effecting B and one for B 
    // effecting C. Maya will not figure out that, if A
    // effects B, and B effets C, then A must effect C.
    //
    // Below we see that most "input" attributes effect
    // both our internal update and the rib generation
    // the same way in each case. But it's not always 
    // exactly the same like this.
    //
    // Notice also that ia_drawStyle does not effect
    // any of the attributes. It's something that's just
    // used in the draw method.
    
    attributeAffects( ia_seed, oa_update );
    attributeAffects( ia_seed, oa_rib );
    
    attributeAffects( ia_roughness, oa_update );
    attributeAffects( ia_roughness, oa_rib );

    attributeAffects( ia_smooth, oa_update );
    attributeAffects( ia_smooth, oa_rib );

    attributeAffects( ia_planeHeight, oa_update );
    attributeAffects( ia_planeHeight, oa_rib );

    attributeAffects( ia_resolution, oa_update );
    attributeAffects( ia_rmanResolution, oa_rib );
    
    attributeAffects( ia_planeSize, oa_update );
    attributeAffects( ia_planeSize, oa_rib );

    attributeAffects( ia_gridSize, oa_update );
    attributeAffects( ia_gridSize, oa_rib );

    attributeAffects( ia_grassMultiplier, oa_update );
    attributeAffects( ia_grassMultiplier, oa_rib );

    attributeAffects( ia_baseWidth, oa_update );
    attributeAffects( ia_baseWidth, oa_rib );

    attributeAffects( ia_grassSegmentLength, oa_update );
    attributeAffects( ia_grassSegmentLength, oa_rib );

    attributeAffects( ia_grassNumSegments, oa_update );
    attributeAffects( ia_grassNumSegments, oa_rib );

    attributeAffects( ia_grassBendAmount, oa_update );
    attributeAffects( ia_grassBendAmount, oa_rib );

    attributeAffects( ia_windDirection, oa_update );
    attributeAffects( ia_windDirection, oa_rib );

    attributeAffects( ia_windSpread, oa_update );
    attributeAffects( ia_windSpread, oa_rib );

    attributeAffects( ia_clock, oa_update );
    attributeAffects( ia_clock, oa_rib );

    attributeAffects( ia_grassBaseColour1, oa_update);
    attributeAffects( ia_grassBaseColour1, oa_rib);

    attributeAffects( ia_grassTipColour1, oa_update);
    attributeAffects( ia_grassTipColour1, oa_rib);

    attributeAffects( ia_grassBaseColour2, oa_update);
    attributeAffects( ia_grassBaseColour2, oa_rib);

    attributeAffects( ia_grassTipColour2, oa_update);
    attributeAffects( ia_grassTipColour2, oa_rib);


    
    
    fprintf( stderr, "VmIslandNode::initialize() done\n" );

    return MStatus::kSuccess;
}
コード例 #12
0
ファイル: hwPhongShader.cpp プロジェクト: OpenXRay/xray
MStatus hwPhongShader::initialize()
{
	// Make sure that all attributes are cached internal for
	// optimal performance !

	TRACE_API_CALLS("initialize");
    MFnNumericAttribute nAttr; 

    // Create input attributes
    aColor = nAttr.createColor( "color", "c");
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0.1f, 0.1f, 0.1f);
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aDiffuseColor = nAttr.createColor( "diffuseColor", "dc" );
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(1.f, 0.5f, 0.5f);
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aSpecularColor = nAttr.createColor( "specularColor", "sc" );
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0.5f, 0.5f, 0.5f);
	nAttr.setCached( true );
	nAttr.setInternal( true );

	// This is defined as a point, so that users can easily enter
	// values beyond 1.
    aShininess = nAttr.createPoint( "shininess", "sh" );
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(100.0f, 100.0f, 100.0f);
	nAttr.setCached( true );
	nAttr.setInternal( true );

	aGeometryShape = nAttr.create( "geometryShape", "gs", MFnNumericData::kInt );
    nAttr.setStorable(true);
    nAttr.setKeyable(true);
    nAttr.setDefault(0);
	nAttr.setCached( true );
	nAttr.setInternal( true );


	// create output attributes here
	// outColor is the only output attribute and it is inherited
	// so we do not need to create or add it.
	//

	// Add the attributes here

    addAttribute(aColor);
	addAttribute(aDiffuseColor);
	addAttribute(aSpecularColor);
	addAttribute(aShininess);
	addAttribute(aGeometryShape);

    attributeAffects (aColor,			outColor);
    attributeAffects (aDiffuseColor,	outColor);
	attributeAffects (aSpecularColor,	outColor);
	attributeAffects (aShininess,		outColor);

    return MS::kSuccess;
}
コード例 #13
0
ファイル: onbShader.cpp プロジェクト: BigRoy/Maya-devkit
MStatus OnbShader::initialize()
{
	MFnNumericAttribute nAttr;
	MFnLightDataAttribute lAttr;

	// Outputs
	MObject outcR = nAttr.create("outColorR", "ocr", MFnNumericData::kFloat, 0.0);
	MObject outcG = nAttr.create("outColorG", "ocg", MFnNumericData::kFloat, 0.0);
	MObject outcB = nAttr.create("outColorB", "ocb", MFnNumericData::kFloat, 0.0);
	aOutColor = nAttr.create("outColor", "oc", outcR, outcG, outcB);
	MAKE_OUTPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	MObject outtR = nAttr.create("outTransparencyR", "otr", MFnNumericData::kFloat, 0.0);
	MObject outtG = nAttr.create("outTransparencyG", "otg", MFnNumericData::kFloat, 0.0);
	MObject outtB = nAttr.create("outTransparencyB", "otb", MFnNumericData::kFloat, 0.0);
	aOutTransparency = nAttr.create("outTransparency", "ot", outtR, outtG, outtB);
	MAKE_OUTPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	// Inputs
	MObject cR = nAttr.create("colorR", "cr", MFnNumericData::kFloat, 0.5);
	MObject cG = nAttr.create("colorG", "cg", MFnNumericData::kFloat, 0.5);
	MObject cB = nAttr.create("colorB", "cb", MFnNumericData::kFloat, 0.5);
	aColor = nAttr.create("color", "c", cR, cG, cB);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	aRoughness = nAttr.create("roughness", "r", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setMin(0.0f));
	CHECK_MSTATUS(nAttr.setMax(1.0f));
	CHECK_MSTATUS(nAttr.setDefault(0.3f));

	MObject tR = nAttr.create("transparencyR", "itr", MFnNumericData::kFloat, 0.0);
	MObject tG = nAttr.create("transparencyG", "itg", MFnNumericData::kFloat, 0.0);
	MObject tB = nAttr.create("transparencyB", "itb", MFnNumericData::kFloat, 0.0);
	aTransparency = nAttr.create("transparency", "it", tR, tG, tB);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	MObject aR = nAttr.create("ambientColorR", "acr", MFnNumericData::kFloat, 0.0);
	MObject aG = nAttr.create("ambientColorG", "acg", MFnNumericData::kFloat, 0.0);
	MObject aB = nAttr.create("ambientColorB", "acb", MFnNumericData::kFloat, 0.0);
	aAmbientColor = nAttr.create("ambientColor", "ambc", aR, aG, aB);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	MObject iR = nAttr.create("incandescenceR", "ir", MFnNumericData::kFloat, 0.0);
	MObject iG = nAttr.create("incandescenceG", "ig", MFnNumericData::kFloat, 0.0);
	MObject iB = nAttr.create("incandescenceB", "ib", MFnNumericData::kFloat, 0.0);
	aIncandescence = nAttr.create("incandescence", "ic", iR, iG, iB);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	MObject sR = nAttr.create("specularColorR", "sr", MFnNumericData::kFloat, 1.0);
	MObject sG = nAttr.create("specularColorG", "sg", MFnNumericData::kFloat, 1.0);
	MObject sB = nAttr.create("specularColorB", "sb", MFnNumericData::kFloat, 1.0);
	aSpecularColor = nAttr.create("specularColor", "sc", sR, sG, sB);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setUsedAsColor(true));

	aEccentricity = nAttr.create("eccentricity", "ecc", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setMin(0.0f));
	CHECK_MSTATUS(nAttr.setMax(1.0f));
	CHECK_MSTATUS(nAttr.setDefault(0.1f));

	aSpecularRollOff = nAttr.create("specularRollOff", "sro", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setMin(0.0f));
	CHECK_MSTATUS(nAttr.setMax(1.0f));
	CHECK_MSTATUS(nAttr.setDefault(0.7f));

	aNormalCamera = nAttr.createPoint("normalCamera", "n");
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f));

	// Attributes for compute()
	aRayDirection = nAttr.createPoint("rayDirection", "rd");
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(nAttr.setHidden(true));

	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, 1.0f, 1.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, 1.0f, 1.0f));

	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));
	CHECK_MSTATUS(nAttr.setHidden(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));

	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));

	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));

	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));

	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("lightDataArray", "ltd",
		aLightDirection,
		aLightIntensity,
		aLightAmbient,
		aLightDiffuse,
		aLightSpecular,
		aLightShadowFraction,
		aPreShadowIntensity,
		aLightBlindData);
	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, 0.0f, 1.0f, NULL));

	// Add Attributes
	CHECK_MSTATUS(addAttribute(aOutColor));
	CHECK_MSTATUS(addAttribute(aOutTransparency));
	CHECK_MSTATUS(addAttribute(aColor));
	CHECK_MSTATUS(addAttribute(aRoughness));
	CHECK_MSTATUS(addAttribute(aTransparency));
	CHECK_MSTATUS(addAttribute(aAmbientColor));
	CHECK_MSTATUS(addAttribute(aIncandescence));
	CHECK_MSTATUS(addAttribute(aSpecularColor));
	CHECK_MSTATUS(addAttribute(aEccentricity));
	CHECK_MSTATUS(addAttribute(aSpecularRollOff));
	CHECK_MSTATUS(addAttribute(aNormalCamera));
	CHECK_MSTATUS(addAttribute(aRayDirection));
	CHECK_MSTATUS(addAttribute(aLightData));

	// Attribute affects relationships
	CHECK_MSTATUS(attributeAffects(aColor, aOutColor));
	CHECK_MSTATUS(attributeAffects(aColor, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aRoughness, aOutColor));
	CHECK_MSTATUS(attributeAffects(aRoughness, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aTransparency, aOutColor));
	CHECK_MSTATUS(attributeAffects(aTransparency, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aAmbientColor, aOutColor));
	CHECK_MSTATUS(attributeAffects(aAmbientColor, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aIncandescence, aOutColor));
	CHECK_MSTATUS(attributeAffects(aIncandescence, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aSpecularColor, aOutColor));
	CHECK_MSTATUS(attributeAffects(aSpecularColor, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aEccentricity, aOutColor));
	CHECK_MSTATUS(attributeAffects(aEccentricity, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aNormalCamera, aOutColor));
	CHECK_MSTATUS(attributeAffects(aNormalCamera, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aRayDirection, aOutColor));
	CHECK_MSTATUS(attributeAffects(aRayDirection, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aSpecularRollOff, aOutColor));
	CHECK_MSTATUS(attributeAffects(aSpecularRollOff, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightDirection, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightDirection, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightIntensity, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightIntensity, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightAmbient, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightAmbient, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightDiffuse, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightDiffuse, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightSpecular, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightSpecular, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightShadowFraction, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightShadowFraction, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, aOutColor));
	CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightBlindData, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightBlindData, aOutTransparency));
	CHECK_MSTATUS(attributeAffects(aLightData, aOutColor));
	CHECK_MSTATUS(attributeAffects(aLightData, aOutTransparency));

	return MS::kSuccess;
}
コード例 #14
0
ファイル: interpShader.cpp プロジェクト: BigRoy/Maya-devkit
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus InterpNode::initialize()
{
     MFnNumericAttribute nAttr; 

// Inputs and Attributes
//
// User defined attributes require a long-name and short-name that
// are required to be unique within the node.
// (See the compound attribute color1 named "Sides".)
//
// Rendering attributes that your node wants to get from the sampler
// require them to be defined given the pre-defined unique long-name.
// (See the compound attribute aNormalCamera named "normalCamera".)
// 
// User defined Attributes are generally something that you want
// to store in the Maya file. The setStorable(true) method enables 
// an attribute to be stored into the Maya scene file. 
//
// Rendering attributes are primarily data that is generated per sample and
// not something that you want to store in a file. To disable an 
// attribute from being recorded to the Maya scene file use 
// the setStorable(false) method.
//
// Simple attributes that represent a range of values can enable a
// slider on the Attribute Editor by using the methods setMin() and
// setMax(). 
// (See the simple attribute InputValue named "Power".)
//
// Compound attributes that represent a vector of 3 floats can enable
// a color swatch on the Attribute Editor that will launch a color picker 
// tool by using the method setUsedAsColor(true).
// (See the compound attribute color1 name "Sides".)
//
// Both Simple and Compound attributes can be initialized with a 
// default value using the method setDefault().
//
// Attributes by default show up in the Attribute Editor and
// in the Connection Editor unless they are specified as being hidden 
// by using the method setHidden(true). 
//
// Attributes by default have both read/write access in the dependency graph.
// To change an attributes behaviour you can use the methods
// setReadable() and setWritable(). The method setReadable(true) 
// indicates that the attribute can be used as the source in 
// a dependency graph connection. The method setWritable(true) 
// indicates that the attribute can be used as the destination 
// in a dependency graph connection.
// (See the compound attribute aOutColor named "outColor" below.
//  It has been marked as a read-only attribute since it is
//  the computed result of the node, it is not stored in the Maya file since 
//  it is always computed, and it is marked as hidden to prevent it 
//  from being displayed in the user interface.)
//  
//


// User defined input value

    aInputValue = nAttr.create( "power", "pow", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setDefault(1.0f) );
    CHECK_MSTATUS ( nAttr.setMin(0.0f) );
    CHECK_MSTATUS ( nAttr.setMax(3.0f) );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(true) );

// User defined color attribute
    aColor1 = nAttr.createColor( "sideColor", "sc");
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setUsedAsColor(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(true) );


    aColor2 = nAttr.createColor( "facingColor", "fc");
    CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.0f, 0.0f) );
    CHECK_MSTATUS ( nAttr.setKeyable(true) );
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setUsedAsColor(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(true) );


	// Surface Normal supplied by the render sampler

    aNormalCamera = nAttr.createPoint( "normalCamera", "n");
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(true) );

	// Point on surface in camera space, will be used to compute view vector

    aPointCamera = nAttr.createPoint( "pointCamera", "p");
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(true) );

// Outputs
//
// Always set your output attributes to be read-only
// You should also mark any internal attributes that your node
// computes to be read-only also, this will prevent any connections.
    aOutColor  = nAttr.createColor( "outColor", "oc" );
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );

    CHECK_MSTATUS ( addAttribute(aInputValue) );
    CHECK_MSTATUS ( addAttribute(aColor1) );
    CHECK_MSTATUS ( addAttribute(aColor2) );
    CHECK_MSTATUS ( addAttribute(aNormalCamera) );
    CHECK_MSTATUS ( addAttribute(aPointCamera) );
    CHECK_MSTATUS ( addAttribute(aOutColor) );

    CHECK_MSTATUS ( attributeAffects (aInputValue, aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aColor1,  aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aColor2,  aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aNormalCamera,  aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aPointCamera,  aOutColor) );

    return MS::kSuccess;
}
コード例 #15
0
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus ShadowMatte::initialize()
{
    MFnNumericAttribute nAttr; 
    MFnLightDataAttribute lAttr;

// Outputs

    aViewColor = nAttr.create( "viewColor", "vc", MFnNumericData::kBoolean);
    nAttr.setKeyable(true);
    nAttr.setStorable(true);
    nAttr.setHidden(false);
    nAttr.setDefault(true);

    aOutColor = nAttr.createColor( "outColor", "oc");
    nAttr.setStorable(false);
    nAttr.setHidden(false);
    nAttr.setReadable(true);
    nAttr.setWritable(false);

    aOutTransparency  = nAttr.createColor( "outTransparency", "ot" );
    nAttr.setStorable(false);
    nAttr.setHidden(false);
    nAttr.setReadable(true);
    nAttr.setWritable(false);


// Inputs

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

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

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

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

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

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

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

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

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

    addAttribute(aLightData);
    addAttribute(aOutColor);
    addAttribute(aOutTransparency);
    addAttribute(aViewColor);


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

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

    return MS::kSuccess;
}
コード例 #16
0
MStatus	MayaToKrayGlobals::initialize()
{
	MayaRenderGlobalsNode::initialize();

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

	//  DOF (depth of field) and motion blur will not work in adaptive mode.
	samplingType = eAttr.create( "samplingType", "samplingType", 0, &stat);
	stat = eAttr.addField( "None", 0 );
	stat = eAttr.addField( "Grid", 1 );
	stat = eAttr.addField( "Qasi Random", 2 );
	stat = eAttr.addField( "Random Full Screen AA", 3 );
	CHECK_MSTATUS(addAttribute( samplingType ));

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

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

	filterRadius = nAttr.create("filterRadius", "filterRadius",  MFnNumericData::kFloat, 0.7);
	CHECK_MSTATUS(addAttribute( filterRadius ));

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

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

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

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

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

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

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

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

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

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

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

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

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

	diffuseModel = eAttr.create( "diffuseModel", "diffuseModel", 2, &stat);
	stat = eAttr.addField( "Raytrace", 0 );
	stat = eAttr.addField( "Photon Estimate", 1 );
	stat = eAttr.addField( "Photon Mapping", 2 );
	stat = eAttr.addField( "Path tracing", 3 );
	//stat = eAttr.addField( "Cache irradiance", 3 );
	//stat = eAttr.addField( "Caustics", 5 );
	CHECK_MSTATUS(addAttribute( diffuseModel ));

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

	diffuseModelPhoton = eAttr.create( "diffuseModelPhoton", "diffuseModelPhoton", 0, &stat);
	stat = eAttr.addField( "Global Filtered", 0 );
	stat = eAttr.addField( "Global Unfiltered", 1 );
	stat = eAttr.addField( "Precomputed Filtered", 2 );
	stat = eAttr.addField( "Precomputed Unfiltered", 3 );
	CHECK_MSTATUS(addAttribute( diffuseModelPhoton ));

	giMode = eAttr.create( "giMode", "giMode", 0, &stat);
	stat = eAttr.addField( "Independent", 0 );
	stat = eAttr.addField( "Time interpolation", 1 );
	stat = eAttr.addField( "Shared for all frames", 2 );
	CHECK_MSTATUS(addAttribute( giMode ));

	pixelOrder = eAttr.create( "pixelOrder", "pixelOrder", 0, &stat);
	stat = eAttr.addField( "Scanline", 0 );
	stat = eAttr.addField( "Scancolumn", 1 );
	stat = eAttr.addField( "Random", 2 );
	stat = eAttr.addField( "Progressive", 3 );
	stat = eAttr.addField( "RenderWorm", 4 );
	stat = eAttr.addField( "Frost", 5 );
	CHECK_MSTATUS(addAttribute( pixelOrder ));

	bitdepth = eAttr.create( "bitdepth", "bitdepth", 0, &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 ));

	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( "Path tracing", 0 );
	stat = eAttr.addField( "Distributed Raytracing", 1 );
	CHECK_MSTATUS(addAttribute( lightingEngine ));

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

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

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

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

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

	// 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( "Color Fade", 0 );
	stat = eAttr.addField( "Fade", 1 );
	stat = eAttr.addField( "GVolume", 2 );
	stat = eAttr.addField( "Physical Sky", 3 );
	stat = eAttr.addField( "VEffect", 4 );
	stat = eAttr.addField( "Volume", 5 );
	//environment  	colorFade, 	<rgb> color, 	<double> amount;
	//	fade, 	<double> amount;
	//	gVolume, 	<texture> t2, 	<int> max_recurse, 	<double> adaptive_threshold, 	<double> max_distance, 	<double> probe_per_length, 	<double> photon_per_lenght, 	<double> photon_radius;
	//	phySky, 	<sharedObject> s2, 	<int> flags;
	//	vEffect, 	<double> intensity, 	<double> start, 	<double> step1, 	<double> step2, 	<int> n;
	//	volume, 	<texture> t2, 	<int> max_recurse, 	<double> adaptive_threshold, 	<double> max_distance, 	<double> probe_per_length, 	<double> photon_per_lenght, 	<double> photon_radius; 
	CHECK_MSTATUS(addAttribute( environmentType ));

	backgroundType = eAttr.create( "backgroundType", "backgroundType", 0, &stat);
	stat = eAttr.addField( "Constant", 0 );
	stat = eAttr.addField( "Physical Sky", 1 );
	stat = eAttr.addField( "Physical Sky 2", 2 );
	stat = eAttr.addField( "Sky", 3 );
	stat = eAttr.addField( "Sky2", 4 );
	stat = eAttr.addField( "Bitmap", 5 );
	stat = eAttr.addField( "Bitmap2", 6 );
	stat = eAttr.addField( "DirectionsMap", 7 );
	stat = eAttr.addField( "LightMap", 8 );
	stat = eAttr.addField( "SphereMap", 9 );
	CHECK_MSTATUS(addAttribute( backgroundType ));

	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 ));

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

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

	zenithDir = nAttr.createPoint("zenithDir", "zenithDir");
	nAttr.setDefault(0.0f, 1.0f, 0.0f);
	CHECK_MSTATUS(addAttribute( zenithDir ));

	orientation = nAttr.createPoint("orientation", "orientation");
	nAttr.setDefault(0.0f, 1.0f, 0.0f);
	CHECK_MSTATUS(addAttribute( orientation ));

	sunDir = nAttr.createPoint("sunDir", "sunDir");
	nAttr.setDefault(0.0f, 1.0f, 0.0f);
	CHECK_MSTATUS(addAttribute( sunDir ));

	groundAlbedo = nAttr.createColor("groundAlbedo", "groundAlbedo");
	nAttr.setDefault(1.0f, 1.0f, 1.0f);
	CHECK_MSTATUS(addAttribute( groundAlbedo ));

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

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

	sunSpotAngle = nAttr.create("sunSpotAngle", "sunSpotAngle",  MFnNumericData::kFloat, 35.0f);
	CHECK_MSTATUS(addAttribute( sunSpotAngle ));

	solidAngle = nAttr.create("solidAngle", "solidAngle",  MFnNumericData::kFloat, 25.0f);
	CHECK_MSTATUS(addAttribute( solidAngle ));

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

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

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

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


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

	//image_formats=@	"HDR High Dynamic Range (Radiance)",
	//				"JPG Joint Photographic experts Group",
	//				"PNG Portable Network Graphics",
	//				"PNG Portable Network Graphics +alpha",
	//				"TIF Tagged Image file Format",
	//				"TIF Tagged Image file Format +alpha",
	//				"TGA Truevision Graphics Adapter file",
	//				"TGA Truevision Graphics Adapter file +alpha",
	//				"BMP BitMaP",
	//				"BMP BitMaP +alpha"@;

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


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

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

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

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

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

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

	photonMapType = eAttr.create( "photonMapType", "photonMapType", 0, &stat);
	stat = eAttr.addField( "PhotonMap", 0 );
	stat = eAttr.addField( "LightMap", 1 );
	CHECK_MSTATUS(addAttribute( photonMapType ));

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

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

	photonNBlur = nAttr.create("photonNBlur", "photonNBlur",  MFnNumericData::kInt, 400);
	CHECK_MSTATUS(addAttribute( photonNBlur ));

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

	photonPrecacheDist = nAttr.create("photonPrecacheDist", "photonPrecacheDist",  MFnNumericData::kFloat, 50.0f);
	CHECK_MSTATUS(addAttribute( photonPrecacheDist ));

	photonPrecacheBlur = nAttr.create("photonPrecacheBlur", "photonPrecacheBlur",  MFnNumericData::kFloat, 100.0f);
	CHECK_MSTATUS(addAttribute( photonPrecacheBlur ));

	photonAutoPhotonsLow = nAttr.create("photonAutoPhotonsLow", "photonAutoPhotonsLow",  MFnNumericData::kFloat, 20.0);
	CHECK_MSTATUS(addAttribute( photonAutoPhotonsLow ));

	photonAutoPhotonsHigh = nAttr.create("photonAutoPhotonsHigh", "photonAutoPhotonsHigh",  MFnNumericData::kFloat, 80.0f);
	CHECK_MSTATUS(addAttribute( photonAutoPhotonsHigh ));

	photonAutoPhotonsSteps = nAttr.create("photonAutoPhotonsSteps", "photonAutoPhotonsSteps",  MFnNumericData::kFloat, 4.0f);
	CHECK_MSTATUS(addAttribute( photonAutoPhotonsSteps ));

	// caustics
	causticsAddToLightmap = nAttr.create("causticsAddToLightmap", "causticsAddToLightmap",  MFnNumericData::kBoolean, true);
	CHECK_MSTATUS(addAttribute( causticsAddToLightmap ));

	causticsCount = nAttr.create("causticsCount", "causticsCount",  MFnNumericData::kInt, 50000);
	CHECK_MSTATUS(addAttribute( causticsCount ));

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

	causticsAutoPhotonsLow = nAttr.create("causticsAutoPhotonsLow", "causticsAutoPhotonsLow",  MFnNumericData::kFloat, 20.0);
	CHECK_MSTATUS(addAttribute( causticsAutoPhotonsLow ));

	causticsAutoPhotonsHigh = nAttr.create("causticsAutoPhotonsHigh", "causticsAutoPhotonsHigh",  MFnNumericData::kFloat, 80.0f);
	CHECK_MSTATUS(addAttribute( causticsAutoPhotonsHigh ));

	causticsAutoPhotonsSteps = nAttr.create("causticsAutoPhotonsSteps", "causticsAutoPhotonsSteps",  MFnNumericData::kFloat, 4.0f);
	CHECK_MSTATUS(addAttribute( causticsAutoPhotonsSteps ));

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

	causticsNBlur = nAttr.create("causticsNBlur", "causticsNBlur",  MFnNumericData::kInt, 400);
	CHECK_MSTATUS(addAttribute( causticsNBlur ));

	// FG
	fgThreshold = nAttr.create("fgThreshold", "fgThreshold",  MFnNumericData::kFloat, .0001f);
	CHECK_MSTATUS(addAttribute( fgThreshold ));

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

	fgMaxRays = nAttr.create("fgMaxRays", "fgMaxRays",  MFnNumericData::kInt, 600);
	CHECK_MSTATUS(addAttribute( fgMaxRays ));

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

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

	fgSplotchDetect = nAttr.create("fgSplotchDetect", "fgSplotchDetect",  MFnNumericData::kFloat, .05f);
	CHECK_MSTATUS(addAttribute( fgSplotchDetect ));

	fgSensitivity = nAttr.create("fgSensitivity", "fgSensitivity",  MFnNumericData::kFloat, .05f);
	CHECK_MSTATUS(addAttribute( fgSensitivity ));

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

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

	fgSpatialTolerance = nAttr.create("fgSpatialTolerance", "fgSpatialTolerance",  MFnNumericData::kFloat, .1f);
	CHECK_MSTATUS(addAttribute( fgSpatialTolerance ));

	fgAngularTolerance = nAttr.create("fgAngularTolerance", "fgAngularTolerance",  MFnNumericData::kFloat, 30.0f);
	CHECK_MSTATUS(addAttribute( fgAngularTolerance ));

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

	fgDistMax = nAttr.create("fgDistMax", "fgDistMax",  MFnNumericData::kFloat, 3000.00f);
	CHECK_MSTATUS(addAttribute( fgDistMax ));

	fgBrightness = nAttr.create("fgBrightness", "fgBrightness",  MFnNumericData::kFloat, 0.00f);
	CHECK_MSTATUS(addAttribute( fgBrightness ));

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

	fgCornerDist = nAttr.create("fgCornerDist", "fgCornerDist",  MFnNumericData::kFloat, 50.00f);
	CHECK_MSTATUS(addAttribute( fgCornerDist ));

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

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

	jpgQuality = nAttr.create("jpgQuality", "jpgQuality",  MFnNumericData::kInt, 75);
	nAttr.setMin(0);
	nAttr.setMax(100);
	CHECK_MSTATUS(addAttribute( jpgQuality ));
	
	qLuminosityModel = eAttr.create( "qLuminosityModel", "qLuminosityModel", 0, &stat);
	stat = eAttr.addField( "Compute as Indirect", 0 );
	stat = eAttr.addField( "Compute as Direct", 1 );
	stat = eAttr.addField( "Automatic", 2 );
	CHECK_MSTATUS(addAttribute( qLuminosityModel ));

	qLevel = nAttr.create("qLevel", "qLevel",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qLevel ));

	qAreaLights = eAttr.create( "qAreaLights", "qAreaLights", 0, &stat);
	stat = eAttr.addField( "Compute Separately (AS)", 0 );
	stat = eAttr.addField( "Compute With Luminosity", 1 );
	CHECK_MSTATUS(addAttribute( qAreaLights ));

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

	qAreaLightVisibility = eAttr.create( "qAreaLightVisibility", "qAreaLightVisibility", 0, &stat);
	stat = eAttr.addField( "Visible (Realistic)", 0 );
	stat = eAttr.addField( "Invisible", 1 );
	CHECK_MSTATUS(addAttribute( qAreaLightVisibility ));

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

	qAreaLightsThreshold = nAttr.create("qAreaLightsThreshold", "qAreaLightsThreshold",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qAreaLightsThreshold ));

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

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

	qLinearLightsThreshold = nAttr.create("qLinearLightsThreshold", "qLinearLightsThreshold",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qLinearLightsThreshold ));

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

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

	qLuminosityThreshold = nAttr.create("qLuminosityThreshold", "qLuminosityThreshold",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qLuminosityThreshold ));

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

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

	qBlurringThreshold = nAttr.create("qBlurringThreshold", "qBlurringThreshold",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qBlurringThreshold ));

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

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

	qBAccuracyLimit = nAttr.create("qBAccuracyLimit", "qBAccuracyLimit",  MFnNumericData::kFloat, 1.00f);
	CHECK_MSTATUS(addAttribute( qBAccuracyLimit ));

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

	qOctreeDetail = eAttr.create( "qOctreeDetail", "qOctreeDetail", 0, &stat);
	stat = eAttr.addField( "Very Low", 0 );
	stat = eAttr.addField( "Low", 1 );
	stat = eAttr.addField( "Normal", 2 );
	stat = eAttr.addField( "High", 3 );
	CHECK_MSTATUS(addAttribute( qOctreeDetail ));

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


	return stat;

}
コード例 #17
0
ファイル: rigidBodyNode.cpp プロジェクト: benelot/dynamica
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;
}
コード例 #18
0
// initializes attribute information
// call by MAYA when this plug-in was loded.
//
MStatus anisotropicShaderNode::initialize()
{
    MFnNumericAttribute nAttr; 
    MFnLightDataAttribute lAttr;
    MFnMatrixAttribute mAttr;

    aMatrixOToW = mAttr.create( "matrixObjectToWorld", "mow",
								MFnMatrixAttribute::kFloat );
 
    CHECK_MSTATUS( mAttr.setStorable( false ) );
    CHECK_MSTATUS( mAttr.setHidden( true ) );

    aMatrixWToC = mAttr.create( "matrixWorldToEye", "mwc", 
								MFnMatrixAttribute::kFloat );
    CHECK_MSTATUS( mAttr.setStorable( false ) );
    CHECK_MSTATUS( mAttr.setHidden( true ) );

    aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl",
										 MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault(0.8f) );
    CHECK_MSTATUS( nAttr.setMin(0.0f) );
    CHECK_MSTATUS( nAttr.setMax(1.0f) );

    aColor = nAttr.createColor( "color", "c" );
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault(0.0f, 0.58824f, 0.644f) );

    aNormalCamera = nAttr.createPoint( "normalCamera", "n" );
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setHidden(true) );

    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) );

    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) );

    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) );

    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) );

    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) );

    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) );

    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) );

    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( "lightDataArray", "ltd",
                aLightDirection, 
                aLightIntensity, 
                aLightAmbient, 
                aLightDiffuse, 
                aLightSpecular,
                aLightShadowFraction,
                aPreShadowIntensity,
                aLightBlindData);
    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, 0.0f, 1.0f, NULL) );

    aSpecularCoeff = nAttr.create( "specularCoeff", "scf", 
								   MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setMin(0.0f) );
    CHECK_MSTATUS( nAttr.setMax(1.0f) );
    CHECK_MSTATUS( nAttr.setDefault(0.8f) );

    aPointCamera = nAttr.createPoint( "pointCamera", "pc" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setHidden(true) );

    // input transparency
    aInTransparency = nAttr.createColor( "transparency", "it" );
    MAKE_INPUT(nAttr);

    // ray direction
    aRayDirection = nAttr.createPoint( "rayDirection", "rd" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setHidden(true) );

    // specular color
    aSpecColor = nAttr.createColor( "specularColor","sc" );
    CHECK_MSTATUS( nAttr.setDefault( .5, .5, .5 ) );
    MAKE_INPUT(nAttr);

    // anisotropic parameters
    //
    aRoughness1 = nAttr.create( "roughness1", "rn1", MFnNumericData::kFloat);
    CHECK_MSTATUS( nAttr.setMin(0.0f) );
    CHECK_MSTATUS( nAttr.setMax(1.0f) );
    CHECK_MSTATUS( nAttr.setDefault(0.2f) );

    aRoughness2 = nAttr.create( "roughness2", "rn2", MFnNumericData::kFloat);
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setMin(0.0f) );
    CHECK_MSTATUS( nAttr.setMax(1.0f) );
    CHECK_MSTATUS( nAttr.setDefault(0.4f) );

    aAxesVector = nAttr.createPoint( "axesVector", "av" );
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault( 0.0f, 1.0f, 0.0f ) );

    // output color
    aOutColor = nAttr.createColor( "outColor", "oc" );
	MAKE_OUTPUT(nAttr);

    // output transparency
    aOutTransparency = nAttr.createColor( "outTransparency", "ot" );
	MAKE_OUTPUT(nAttr);

    setAttribute();

    return MS::kSuccess;
}
コード例 #19
0
ファイル: softBodyNode.cpp プロジェクト: benelot/dynamica
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;
}
コード例 #20
0
ファイル: mtm_envlight.cpp プロジェクト: MassW/OpenMaya
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;
}
コード例 #21
0
ファイル: cellShader.cpp プロジェクト: DimondTheCat/xray
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus Cell3D::initialize()
{
    MFnMatrixAttribute mAttr;
    MFnNumericAttribute nAttr; 

	// Input attributes

    aColorGain = nAttr.createColor("colorGain", "cg");
    MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setDefault(1.0f,1.0f,1.0f) );

    aColorOffset = nAttr.createColor("colorOffset", "co");
    MAKE_INPUT(nAttr);
    
    aPlaceMat = mAttr.create("placementMatrix", "pm", 
							 MFnMatrixAttribute::kFloat);
    MAKE_INPUT(mAttr);

	// Implicit shading network attributes

    aPointWorld = nAttr.createPoint("pointWorld", "pw");
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS( nAttr.setHidden(true) );

	// Create output attributes

    aOutF0 = nAttr.create( "F0", "f0", MFnNumericData::kFloat);
    MAKE_OUTPUT(nAttr);

    aOutF1 = nAttr.create( "F1", "f1", MFnNumericData::kFloat);
    MAKE_OUTPUT(nAttr);

    aOutN0 = nAttr.create( "N0", "n0", MFnNumericData::kFloat);
    MAKE_OUTPUT(nAttr);

    aOutBorderDist = nAttr.create("borderDistance", "bd", 
								  MFnNumericData::kFloat);
    MAKE_OUTPUT(nAttr);
    
    aOutColor = nAttr.createColor("outColor", "oc");
	MAKE_OUTPUT(nAttr);

    aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
	MAKE_OUTPUT(nAttr);

	// Add attributes to the node database.

    CHECK_MSTATUS( addAttribute(aColorGain) );
    CHECK_MSTATUS( addAttribute(aColorOffset) );
    CHECK_MSTATUS( addAttribute(aPointWorld) );
    CHECK_MSTATUS( addAttribute(aPlaceMat) );

    CHECK_MSTATUS( addAttribute(aOutAlpha) );
    CHECK_MSTATUS( addAttribute(aOutColor) );
    CHECK_MSTATUS( addAttribute(aOutF0) );
    CHECK_MSTATUS( addAttribute(aOutF1) );
    CHECK_MSTATUS( addAttribute(aOutN0) );
    CHECK_MSTATUS( addAttribute(aOutBorderDist) );

    // All input affect the output color and alpha

    CHECK_MSTATUS( attributeAffects (aColorGain, aOutColor) );
    CHECK_MSTATUS( attributeAffects (aColorOffset, aOutColor) );
    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutColor) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutColor) );

    CHECK_MSTATUS( attributeAffects (aColorGain, aOutAlpha) );
    CHECK_MSTATUS( attributeAffects (aColorOffset, aOutAlpha) );
    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutAlpha) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutAlpha) );

    // Geometry attribute affect all other outputs.

    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF0) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF0) );

    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF1) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF1) );

    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutN0) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutN0) );

    CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutBorderDist) );
    CHECK_MSTATUS( attributeAffects (aPointWorld, aOutBorderDist) );

    return MS::kSuccess;
}
コード例 #22
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;
}
コード例 #23
0
ファイル: volumeShader.cpp プロジェクト: BigRoy/Maya-devkit
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus VolumeNode::initialize()
{
	MFnNumericAttribute nAttr; 

	// Inputs
	aColor = nAttr.createColor( "color", "c" );
    CHECK_MSTATUS( nAttr.setKeyable( true ) );
    CHECK_MSTATUS( nAttr.setStorable( true ) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setDefault(1.0f, 1.0f, 1.0f) );

    aInputValue = nAttr.create( "distance", "d", MFnNumericData::kFloat);
    CHECK_MSTATUS( nAttr.setMin(0.0f) );
    CHECK_MSTATUS(nAttr.setMax(100000.0f) );
    CHECK_MSTATUS( nAttr.setSoftMax(1000.0f) );
    CHECK_MSTATUS( nAttr.setSoftMax(1000.0f) );
    CHECK_MSTATUS( nAttr.setKeyable(true) );
    CHECK_MSTATUS(nAttr.setStorable(true)  );
    CHECK_MSTATUS( nAttr.setDefault(1.0f) );


    aToggleCamera = nAttr.create( "cameraSpace", "cs", 
								  MFnNumericData::kBoolean);

    CHECK_MSTATUS( nAttr.setKeyable(true) );
    CHECK_MSTATUS( nAttr.setStorable(true) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setDefault(false) );

    aToggleObject = nAttr.create( "objectSpace", "os", 
								  MFnNumericData::kBoolean);
    CHECK_MSTATUS( nAttr.setKeyable(true) );
    CHECK_MSTATUS( nAttr.setStorable(true) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setDefault(false) );

    aToggleWorld = nAttr.create( "worldSpace", "ws", MFnNumericData::kBoolean);
    CHECK_MSTATUS(nAttr.setKeyable(true)  );
    CHECK_MSTATUS( nAttr.setStorable(true) );
    CHECK_MSTATUS(nAttr.setHidden(false)  );
    CHECK_MSTATUS( nAttr.setDefault(true) );

    aFarPointC = nAttr.createPoint("farPointCamera", "fc" );
    CHECK_MSTATUS(nAttr.setStorable(false)  );
    CHECK_MSTATUS( nAttr.setHidden(true) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(true) );

    aFarPointO = nAttr.createPoint("farPointObj", "fo" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS(nAttr.setHidden(true)  );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(true) );

    aFarPointW = nAttr.createPoint("farPointWorld", "fw" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(true) );
    CHECK_MSTATUS(nAttr.setReadable(true)  );
    CHECK_MSTATUS( nAttr.setWritable(true) );

    aPointC = nAttr.createPoint("pointCamera", "p" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(true) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(true) );

    aPointO = nAttr.createPoint("pointObj", "po" );
    CHECK_MSTATUS( nAttr.setStorable(false)  );
    CHECK_MSTATUS( nAttr.setHidden(true) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(true) );

    aPointW = nAttr.createPoint("pointWorld", "pw" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(true) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(true) );

	// Outputs

    aOutColor = nAttr.createColor( "outColor", "oc" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(false) );

    aOutTransparency = nAttr.createColor( "outTransparency", "ot" );
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(false) );

    aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
    CHECK_MSTATUS( nAttr.setStorable(false) );
    CHECK_MSTATUS( nAttr.setHidden(false) );
    CHECK_MSTATUS( nAttr.setReadable(true) );
    CHECK_MSTATUS( nAttr.setWritable(false) );

    CHECK_MSTATUS( addAttribute(aColor) );
    CHECK_MSTATUS( addAttribute(aInputValue) );
    CHECK_MSTATUS( addAttribute(aFarPointC) );
    CHECK_MSTATUS( addAttribute(aFarPointO) );
    CHECK_MSTATUS( addAttribute(aFarPointW) );
    CHECK_MSTATUS( addAttribute(aPointC) );
    CHECK_MSTATUS( addAttribute(aPointO) );
    CHECK_MSTATUS( addAttribute(aPointW) );
    CHECK_MSTATUS( addAttribute(aToggleCamera) );
    CHECK_MSTATUS( addAttribute(aToggleObject) );
    CHECK_MSTATUS( addAttribute(aToggleWorld) );

    CHECK_MSTATUS( addAttribute(aOutColor) );
    CHECK_MSTATUS( addAttribute(aOutTransparency) );
    CHECK_MSTATUS( addAttribute(aOutAlpha) );

    CHECK_MSTATUS( attributeAffects(aColor,  aOutColor) );
    CHECK_MSTATUS( attributeAffects(aColor,  aOutTransparency) );

    CHECK_MSTATUS( attributeAffects(aFarPointC, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aFarPointO, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aFarPointW, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aPointC, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aPointO, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aPointW, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aToggleCamera, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aToggleObject, aOutColor) );
    CHECK_MSTATUS( attributeAffects(aToggleWorld, aOutColor) );

    return MS::kSuccess;
}
コード例 #24
0
ファイル: shiftNode.cpp プロジェクト: BigRoy/Maya-devkit
// initializes attribute information
MStatus shiftNode::initialize()
{
	MStatus stat;

	MFnNumericAttribute nAttr; 

	// shift

	aShift = nAttr.create( "shift", "sh", 
						  MFnNumericData::kBoolean, false );
	stat = addAttribute( aShift );
	PERRORfail( stat, "addAttribute shift" );

	// distance

	aDist = nAttr.create( "distance", "dis", 
						 MFnNumericData::kFloat, 0.0 );
	stat = addAttribute( aDist );
	PERRORfail( stat, "addAttribute dist" );

	// inColor

	aColor = nAttr.createColor( "color", "c" );
	nAttr.setStorable(false);
	stat = addAttribute( aColor );
	PERRORfail( stat, "addAttribute inColor" );
	
	// refPointCamera

	aRefPointCamera = nAttr.createPoint( "refPointCamera", "rpc" );
	nAttr.setStorable(false);
	nAttr.setWritable(true);
	nAttr.setRenderSource(true);
	nAttr.setHidden(true);
	stat = addAttribute( aRefPointCamera );
	PERRORfail( stat, "addAttribute refPointCamera" );

	// uv

	MObject u = nAttr.create( "uCoord", "u", MFnNumericData::kFloat, 0.0 );
	MObject v = nAttr.create( "vCoord", "v", MFnNumericData::kFloat, 0.0 );
	aUv = nAttr.create( "uvCoord", "uv", u, v );
	nAttr.setStorable(false);
	nAttr.setWritable(true);
	nAttr.setRenderSource(true);
	nAttr.setHidden(true);
	stat = addAttribute( aUv );
	PERRORfail( stat, "addAttribute uv" );

	// create output attributes here

    aOutColor = nAttr.createColor( "outColor", "oc" );
	PERRORfail(stat, "initialize create outColor attribute");
	nAttr.setReadable( true );
	nAttr.setWritable( false );
	stat = addAttribute( aOutColor );
	PERRORfail(stat, "addAttribute(outColor)");
	
	// attribute affects

	attributeAffects ( aShift, aOutColor );
	attributeAffects ( aDist, aOutColor );
	attributeAffects ( aColor, aOutColor );
	attributeAffects ( aRefPointCamera, aOutColor );
	attributeAffects ( aUv, aOutColor );

	// we need to do the followings to cause other input attributes
	// to evaluate with the new values we set

	attributeAffects ( aUv, aUv );
	attributeAffects ( aRefPointCamera, aRefPointCamera );

	return MS::kSuccess;
}
コード例 #25
0
ファイル: dSolverNode.cpp プロジェクト: Belxjander/Asuna
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;
}
コード例 #26
0
ファイル: noiseShader.cpp プロジェクト: DimondTheCat/xray
// initializes attribute information
MStatus noise3::initialize()
{
    MFnMatrixAttribute mAttr; 
    MFnNumericAttribute nAttr; 

	// Create input attributes

	aColor1 = nAttr.createColor("color1", "c1");
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS ( nAttr.setDefault(0., .58824, .644) );		// Light blue

	aColor2 = nAttr.createColor("color2", "c2");
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS ( nAttr.setDefault(1., 1., 1.) );			// White

    aScale = nAttr.create( "scale", "s", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setDefault( 1. ) );

    aBias = nAttr.create( "bias", "b", MFnNumericData::kFloat);
	MAKE_INPUT(nAttr);

    aPlaceMat = mAttr.create("placementMatrix", "pm",
							 MFnMatrixAttribute::kFloat);
    MAKE_INPUT(mAttr);

	// Implicit shading network attributes

    aPointWorld = nAttr.createPoint("pointWorld", "pw");
	MAKE_INPUT(nAttr);
    CHECK_MSTATUS ( nAttr.setHidden(true) );

    // Create output attributes

    aOutColor = nAttr.createColor("outColor", "oc");
	MAKE_OUTPUT(nAttr);

    aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat);
	MAKE_OUTPUT(nAttr);

    // Add the attributes here
    CHECK_MSTATUS ( addAttribute(aColor1) );
    CHECK_MSTATUS ( addAttribute(aColor2) );
    CHECK_MSTATUS ( addAttribute(aScale) );
    CHECK_MSTATUS ( addAttribute(aBias) );
    CHECK_MSTATUS ( addAttribute(aPointWorld) );
    CHECK_MSTATUS ( addAttribute(aPlaceMat) );

    CHECK_MSTATUS ( addAttribute(aOutColor) );
    CHECK_MSTATUS ( addAttribute(aOutAlpha) );

    // All input affect the output color and alpha
    CHECK_MSTATUS ( attributeAffects (aColor1, aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aColor1, aOutAlpha) );

    CHECK_MSTATUS ( attributeAffects (aColor2, aOutColor) ) ;
    CHECK_MSTATUS ( attributeAffects (aColor2, aOutAlpha) );

    CHECK_MSTATUS ( attributeAffects (aScale, aOutAlpha) );
    CHECK_MSTATUS ( attributeAffects (aScale, aOutColor) );

    CHECK_MSTATUS ( attributeAffects (aBias, aOutAlpha) );
    CHECK_MSTATUS ( attributeAffects (aBias, aOutColor) ); 

    CHECK_MSTATUS ( attributeAffects (aPointWorld, aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aPointWorld, aOutAlpha) );

    CHECK_MSTATUS ( attributeAffects (aPlaceMat, aOutColor) );
    CHECK_MSTATUS ( attributeAffects (aPlaceMat, aOutAlpha) );

    return MS::kSuccess;
}
コード例 #27
0
	static MStatus initialize()
	{
		// set up uder-defined attribute
		MFnNumericAttribute numericAttrFn;
		MFnGenericAttribute genericAttrFn;

		// enable thie node
		aEnable = numericAttrFn.create( "enbale", "e", MFnNumericData::kBoolean, 0, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setDefault(0);
		numericAttrFn.setKeyable(true);
		addAttribute(aEnable);

		// enable when rendering
		aEnableRender = numericAttrFn.create( "enbaleAsRendering", "er", MFnNumericData::kBoolean, 0, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setDefault(0);
		numericAttrFn.setKeyable(true);
		addAttribute(aEnableRender);


		// Inputs
		//
		// input color
		aColor = numericAttrFn.createColor( "Color", "c", &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setDefault( 0.0, 0.5, 0.0);
		addAttribute(aColor);

		// enable supersampling
		aIsSpuersampling = numericAttrFn.create( "supersampling", "ssp", MFnNumericData::kBoolean, 0, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setDefault(1);
		numericAttrFn.setKeyable(true);
		addAttribute(aIsSpuersampling);

		// filter size
	/*	aFSize = numericAttrFn.create( "filterSize", "fs", MFnNumericData::k3Float, 0.0, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setMin( 0.0, 0.0, 0.0 );
		numericAttrFn.setMax( 10.0, 10.0, 10.0 );
		numericAttrFn.setDefault( 1.0, 1.0, 1.0 );
		addAttribute(aFSize);
*/
		// filter size
		aFilterSize = numericAttrFn.create( "filterSizes", "fls", MFnNumericData::k2Int, 0, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setMin( 0, 0 );
		numericAttrFn.setMax( 10, 10 );
		numericAttrFn.setDefault( 0, 0 );
		addAttribute(aFilterSize);

		// sample offset
		aOffsetSample = numericAttrFn.create( "sampleOffset", "ao", MFnNumericData::kFloat, 0.0 , &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setSoftMin( 0.0f );
		numericAttrFn.setSoftMax( 0.1f );
		numericAttrFn.setDefault( 0.01f);
		addAttribute(aOffsetSample);

		// UV coordinate
		MObject uCoord = numericAttrFn.create( "uCoord", "u", MFnNumericData::kDouble );
		MObject vCoord = numericAttrFn.create( "vCoord", "v", MFnNumericData::kDouble );
		aUVCoord = numericAttrFn.create( "uvCoord", "uv", uCoord, vCoord, MObject::kNullObj, &status);
		CHECK_MSTATUS(status);
		numericAttrFn.setHidden(true);
		numericAttrFn.setRenderSource(true);
		addAttribute(aUVCoord);

		// UV filter size
		MObject sUVFilterSizeX = numericAttrFn.create( "uvFilterSizeX", "ufx", MFnNumericData::kFloat );
		MObject sUVFilterSizeY = numericAttrFn.create( "uvFilterSizeY", "ufy", MFnNumericData::kFloat );
		aUVFilterSize = numericAttrFn.create( "uvFilterSize", "uf", sUVFilterSizeX, sUVFilterSizeY, MObject::kNullObj, &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setHidden(true);
		addAttribute(aUVFilterSize);

		// World-space position
		aPointWorld = numericAttrFn.createPoint( "pointWorld", "pw", &status );
		CHECK_MSTATUS(status);
		numericAttrFn.setHidden(true);
		addAttribute(aPointWorld);

		// input Shape as the source
		aShape = genericAttrFn.create( "sourceShape", "s", &status );
		//genericAttrFn.addDataAccept( MFnData::kNurbsSurface );
		genericAttrFn.addAccept( MFnData::kNurbsSurface );
		genericAttrFn.addAccept( MFnData::kMesh );
		CHECK_MSTATUS(status);
		addAttribute(aShape);

		// target shape
		aTargetShape = genericAttrFn.create( "targetShape", "ts", &status );
		//genericAttrFn.addDataAccept( MFnData::kNurbsSurface );
		genericAttrFn.addAccept( MFnData::kNurbsSurface );
		genericAttrFn.addAccept( MFnData::kMesh );
		CHECK_MSTATUS(status);
		addAttribute(aTargetShape);


		// output
		//
		// output color
		aOutColor = numericAttrFn.createColor( "outColor", "oc", &status);
		CHECK_MSTATUS(status);
		numericAttrFn.setWritable(false);
		addAttribute(aOutColor);


		// affect Attribute
		//attributeAffects( aFSize, aOutColor );
		attributeAffects( aEnable, aOutColor );
		attributeAffects( aEnableRender, aOutColor );
		attributeAffects( aColor, aOutColor );
		attributeAffects( aIsSpuersampling, aOutColor );
		attributeAffects( aFilterSize, aOutColor );
		attributeAffects( aOffsetSample, aOutColor );
		attributeAffects( aUVCoord, aOutColor );
		attributeAffects( aUVFilterSize, aOutColor );
		attributeAffects( aPointWorld, aOutColor );
		attributeAffects( aShape, aOutColor );
		attributeAffects( aTargetShape, aOutColor );

		attributeAffects( aUVCoord, aUVCoord );
		return MS::kSuccess;
	}