コード例 #1
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;
}
コード例 #2
0
MStatus
OpenSubdivShader::initialize()
{
    MStatus stat;
    MFnTypedAttribute typedAttr;
    MFnNumericAttribute numAttr;
    MFnEnumAttribute enumAttr;

    aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 1);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setSoftMax(5);

    aScheme = enumAttr.create("scheme", "sc");
    enumAttr.addField("Catmull-Clark", kCatmark);
    enumAttr.addField("Loop", kLoop);
    enumAttr.addField("Bilinear", kBilinear);
    enumAttr.setInternal(true);

    aKernel = enumAttr.create("kernel", "kn");
    enumAttr.addField("CPU", OpenSubdiv::OsdKernelDispatcher::kCPU);
    if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kOPENMP))
        enumAttr.addField("OpenMP", OpenSubdiv::OsdKernelDispatcher::kOPENMP);
    if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kCL))
        enumAttr.addField("CL", OpenSubdiv::OsdKernelDispatcher::kCL);
    if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kCUDA))
        enumAttr.addField("CUDA", OpenSubdiv::OsdKernelDispatcher::kCUDA);
    enumAttr.setInternal(true);

    aDiffuse = numAttr.createColor("diffuse", "d");
    numAttr.setDefault(1.0f, 1.0f, 1.0f);
    aSpecular = numAttr.createColor("specular", "s");
    numAttr.setDefault(1.0f, 1.0f, 1.0f);
    aAmbient = numAttr.createColor("ambient", "a");
    numAttr.setDefault(1.0f, 1.0f, 1.0f);
    aShininess = numAttr.create("shininess", "shin", MFnNumericData::kFloat, 16.0f);
    numAttr.setMin(0);
    numAttr.setMax(128.0f);

    aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean);

    addAttribute(aLevel);
    addAttribute(aScheme);
    addAttribute(aKernel);
    addAttribute(aDiffuse);
    addAttribute(aSpecular);
    addAttribute(aAmbient);
    addAttribute(aShininess);
    addAttribute(aWireframe);

    return MS::kSuccess;
}
コード例 #3
0
MStatus
OpenSubdivPtexShader::initialize()
{
    MFnTypedAttribute typedAttr;
    MFnNumericAttribute numAttr;
    MFnEnumAttribute enumAttr;

    // level
    aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setSoftMax(5);
    numAttr.setMax(10);

    // tessFactor
    aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setMax(10);

    // scheme
    aScheme = enumAttr.create("scheme", "sc", OsdPtexMeshData::kCatmark);
    enumAttr.addField("Catmull-Clark",  OsdPtexMeshData::kCatmark);
    enumAttr.addField("Loop",           OsdPtexMeshData::kLoop);
    enumAttr.addField("Bilinear",       OsdPtexMeshData::kBilinear);
    enumAttr.setInternal(true);

    // kernel
    aKernel = enumAttr.create("kernel", "kn", OsdPtexMeshData::kCPU);
    enumAttr.addField("CPU",    OsdPtexMeshData::kCPU);
#ifdef OPENSUBDIV_HAS_OPENMP
    enumAttr.addField("OpenMP", OsdPtexMeshData::kOPENMP);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
    enumAttr.addField("CL",     OsdPtexMeshData::kCL);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
    enumAttr.addField("CUDA",   OsdPtexMeshData::kCUDA);
#endif
    enumAttr.setInternal(true);

    // interpolateBoundary
    aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib",
                                           OsdPtexMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("None",            OsdPtexMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("Edge Only",       OsdPtexMeshData::kInterpolateBoundaryEdgeOnly);
    enumAttr.addField("Edge and Corner", OsdPtexMeshData::kInterpolateBoundaryEdgeAndCorner);
    enumAttr.addField("Always Sharp",    OsdPtexMeshData::kInterpolateBoundaryAlwaysSharp);
    enumAttr.setInternal(true);

    // adaptive
    aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true);
    numAttr.setInternal(true);

    // wireframe
    aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false);

    // material attributes
    aDiffuse = numAttr.createColor("diffuse",   "d");
    numAttr.setDefault(0.6f, 0.6f, 0.7f);
    aAmbient = numAttr.createColor("ambient",   "a");
    numAttr.setDefault(0.1f, 0.1f, 0.1f);
    aSpecular = numAttr.createColor("specular", "s");
    numAttr.setDefault(0.3f, 0.3f, 0.3f);

    // Ptex Texture Attributes
    //
    // diffuseEnvironmentMapFile;
    aDiffuseEnvironmentMapFile = typedAttr.create("diffuseEnvironmentMap", "difenv", MFnData::kString);
    typedAttr.setInternal(true);
    // don't let maya hold on to string when fileNode is disconnected
    typedAttr.setDisconnectBehavior(MFnAttribute::kReset);

    // specularEnvironmentMapFile;
    aSpecularEnvironmentMapFile = typedAttr.create("specularEnvironmentMap", "specenv", MFnData::kString);
    typedAttr.setInternal(true);
    // don't let maya hold on to string when fileNode is disconnected
    typedAttr.setDisconnectBehavior(MFnAttribute::kReset);

    // colorFile;
    aColorFile = typedAttr.create("colorFile", "cf", MFnData::kString);
    typedAttr.setInternal(true);

    // displacementFile;
    aDisplacementFile = typedAttr.create("displacementFile", "df", MFnData::kString);
    typedAttr.setInternal(true);

    // occlusionFile;
    aOcclusionFile = typedAttr.create("occlusionFile", "of", MFnData::kString);
    typedAttr.setInternal(true);

    // enableDisplacement;
    aEnableDisplacement = numAttr.create("enableDisplacement", "end", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableColor;
    aEnableColor = numAttr.create("enableColor", "enc", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableOcclusion;
    aEnableOcclusion = numAttr.create("enableOcclusion", "eno", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // enableNormal;
    aEnableNormal = numAttr.create("enableNormal", "enn", MFnNumericData::kBoolean, 1);
    numAttr.setInternal(true);

    // fresnelBias;
    aFresnelBias = numAttr.create("fresnelBias", "fb", MFnNumericData::kFloat, 0.2f);
    numAttr.setMin(0);
    numAttr.setMax(1);

    // fresnelScale;
    aFresnelScale = numAttr.create("fresnelScale", "fs", MFnNumericData::kFloat, 1.0f);
    numAttr.setMin(0);
    numAttr.setSoftMax(1);

    // fresnelPower;
    aFresnelPower = numAttr.create("fresnelPower", "fp", MFnNumericData::kFloat, 5.0f);
    numAttr.setMin(0);
    numAttr.setSoftMax(10);

    // shaderSource;
    aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString);
    typedAttr.setInternal(true);


    // add attributes
    addAttribute(aLevel);
    addAttribute(aTessFactor);
    addAttribute(aScheme);
    addAttribute(aKernel);
    addAttribute(aInterpolateBoundary);
    addAttribute(aAdaptive);
    addAttribute(aWireframe);

    addAttribute(aDiffuse);
    addAttribute(aAmbient);
    addAttribute(aSpecular);

    addAttribute(aShaderSource);

    addAttribute(aDiffuseEnvironmentMapFile);
    addAttribute(aSpecularEnvironmentMapFile);
    addAttribute(aColorFile);
    addAttribute(aDisplacementFile);
    addAttribute(aOcclusionFile);

    addAttribute(aEnableDisplacement);
    addAttribute(aEnableColor);
    addAttribute(aEnableOcclusion);
    addAttribute(aEnableNormal);

    addAttribute(aFresnelBias);
    addAttribute(aFresnelScale);
    addAttribute(aFresnelPower);

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

    aIndex = nAttr.create( "index", "ix", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setDefault(1.8f) );
    CHECK_MSTATUS ( nAttr.setSoftMin(1.0f) );
    CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) );

    aScale = nAttr.create( "scale", "s", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setDefault(1.55f) );
    CHECK_MSTATUS ( nAttr.setSoftMin(0.0f) );
    CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) );

    aBias = nAttr.create( "bias", "b", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(true) );
    CHECK_MSTATUS ( nAttr.setDefault(-0.1f) );
    CHECK_MSTATUS ( nAttr.setSoftMin(-1.0f) );
    CHECK_MSTATUS ( nAttr.setSoftMax( 1.0f) );



    aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f) );

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

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


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




    aRayDirectionX = nAttr.create( "rayDirectionX", "rx", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f) );

    aRayDirectionY = nAttr.create( "rayDirectionY", "ry", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false));
    CHECK_MSTATUS ( nAttr.setDefault(1.0f));

    aRayDirectionZ = nAttr.create( "rayDirectionZ", "rz", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f) );

    aRayDirection = nAttr.create( "rayDirection","r",
                                  aRayDirectionX, aRayDirectionY, aRayDirectionZ);
    CHECK_MSTATUS ( nAttr.setStorable(false) );
    CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) );
    CHECK_MSTATUS ( nAttr.setHidden(true) );



// Outputs

    aOutValue = nAttr.create( "outValue", "ov", MFnNumericData::kFloat);
    CHECK_MSTATUS ( nAttr.setHidden(false) );
    CHECK_MSTATUS ( nAttr.setReadable(true) );
    CHECK_MSTATUS ( nAttr.setWritable(false) );



    CHECK_MSTATUS ( addAttribute(aIndex));
    CHECK_MSTATUS ( addAttribute(aScale) );
    CHECK_MSTATUS ( addAttribute(aBias) );

	// compound attribute - only need to add parent
    CHECK_MSTATUS ( addAttribute(aNormalCamera) );

	// compound attribute - only need to add parent
    CHECK_MSTATUS ( addAttribute(aRayDirection) );

    CHECK_MSTATUS ( addAttribute(aOutValue) );


    CHECK_MSTATUS ( attributeAffects (aIndex, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aScale, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aBias, aOutValue) );

    CHECK_MSTATUS ( attributeAffects (aNormalCameraX, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aNormalCameraY, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aNormalCameraZ, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutValue) );

    CHECK_MSTATUS ( attributeAffects (aRayDirectionX, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aRayDirectionY, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aRayDirectionZ, aOutValue) );
    CHECK_MSTATUS ( attributeAffects (aRayDirection, aOutValue) );

    return MS::kSuccess;
}
コード例 #5
0
MStatus pointOnSubd::initialize()
//
//	Description:
//		This method is called to create and initialize all of the attributes
//      and attribute dependencies for this node type.  This is only called 
//		once when the node type is registered with Maya.
//
//	Return Values:
//		MS::kSuccess
//		MS::kFailure
//		
{
	MStatus stat;

	MFnTypedAttribute subdAttr;
	aSubd = subdAttr.create( "subd", "s", MFnSubdData::kSubdSurface, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aSubd" );
 	subdAttr.setStorable(true);
 	subdAttr.setKeyable(false);
	subdAttr.setReadable( true );
	subdAttr.setWritable( true );
	subdAttr.setCached( false );
	stat = addAttribute( pointOnSubd::aSubd );
	McheckErr( stat, "cannot add pointOnSubd::aSubd" );

	MFnNumericAttribute faceFirstAttr;
	aFaceFirst = faceFirstAttr.create( "faceFirst", "ff",
									   MFnNumericData::kLong, 0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aFaceFirst" );
 	faceFirstAttr.setStorable(true);
 	faceFirstAttr.setKeyable(true);
	faceFirstAttr.setSoftMin( 0.0 );
	faceFirstAttr.setReadable( true );
	faceFirstAttr.setWritable( true );
	faceFirstAttr.setCached( false );
	stat = addAttribute( pointOnSubd::aFaceFirst );
	McheckErr( stat, "cannot add pointOnSubd::aFaceFirst" );

	MFnNumericAttribute faceSecondAttr;
	aFaceSecond = faceSecondAttr.create( "faceSecond", "fs",
										 MFnNumericData::kLong, 0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aFaceSecond" );
 	faceSecondAttr.setStorable(true);
 	faceSecondAttr.setKeyable(true);
	faceSecondAttr.setSoftMin( 0.0 );
	faceSecondAttr.setReadable( true );
	faceSecondAttr.setWritable( true );
	faceSecondAttr.setCached( false );
	stat = addAttribute( pointOnSubd::aFaceSecond );
	McheckErr( stat, "cannot add pointOnSubd::aFaceSecond" );

	MFnNumericAttribute uAttr;
	aU = uAttr.create( "uValue", "u", MFnNumericData::kDouble,
					   0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aU" );
 	uAttr.setStorable(true);
 	uAttr.setKeyable(true);
	uAttr.setSoftMin( 0.0 );
	uAttr.setSoftMax( 1.0 );
	uAttr.setReadable( true );
	uAttr.setWritable( true );
	uAttr.setCached( false );
	stat = addAttribute( aU );
	McheckErr( stat, "cannot add pointOnSubd::aU" );

	MFnNumericAttribute vAttr;
	aV = vAttr.create( "vValue", "v", MFnNumericData::kDouble,
					   0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aV" );
 	vAttr.setStorable(true);
 	vAttr.setKeyable(true);
	vAttr.setSoftMin( 0.0 );
	vAttr.setSoftMax( 1.0 );
	vAttr.setReadable( true );
	vAttr.setWritable( true );
	vAttr.setCached( false );
	stat = addAttribute( aV );
	McheckErr( stat, "cannot add pointOnSubd::aV" );

	MFnNumericAttribute relAttr;
	aRelativeUV = relAttr.create( "relative", "rel", MFnNumericData::kBoolean,
								  0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aRelativeUV" );
 	relAttr.setStorable(true);
 	relAttr.setKeyable(true);
	relAttr.setSoftMin( 0.0 );
	relAttr.setSoftMax( 1.0 );
	relAttr.setReadable( true );
	relAttr.setWritable( true );
	relAttr.setCached( false );
	stat = addAttribute( pointOnSubd::aRelativeUV );
	McheckErr( stat, "cannot add pointOnSubd::aRelativeUV" );

	MFnNumericAttribute pointXAttr;
	aPointX = pointXAttr.create( "pointX", "px", MFnNumericData::kDouble,
								0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aPointX" );
	pointXAttr.setWritable(false);
	pointXAttr.setStorable(false);
	pointXAttr.setReadable( true );
	pointXAttr.setCached( true );
	stat = addAttribute( aPointX );
	McheckErr( stat, "cannot add pointOnSubd::aPointX" );

	MFnNumericAttribute pointYAttr;
	aPointY = pointYAttr.create( "pointY", "py", MFnNumericData::kDouble,
								0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aPointY" );
	pointYAttr.setWritable(false);
	pointYAttr.setStorable(false);
	pointYAttr.setReadable( true );
	pointYAttr.setCached( true );
	stat = addAttribute( aPointY );
	McheckErr( stat, "cannot add pointOnSubd::aPointY" );

	MFnNumericAttribute pointZAttr;
	aPointZ = pointZAttr.create( "pointZ", "pz", MFnNumericData::kDouble,
								0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aPointZ" );
	pointZAttr.setWritable(false);
	pointZAttr.setStorable(false);
	pointZAttr.setReadable( true );
	pointZAttr.setCached( true );
	stat = addAttribute( aPointZ );
	McheckErr( stat, "cannot add pointOnSubd::aPointZ" );

	MFnNumericAttribute pointAttr;
	aPoint = pointAttr.create( "point", "p", aPointX, aPointY, aPointZ, &stat);
	McheckErr( stat, "cannot create pointOnSubd::aPoint" );
	pointAttr.setWritable(false);
	pointAttr.setStorable(false);
	pointAttr.setReadable( true );
	pointAttr.setCached( true );
	stat = addAttribute( aPoint );
	McheckErr( stat, "cannot add pointOnSubd::aPoint" );

	MFnNumericAttribute normalXAttr;
	aNormalX = normalXAttr.create( "normalX", "nx", MFnNumericData::kDouble,
								   0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aNormal" );
	normalXAttr.setWritable(false);
	normalXAttr.setStorable(false);
	normalXAttr.setReadable( true );
	normalXAttr.setCached( true );
	stat = addAttribute( aNormalX );
	McheckErr( stat, "cannot add pointOnSubd::aNormalX" );

	MFnNumericAttribute normalYAttr;
	aNormalY = normalYAttr.create( "normalY", "ny", MFnNumericData::kDouble,
								   0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aNormal" );
	normalYAttr.setWritable(false);
	normalYAttr.setStorable(false);
	normalYAttr.setReadable( true );
	normalYAttr.setCached( true );
	stat = addAttribute( aNormalY );
	McheckErr( stat, "cannot add pointOnSubd::aNormalY" );

	MFnNumericAttribute normalZAttr;
	aNormalZ = normalZAttr.create( "normalZ", "nz", MFnNumericData::kDouble,
								   0.0, &stat );
	McheckErr( stat, "cannot create pointOnSubd::aNormal" );
	normalZAttr.setWritable(false);
	normalZAttr.setStorable(false);
	normalZAttr.setReadable( true );
	normalZAttr.setCached( true );
	stat = addAttribute( aNormalZ );
	McheckErr( stat, "cannot add pointOnSubd::aNormalZ" );

	MFnNumericAttribute normalAttr;
	aNormal = normalAttr.create("normal","n",aNormalX,aNormalY,aNormalZ,&stat);
	McheckErr( stat, "cannot create pointOnSubd::aNormal" );
	normalAttr.setWritable(false);
	normalAttr.setStorable(false);
	normalAttr.setReadable( true );
	normalAttr.setCached( true );
	stat = addAttribute( aNormal );
	McheckErr( stat, "cannot add pointOnSubd::aNormal" );


	// Set up a dependency between the input and the output.  This will cause
	// the output to be marked dirty when the input changes.  The output will
	// then be recomputed the next time the value of the output is requested.
	//
	stat = attributeAffects( aSubd, aPoint );
	stat = attributeAffects( aSubd, aPointX );
	stat = attributeAffects( aSubd, aPointY );
	stat = attributeAffects( aSubd, aPointZ );
	stat = attributeAffects( aSubd, aNormal );
	stat = attributeAffects( aSubd, aNormalX );
	stat = attributeAffects( aSubd, aNormalY );
	stat = attributeAffects( aSubd, aNormalZ );

	stat = attributeAffects( aFaceFirst, aPoint );
	stat = attributeAffects( aFaceFirst, aPointX );
	stat = attributeAffects( aFaceFirst, aPointY );
	stat = attributeAffects( aFaceFirst, aPointZ );
	stat = attributeAffects( aFaceFirst, aNormal );
	stat = attributeAffects( aFaceFirst, aNormalX );
	stat = attributeAffects( aFaceFirst, aNormalY );
	stat = attributeAffects( aFaceFirst, aNormalZ );

	stat = attributeAffects( aFaceSecond, aPoint );
	stat = attributeAffects( aFaceSecond, aPointX );
	stat = attributeAffects( aFaceSecond, aPointY );
	stat = attributeAffects( aFaceSecond, aPointZ );
	stat = attributeAffects( aFaceSecond, aNormal );
	stat = attributeAffects( aFaceSecond, aNormalX );
	stat = attributeAffects( aFaceSecond, aNormalY );
	stat = attributeAffects( aFaceSecond, aNormalZ );

	stat = attributeAffects( aU, aPoint );
	stat = attributeAffects( aU, aPointX );
	stat = attributeAffects( aU, aPointY );
	stat = attributeAffects( aU, aPointZ );
	stat = attributeAffects( aU, aNormal );
	stat = attributeAffects( aU, aNormalX );
	stat = attributeAffects( aU, aNormalY );
	stat = attributeAffects( aU, aNormalZ );

	stat = attributeAffects( aV, aPoint );
	stat = attributeAffects( aV, aPointX );
	stat = attributeAffects( aV, aPointY );
	stat = attributeAffects( aV, aPointZ );
	stat = attributeAffects( aV, aNormal );
	stat = attributeAffects( aV, aNormalX );
	stat = attributeAffects( aV, aNormalY );
	stat = attributeAffects( aV, aNormalZ );

	stat = attributeAffects( aRelativeUV, aPoint );
	stat = attributeAffects( aRelativeUV, aPointX );
	stat = attributeAffects( aRelativeUV, aPointY );
	stat = attributeAffects( aRelativeUV, aPointZ );
	stat = attributeAffects( aRelativeUV, aNormal );
	stat = attributeAffects( aRelativeUV, aNormalX );
	stat = attributeAffects( aRelativeUV, aNormalY );
	stat = attributeAffects( aRelativeUV, aNormalZ );

	return MS::kSuccess;

}
コード例 #6
0
// The initialize routine is called after the node has been created.
// It sets up the input and output attributes and adds them to the node.
// Finally the dependencies are arranged so that when the inputs
// change Maya knowns to call compute to recalculate the output values.
//
MStatus hwColorPerVertexShader::initialize()
{
    MFnNumericAttribute nAttr; 
    MFnTypedAttribute tAttr; 
	MStatus status;

    // Create input attributes.
	// All attributes are cached internal
	//
    aColorGain = nAttr.createColor( "colorGain", "cg", &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(1.f, 1.f, 1.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aTranspGain = nAttr.create("transparencyGain", "tg",
						  MFnNumericData::kFloat, 1.f, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(1.f));
    CHECK_MSTATUS( nAttr.setSoftMin(0.f));
    CHECK_MSTATUS( nAttr.setSoftMax(2.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aColorBias = nAttr.createColor( "colorBias", "cb", &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(0.f, 0.f, 0.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aTranspBias = nAttr.create( "transparencyBias", "tb",
						   MFnNumericData::kFloat, 0.f, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(0.f));
    CHECK_MSTATUS( nAttr.setSoftMin(-1.f));
    CHECK_MSTATUS( nAttr.setSoftMax(1.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );

	aNormalsPerVertex = nAttr.create("normalsPerVertex", "nv",
		MFnNumericData::kInt, 0, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(false));
    CHECK_MSTATUS( nAttr.setDefault(0));
    CHECK_MSTATUS( nAttr.setSoftMin(0));
    CHECK_MSTATUS( nAttr.setSoftMax(3));
	nAttr.setCached( true );
	nAttr.setInternal( true );

	aColorsPerVertex = nAttr.create("colorsPerVertex", "cv",
		MFnNumericData::kInt, 0, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(false));
    CHECK_MSTATUS( nAttr.setDefault(0));
    CHECK_MSTATUS( nAttr.setSoftMin(0));
    CHECK_MSTATUS( nAttr.setSoftMax(5));
	nAttr.setCached( true );
	nAttr.setInternal( true );

	aColorSetName = tAttr.create("colorSetName", "cs",
		MFnData::kString, MObject::kNullObj, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( tAttr.setStorable(true));
    CHECK_MSTATUS( tAttr.setKeyable(false));
	tAttr.setCached( true );
	tAttr.setInternal( true );

    aTexRotateX = nAttr.create( "texRotateX", "tx",
						   MFnNumericData::kFloat, 0.f, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(0.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );
	
    aTexRotateY = nAttr.create( "texRotateY", "ty",
						   MFnNumericData::kFloat, 0.f, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(0.f));
	nAttr.setCached( true );
	nAttr.setInternal( true );

    aTexRotateZ = nAttr.create( "texRotateZ", "tz",
						   MFnNumericData::kFloat, 0.f, &status);
    CHECK_MSTATUS( status );
    CHECK_MSTATUS( nAttr.setStorable(true));
    CHECK_MSTATUS( nAttr.setKeyable(true));
    CHECK_MSTATUS( nAttr.setDefault(0.f));
	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

    CHECK_MSTATUS( addAttribute(aColorGain));
    CHECK_MSTATUS( addAttribute(aTranspGain));
    CHECK_MSTATUS( addAttribute(aColorBias));
    CHECK_MSTATUS( addAttribute(aTranspBias));
	CHECK_MSTATUS( addAttribute(aNormalsPerVertex));
	CHECK_MSTATUS( addAttribute(aColorsPerVertex));
	CHECK_MSTATUS( addAttribute(aColorSetName));
	CHECK_MSTATUS( addAttribute(aTexRotateX));
	CHECK_MSTATUS( addAttribute(aTexRotateY));
	CHECK_MSTATUS( addAttribute(aTexRotateZ));

    CHECK_MSTATUS( attributeAffects (aColorGain,  outColor));
    CHECK_MSTATUS( attributeAffects (aTranspGain, outColor));
    CHECK_MSTATUS( attributeAffects (aColorBias,  outColor));
    CHECK_MSTATUS( attributeAffects (aTranspBias, outColor));
    CHECK_MSTATUS( attributeAffects (aNormalsPerVertex, outColor));
    CHECK_MSTATUS( attributeAffects (aColorsPerVertex, outColor));
    CHECK_MSTATUS( attributeAffects (aColorSetName, outColor));
    CHECK_MSTATUS( attributeAffects (aTexRotateX, outColor));
    CHECK_MSTATUS( attributeAffects (aTexRotateY, outColor));
    CHECK_MSTATUS( attributeAffects (aTexRotateZ, outColor));

    return MS::kSuccess;
}
コード例 #7
0
ファイル: BPT_insertVtxNode.cpp プロジェクト: Byron/bsuite
//----------------------------------------------------------------------------
MStatus		BPT_InsertVtx::initialize()
//----------------------------------------------------------------------------
{
	
	
	MFnEnumAttribute	FnEnumAttr;
	MFnTypedAttribute	FnTypedAttr;
	MFnNumericAttribute	FnFloatAttr;
	MStatus				status;

	

	IVinMesh = FnTypedAttr.create("inMesh","in",MFnData::kMesh);
	FnTypedAttr.setStorable(true);
	//FnTypedAttr.setCached(false);
	FnTypedAttr.setInternal(true);
	

	IVoutMesh = FnTypedAttr.create("outMesh","out",MFnData::kMesh);
	FnTypedAttr.setStorable(true);
	FnTypedAttr.setWritable(false);



	IVcount = FnFloatAttr.create("count","c",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setInternal(true);
	FnFloatAttr.setKeyable(true);
	FnFloatAttr.setMin(1);
	FnFloatAttr.setSoftMax(15);
	
	

	IVselEdgeIDs = FnTypedAttr.create("edgeIDs","eID",MFnData::kIntArray);
	FnTypedAttr.setStorable(true);
	FnTypedAttr.setHidden(true);
	FnTypedAttr.setConnectable(false);


	
	IVselVertIDs = FnTypedAttr.create("vertIDs","vID",MFnData::kIntArray);
	FnTypedAttr.setStorable(true);
	FnTypedAttr.setHidden(true);
	FnTypedAttr.setConnectable(false);


	
	IVoptions = FnTypedAttr.create("options","op",MFnData::kIntArray);
	FnTypedAttr.setStorable(true);
	FnTypedAttr.setHidden(true);
	FnTypedAttr.setConnectable(false);


	IVslide = FnFloatAttr.create("slide","sl",MFnNumericData::kDouble);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setInternal(true);
//	FnFloatAttr.setMin(0.0);
//	FnFloatAttr.setMax(1.0);
	FnFloatAttr.setKeyable(true);

	IVnormal = FnFloatAttr.create("alongNormal","an",MFnNumericData::kDouble);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setDefault(0.0);
	FnFloatAttr.setKeyable(true);

	IVslideRelative = FnFloatAttr.create("slideRelative","sr",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setMin(0.0);
	FnFloatAttr.setMax(1.0);
	FnFloatAttr.setKeyable(true);
	

	IVnormalRelative = FnFloatAttr.create("normalRelative","nr",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setMin(0.0);
	FnFloatAttr.setMax(1.0);
	FnFloatAttr.setKeyable(true);


	IVwhichSide = FnFloatAttr.create("side","si",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setMin(0.0);
	FnFloatAttr.setMax(1.0);
	FnFloatAttr.setKeyable(true);

	IVSlideLimited = FnFloatAttr.create("slideLimited","sll",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setMin(0.0);
	FnFloatAttr.setMax(1.0);
	FnFloatAttr.setKeyable(false);


	IVspin = FnFloatAttr.create("spin","sp",MFnNumericData::kLong);
	FnFloatAttr.setStorable(true);
	FnFloatAttr.setMin(0.0);
	FnFloatAttr.setKeyable(true);
	FnFloatAttr.setInternal(true);



	// Add attributes

	status = addAttribute(IVslideRelative);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVnormalRelative);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVwhichSide);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVnormal);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVslide);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVSlideLimited);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVoptions);
	MCheckStatus(status, "AddAttrIVNode");
		
	status = addAttribute(IVspin);
	MCheckStatus(status, "AddAttrIVNode");
	
	status = addAttribute(IVcount);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVselEdgeIDs);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVselVertIDs);
	MCheckStatus(status, "AddAttrIVNode");



	status = addAttribute(IVoutMesh);
	MCheckStatus(status, "AddAttrIVNode");

	status = addAttribute(IVinMesh);
	MCheckStatus(status, "AddAttrIVNode");





	// Add attribute affects

	status = attributeAffects( IVspin, IVoutMesh );
	MCheckStatus(status, "AddAttrAffectsIVNode");

	status = attributeAffects( IVcount, IVoutMesh );
	MCheckStatus(status, "AddAttrAffectsIVNode");

	status = attributeAffects( IVinMesh, IVoutMesh );
	MCheckStatus(status, "AddAttrAffectsIVNode");

	status = attributeAffects( IVslide, IVoutMesh);
	MCheckStatus(status, "AddAttrAffectsIVNode");
		
	status = attributeAffects( IVslideRelative, IVoutMesh);
	MCheckStatus(status, "AddAttrAffectsIVNode");

	status = attributeAffects( IVnormalRelative, IVoutMesh);
	MCheckStatus(status, "AddAttrAffectsIVNode");

	status = attributeAffects( IVwhichSide, IVoutMesh);
	MCheckStatus(status, "AddAttrAffectsIVNode");
		
	status = attributeAffects( IVnormal, IVoutMesh);
	MCheckStatus(status, "AddAttrAffectsIVNode");



	// Zuletzt die SoftTransformationAttribute hinzufuegen
	// Per Macro - dirty, aber funktioniert - wie machen die ALIAS Typen das ??? Die leiten auch stuendig von einer BaseNode ab, und da gehen dann keine Attribute flueten
	// Oder werden unbrauchbar so wie bei mir, so dass im Endeffekt suemtliche Attribute ein eindeutiges statisches Attribut haben muessen

	STE_ADD_ATTRIBUTES(IV)


		return status;
}
コード例 #8
0
ファイル: mayaPolySmooth.cpp プロジェクト: AiYong/OpenSubdiv
// Create and Add Attributes
//
//  Description:
//      This method is called to create and initialize all of the attributes
//      and attribute dependencies for this node type.  This is only called
//      once when the node type is registered with Maya.
//
//  Return Values:
//      MS::kSuccess
//      MS::kFailure
//
MStatus
MayaPolySmooth::initialize() {

    MStatus stat;

    MFnCompoundAttribute  cAttr;
    MFnEnumAttribute      eAttr;
    MFnGenericAttribute   gAttr;
    MFnLightDataAttribute lAttr;
    MFnMatrixAttribute    mAttr;
    MFnMessageAttribute   msgAttr;
    MFnNumericAttribute   nAttr;
    MFnTypedAttribute     tAttr;
    MFnUnitAttribute      uAttr;

    // MAYA_NODE_BUILDER:BEG [ATTRIBUTE CREATION] ==========
    // a_inputPolymesh : This is a description for this attribute
    a_inputPolymesh = tAttr.create("inputPolymesh", "ip", MFnData::kMesh, MObject::kNullObj, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::inputPolymesh" );
    stat = tAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setReadable()" );
    stat = tAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setWritable()" );
    stat = tAttr.setHidden(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setHidden()" );
    stat = addAttribute( a_inputPolymesh );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_inputPolymesh)" );

    // a_output : This is a description for this attribute
    a_output = tAttr.create("output", "out", MFnData::kMesh, MObject::kNullObj, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::output" );
    stat = tAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::output.setReadable()" );
    stat = tAttr.setWritable(false);
    MCHECKERR( stat, "cannot MayaPolySmooth::output.setWritable()" );
    stat = tAttr.setHidden(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::output.setHidden()" );
    stat = addAttribute( a_output );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_output)" );

    // a_subdivisionLevels : The number of recursive quad subdivisions to perform on each face.
    a_subdivisionLevels = nAttr.create("subdivisionLevels", "sl", MFnNumericData::kInt, 0.0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::subdivisionLevels" );
    stat = nAttr.setDefault(2);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setDefault(2)" );
    stat = nAttr.setMin(0);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMin(0)" );
    stat = nAttr.setMax(10);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMax(10)" );
    stat = nAttr.setSoftMax(4);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setSoftMax(4)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setWritable()" );
    stat = addAttribute( a_subdivisionLevels );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_subdivisionLevels)" );

    // a_recommendedIsolation : The number of recursive quad subdivisions to perform on each face.
    a_recommendedIsolation = nAttr.create("recommendedIsolation", "ri", MFnNumericData::kInt, 0.0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::recommendedIsolation" );
    stat = nAttr.setDefault(2);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setDefault(0)" );
    stat = nAttr.setMin(0);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setMin(0)" );
    stat = nAttr.setMax(10);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setSoftMax(10)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setReadable()" );
    stat = nAttr.setWritable(false);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setWritable()" );
    stat = nAttr.setHidden(false);
    MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setHidden()" );
    stat = addAttribute( a_recommendedIsolation );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_recommendedIsolation)" );

    // a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul>
    a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::vertBoundaryMethod" );
    stat = eAttr.addField("Interpolate Edges", k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges, k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.addField("Interpolate Edges And Corners", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner);
    MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges And Corners, k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" );
    stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setWritable()" );
    stat = addAttribute( a_vertBoundaryMethod );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_vertBoundaryMethod)" );

    // a_fvarBoundaryMethod : Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). <ul> <li>Bi-linear (None): Renderman: InterpolateBoundaryNone</li> <li>Smooth, (Edge Only): Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, (Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> <li>Smooth, (ZBrush and Maya "Smooth Internal Only"): Renderman: InterpolateBoundaryAlwaysSharp</li> </ul>
    a_fvarBoundaryMethod = eAttr.create("fvarBoundaryMethod", "fvbm", 0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::fvarBoundaryMethod" );
    stat = eAttr.addField("Bi-linear (None)", k_BoundaryMethod_InterpolateBoundaryNone);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Bi-linear (None), k_BoundaryMethod_InterpolateBoundaryNone)" );
    stat = eAttr.addField("Smooth (Edge Only)", k_BoundaryMethod_InterpolateBoundaryEdgeOnly);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge Only), k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" );
    stat = eAttr.addField("Smooth (Edge and Corner)", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge and Corner), k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" );
    stat = eAttr.addField("Smooth (Always Sharp)", k_BoundaryMethod_InterpolateBoundaryAlwaysSharp);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Always Sharp), k_BoundaryMethod_InterpolateBoundaryAlwaysSharp)" );
    stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryNone);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryNone)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setWritable()" );
    stat = addAttribute( a_fvarBoundaryMethod );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_fvarBoundaryMethod)" );

    // a_fvarPropagateCorners :
    a_fvarPropagateCorners = nAttr.create("fvarPropagateCorners", "fvpc", MFnNumericData::kBoolean, 0.0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::fvarPropagateCorners" );
    stat = nAttr.setDefault(false);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setDefault(false)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setWritable()" );
    stat = addAttribute( a_fvarPropagateCorners );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_fvarPropagateCorners)" );

    // a_smoothTriangles : Apply a special subdivision rule be applied to all triangular faces that was empirically determined to make triangles subdivide more smoothly.
    a_smoothTriangles = nAttr.create("smoothTriangles", "stri", MFnNumericData::kBoolean, 0.0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::smoothTriangles" );
    stat = nAttr.setDefault(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setDefault(true)" );
    stat = nAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setReadable()" );
    stat = nAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setWritable()" );
    stat = addAttribute( a_smoothTriangles );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_smoothTriangles)" );

    // a_creaseMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Normal</li> <li>Chaikin: Improves the appearance of multiedge creases with varying weight</li> </ul>
    a_creaseMethod = eAttr.create("creaseMethod", "crm", 0, &stat);
    MCHECKERR( stat, "cannot create MayaPolySmooth::creaseMethod" );
    stat = eAttr.addField("Normal", k_creaseMethod_normal);
    MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.addField(Normal, k_creaseMethod_normal)" );
    stat = eAttr.addField("Chaikin", k_creaseMethod_chaikin);
    MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.addField(Chaikin, k_creaseMethod_chaikin)" );
    stat = eAttr.setDefault(0);
    MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setDefault(0)" );
    stat = eAttr.setReadable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setReadable()" );
    stat = eAttr.setWritable(true);
    MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setWritable()" );
    stat = addAttribute( a_creaseMethod );
    MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_creaseMethod)" );

    // MAYA_NODE_BUILDER:END [ATTRIBUTE CREATION] ==========


    // Set up a dependency between the input and the output.  This will cause
    // the output to be marked dirty when the input changes.  The output will
    // then be recomputed the next time the value of the output is requested.
    //
    // MAYA_NODE_BUILDER:BEG [ATTRIBUTE DEPENDS] ==========
    stat = attributeAffects( a_creaseMethod, a_output );
    MCHECKERR( stat, "cannot have attribute creaseMethod affect output" );
    stat = attributeAffects( a_inputPolymesh, a_output );
    MCHECKERR( stat, "cannot have attribute inputPolymesh affect output" );
    stat = attributeAffects( a_subdivisionLevels, a_output );
    MCHECKERR( stat, "cannot have attribute subdivisionLevels affect output" );
    stat = attributeAffects( a_smoothTriangles, a_output );
    MCHECKERR( stat, "cannot have attribute smoothTriangles affect output" );
    stat = attributeAffects( a_fvarPropagateCorners, a_output );
    MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect output" );
    stat = attributeAffects( a_vertBoundaryMethod, a_output );
    MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect output" );
    stat = attributeAffects( a_fvarBoundaryMethod, a_output );
    MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect output" );

    stat = attributeAffects( a_creaseMethod, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute creaseMethod affect .si output" );
    stat = attributeAffects( a_inputPolymesh, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute inputPolymesh affect .si output" );
    stat = attributeAffects( a_subdivisionLevels, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute subdivisionLevels affect .si output" );
    stat = attributeAffects( a_smoothTriangles, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute smoothTriangles affect .si output" );
    stat = attributeAffects( a_fvarPropagateCorners, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect .si output" );
    stat = attributeAffects( a_vertBoundaryMethod, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect .si output" );
    stat = attributeAffects( a_fvarBoundaryMethod, a_recommendedIsolation );
    MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect .si output" );
    // MAYA_NODE_BUILDER:END [ATTRIBUTE DEPENDS] ==========

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

    MFnNumericAttribute nAttr;
    MFnEnumAttribute eAttr;
    MFnTypedAttribute typedAttr;

    // Add ui type attribute
    aUIType = eAttr.create("uiType", "ut", uiDrawManager::kText);
    eAttr.addField("text", uiDrawManager::kText);
    eAttr.addField("line", uiDrawManager::kLine);
    eAttr.addField("point", uiDrawManager::kPoint);
    eAttr.addField("rect", uiDrawManager::kRect);    
    eAttr.addField("quad", uiDrawManager::kQuad);
    eAttr.addField("sphere", uiDrawManager::kSphere);
    eAttr.addField("circle", uiDrawManager::kCircle);    
    eAttr.addField("arc", uiDrawManager::kArc);    
    eAttr.addField("line list", uiDrawManager::kLineList);
    eAttr.addField("line strip", uiDrawManager::kLineStrip);
    eAttr.addField("point list", uiDrawManager::kPointList);
    eAttr.addField("icon", uiDrawManager::kIcon);
    eAttr.addField("cone", uiDrawManager::kCone);
    eAttr.addField("box", uiDrawManager::kBox);
    MPxNode::addAttribute(aUIType);

    // Add color attribute
    aPrimitiveColor = nAttr.create("primitiveColor", "pc", MFnNumericData::k3Float);
    nAttr.setDefault(1.0f, 0.0f, 0.0f);
    nAttr.setUsedAsColor(true);
    MPxNode::addAttribute(aPrimitiveColor);

    // Add transparency attribute
    aPrimitiveTransparency = nAttr.create("primitiveTransparency", "pt", MFnNumericData::kFloat, 0.0);
    nAttr.setSoftMin(0.0);
    nAttr.setSoftMax(1.0);    
    MPxNode::addAttribute(aPrimitiveTransparency);

    // add line width and line style attributes
    aLineWidth = nAttr.create("lineWidth", "lw", MFnNumericData::kFloat, 2.0);
    MPxNode::addAttribute(aLineWidth);

    aLineStyle = eAttr.create("lineStyle", "ls", MUIDrawManager::kSolid);
    eAttr.addField("solid", MUIDrawManager::kSolid);
    eAttr.addField("shortdotted", MUIDrawManager::kShortDotted);
    eAttr.addField("shortdashed", MUIDrawManager::kShortDashed);
    eAttr.addField("dashed", MUIDrawManager::kDashed);
    eAttr.addField("dotted", MUIDrawManager::kDotted);
    MPxNode::addAttribute(aLineStyle);

    // Add filled attribute
    aIsFilled = nAttr.create("isFilled", "if", MFnNumericData::kBoolean, 0);    
    MPxNode::addAttribute(aIsFilled);

    // Add shaded attribute
    aShaded = nAttr.create("shaded", "sd", MFnNumericData::kBoolean, 0);    
    MPxNode::addAttribute(aShaded);

    // Add radius attribute
    aRadius = nAttr.create("radius", "ra", MFnNumericData::kDouble, 1.0);
    MPxNode::addAttribute(aRadius);

    // add 2D attributes
    aDraw2D = nAttr.create("draw2D", "d2", MFnNumericData::kBoolean, 0);
    MPxNode::addAttribute(aDraw2D);

    aPosition = nAttr.create("position", "pos", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 0.001);
    MPxNode::addAttribute(aPosition);

    // Add text attributes.
    MFnStringData stringFn;
    MObject defaultText = stringFn.create("uiDrawManager-Text");
    aText = typedAttr.create("text", "t", MFnData::kString, defaultText);
    MPxNode::addAttribute(aText);    

    aTextFontSize = nAttr.create("textFontSize", "tfs", MFnNumericData::kInt, MUIDrawManager::kDefaultFontSize);
    nAttr.setMin(-1);
    nAttr.setMax(99);    
    MPxNode::addAttribute(aTextFontSize);

    unsigned int nFont = MUIDrawManager::getFontList(uiDrawManagerData::fFontList);
    if (nFont == 0)
    {
        perror("No font available!");
    }
    aFontFaceName = eAttr.create("fontFaceName", "ffn", 0);
    for (unsigned int i = 0; i < nFont; i++)
    {
        MString str = uiDrawManagerData::fFontList[i];
        eAttr.addField(str, (short)i);
    }
    MPxNode::addAttribute(aFontFaceName);

    aTextAlignment = eAttr.create("textAlignment", "ta", MUIDrawManager::kLeft);
    eAttr.addField("left", MUIDrawManager::kLeft);
    eAttr.addField("center", MUIDrawManager::kCenter);
    eAttr.addField("right", MUIDrawManager::kRight);
    MPxNode::addAttribute(aTextAlignment);    

    eTextIncline = eAttr.create("textIncline", "tic", MUIDrawManager::kInclineNormal);
    eAttr.addField("normal", MUIDrawManager::kInclineNormal);
    eAttr.addField("italic", MUIDrawManager::kInclineItalic);
    MPxNode::addAttribute(eTextIncline);    

    aTextWeight = eAttr.create("textWeight", "tw", MUIDrawManager::kWeightBold);
    eAttr.addField("light", MUIDrawManager::kWeightLight);
	eAttr.addField("normal", MUIDrawManager::kWeightNormal);
	eAttr.addField("demiBold", MUIDrawManager::kWeightDemiBold);
	eAttr.addField("bold", MUIDrawManager::kWeightBold);
	eAttr.addField("black", MUIDrawManager::kWeightBlack);
    MPxNode::addAttribute(aTextWeight);

    aTextStretch = nAttr.create("textStretch", "ts", MFnNumericData::kInt, MUIDrawManager::kStretchUnstretched);
    nAttr.setMin(50);
    nAttr.setMax(200);
    MPxNode::addAttribute(aTextStretch);

    aTextLine = eAttr.create("textLine", "tl", 0);
    eAttr.addField("none", 0);
    eAttr.addField("overline", MUIDrawManager::kLineOverline);
    eAttr.addField("underline", MUIDrawManager::kLineUnderline);
    eAttr.addField("strikeout", MUIDrawManager::kLineStrikeoutLine);
    MPxNode::addAttribute(aTextLine);    

    aTextBoxSize = nAttr.create("textBoxSize", "tbs", MFnNumericData::k2Int);
    nAttr.setDefault(0, 0);
    MPxNode::addAttribute(aTextBoxSize);

    aTextBoxColor = nAttr.create("textBoxColor", "tbc", MFnNumericData::k3Float);
    nAttr.setDefault(0.0f, 1.0f, 1.0f);
    nAttr.setUsedAsColor(true);
    MPxNode::addAttribute(aTextBoxColor);

    aTextBoxTransparency = nAttr.create("textBoxTransparency", "tbt", MFnNumericData::kFloat, 0.0);
    nAttr.setSoftMin(0.0);
    nAttr.setSoftMax(1.0);    
    MPxNode::addAttribute(aTextBoxTransparency);
    
    // add point attributes
    aPointSize = nAttr.create("pointSize", "ps", MFnNumericData::kFloat, 2.0);
    MPxNode::addAttribute(aPointSize);

    // add line attributes
    aLineStartPoint = nAttr.create("lineStartPoint", "lsp", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 0.0);
    MPxNode::addAttribute(aLineStartPoint);

    aLineEndPoint = nAttr.create("lineEndPoint", "lep", MFnNumericData::k3Double);
    nAttr.setDefault(1.0, 1.0, 1.0);
    MPxNode::addAttribute(aLineEndPoint);

    // add rect attributes
    aRectUp = nAttr.create("rectUp", "ru", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 1.0, 0.0);
    MPxNode::addAttribute(aRectUp);

    aRectNormal = nAttr.create("rectNormal", "rn", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 1.0);
    MPxNode::addAttribute(aRectNormal);

    aRectScale = nAttr.create("rectScale", "rs", MFnNumericData::k2Double);
    nAttr.setDefault(1.0, 1.0);
    MPxNode::addAttribute(aRectScale);

    // add quad attributes
    double defaultPosition[4][3] = 
    {
        {0.0, 0.0, 0.0},
        {1.0, 0.0, 0.0},
        {1.0, 1.0, 0.0},
        {0.0, 1.0, 0.0}
    };
    for (int i = 0; i < 4;  ++i)
    {
        MString fullName = "quadVertex";
        MString shortName = "qv";
        aQuadVertex[i] = nAttr.create(fullName + i, shortName + i, MFnNumericData::k3Double);
        nAttr.setDefault(defaultPosition[i][0], defaultPosition[i][1], defaultPosition[i][2]);
        MPxNode::addAttribute(aQuadVertex[i]);
    }

    // add circle attributes
    aCircleNormal = nAttr.create("circleNormal", "cn", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 1.0);
    MPxNode::addAttribute(aCircleNormal);

    // add arc attributes
    aArcStart = nAttr.create("arcStartVector", "asv", MFnNumericData::k3Double);
    nAttr.setDefault(1.0, 0.0, 0.0);
    MPxNode::addAttribute(aArcStart);

    aArcEnd = nAttr.create("arcEndVector", "aev", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 1.0, 0.0);
    MPxNode::addAttribute(aArcEnd);

    aArcNormal = nAttr.create("arcNormal", "an", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 1.0);
    MPxNode::addAttribute(aArcNormal);

	// icon attributes
	aIconName = eAttr.create("icon", "i", 0 );
	unsigned int iconCount = MUIDrawManager::getIconNames(uiDrawManagerData::fIconList);
	for (unsigned int i=0; i<iconCount; i++)
	{
		MString str = uiDrawManagerData::fIconList[i];
        eAttr.addField(str, (short)i);
	}
	MPxNode::addAttribute(aIconName);

	aIconScale = nAttr.create("iconScale", "cs", MFnNumericData::kFloat, 1.0);
    MPxNode::addAttribute(aIconScale);

	// cone attributes
	aConeDirection = nAttr.create("coneDirection", "cd", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 1.0);
    MPxNode::addAttribute(aConeDirection);

	aConeHeight = nAttr.create("coneHeight", "ch", MFnNumericData::kDouble);
    nAttr.setDefault(1.0);
    MPxNode::addAttribute(aConeHeight);

	// box attributes
	aBoxUp = nAttr.create("boxUp", "bu", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 0.0, 1.0);
    MPxNode::addAttribute(aBoxUp);

	aBoxRight = nAttr.create("boxRight", "br", MFnNumericData::k3Double);
    nAttr.setDefault(0.0, 1.0, 0.0);
    MPxNode::addAttribute(aBoxRight);

	aBoxScale = nAttr.create("boxScale", "bs", MFnNumericData::k3Double);
    nAttr.setDefault(1.0, 1.0, 1.0);
    MPxNode::addAttribute(aBoxScale);

	return MS::kSuccess;
}
コード例 #10
0
MStatus
OpenSubdivShader::initialize() 
{
    MFnTypedAttribute typedAttr;
    MFnNumericAttribute numAttr;
    MFnEnumAttribute enumAttr;

    // Subdivision level
    aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setSoftMax(5);
    numAttr.setMax(10);
    addAttribute(aLevel);

    // GPU tesselation factor
    aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2);
    numAttr.setInternal(true);
    numAttr.setMin(1);
    numAttr.setMax(10);
    addAttribute(aTessFactor);

    // Subdivision scheme
    aScheme = enumAttr.create("scheme", "sc", OsdMeshData::kCatmark);
    enumAttr.setInternal(true);
    enumAttr.addField("Catmull-Clark",  OsdMeshData::kCatmark);
    enumAttr.addField("Loop",           OsdMeshData::kLoop);
    enumAttr.addField("Bilinear",       OsdMeshData::kBilinear);
    addAttribute(aScheme);

    // Computation kernel
    aKernel = enumAttr.create("kernel", "kn", OsdMeshData::kCPU);
    enumAttr.setInternal(true);
    enumAttr.addField("CPU",    OsdMeshData::kCPU);
#ifdef OPENSUBDIV_HAS_OPENMP
    enumAttr.addField("OpenMP", OsdMeshData::kOPENMP);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
    enumAttr.addField("CL",     OsdMeshData::kCL);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
    enumAttr.addField("CUDA",   OsdMeshData::kCUDA);
#endif
    addAttribute(aKernel);

    // Boundary interpolation flag
    aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib", 
                    OsdMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("None",            OsdMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("Edge Only",       OsdMeshData::kInterpolateBoundaryEdgeOnly);
    enumAttr.addField("Edge and Corner", OsdMeshData::kInterpolateBoundaryEdgeAndCorner);
    enumAttr.addField("Always Sharp",    OsdMeshData::kInterpolateBoundaryAlwaysSharp);
    enumAttr.setInternal(true);
    addAttribute(aInterpolateBoundary);

    // Feature-adaptive toggle
    aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true);
    numAttr.setInternal(true);
    addAttribute(aAdaptive);

    // Wireframe display toggle
    aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false);
    addAttribute(aWireframe);

    // Material attributes 
    aDiffuse = numAttr.createColor("diffuse",   "d");
    numAttr.setDefault(0.6f, 0.6f, 0.7f);
    addAttribute(aDiffuse);

    aAmbient = numAttr.createColor("ambient",   "a");
    numAttr.setDefault(0.1f, 0.1f, 0.1f);
    addAttribute(aAmbient);

    aSpecular = numAttr.createColor("specular", "s");
    numAttr.setDefault(0.3f, 0.3f, 0.3f);
    addAttribute(aSpecular);

    aShininess = numAttr.create("shininess", "shin", MFnNumericData::kFloat, 50.0f);
    numAttr.setMin(0);
    numAttr.setSoftMax(128.0f);
    addAttribute(aShininess);

    // Texture attributes
    aDiffuseMapFile = typedAttr.create("diffuseMap", "difmap", MFnData::kString);
    typedAttr.setInternal(true);
    /* don't let maya hold on to string when fileNode is disconnected */
    typedAttr.setDisconnectBehavior(MFnAttribute::kReset);
    addAttribute(aDiffuseMapFile);

    // UV set (defaults to current UV set)
    aUVSet = typedAttr.create("uvSet", "uvs", MFnData::kString);
    typedAttr.setInternal(true);
    addAttribute(aUVSet);

    // Boundary interpolation flag for face-varying data (UVs)
    aInterpolateUVBoundary = enumAttr.create("interpolateUVBoundary", "iuvb", 
                    OsdMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("None",            OsdMeshData::kInterpolateBoundaryNone);
    enumAttr.addField("Edge Only",       OsdMeshData::kInterpolateBoundaryEdgeOnly);
    enumAttr.addField("Edge and Corner", OsdMeshData::kInterpolateBoundaryEdgeAndCorner);
    enumAttr.addField("Always Sharp",    OsdMeshData::kInterpolateBoundaryAlwaysSharp);
    enumAttr.setInternal(true);
    addAttribute(aInterpolateUVBoundary);

    // Optional shader source filename
    aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString);
    typedAttr.setInternal(true);
    addAttribute(aShaderSource);

    return MS::kSuccess;
}
コード例 #11
0
MStatus proWater::initialize()
{
	// local attribute initialization
    //time parameter
    MFnNumericAttribute nAttr;
    time = nAttr.create("time", "t", MFnNumericData::kDouble);
    nAttr.setDefault(0.0);
    nAttr.setKeyable(true);
    nAttr.setSoftMin(0.0);
    nAttr.setSoftMax(1000);
    nAttr.setMin(0.0);
    nAttr.setMax(1000);
    addAttribute(time);
    attributeAffects(proWater::time, proWater::outputGeom);
    //
    
    //direction parameter
    MFnNumericAttribute dirAttr;
    dir = dirAttr.create("direction", "dirDeg", MFnNumericData::kDouble);
    dirAttr.setDefault(45);
    dirAttr.setKeyable(true);
    dirAttr.setSoftMin(0.0);
    dirAttr.setSoftMax(360);
    dirAttr.setMin(0.0);
    dirAttr.setMax(360);
    addAttribute(dir);
    attributeAffects(proWater::dir, proWater::outputGeom);
    //
    
    //bigAmp1 parameter
    MFnNumericAttribute bigAttr;
    bigFreq = bigAttr.create("largeWaveAmplitude", "bigAmp", MFnNumericData::kDouble);
    bigAttr.setDefault(3);
    bigAttr.setKeyable(true);
    bigAttr.setSoftMin(0.0);
    bigAttr.setSoftMax(100);
    bigAttr.setMin(0.0);
    bigAttr.setMax(100);
    addAttribute(bigFreq);
    attributeAffects(proWater::bigFreq, proWater::outputGeom);
    //
    
    //amplitude1 parameter
    MFnNumericAttribute ampAttr1;
    amplitude1 = ampAttr1.create("firstOctaveAmplitude", "amp1", MFnNumericData::kDouble);
    ampAttr1.setDefault(0.5);
    ampAttr1.setKeyable(true);
    ampAttr1.setSoftMin(0.0);
    ampAttr1.setSoftMax(100);
    ampAttr1.setMin(0.0);
    ampAttr1.setMax(100);
    addAttribute(amplitude1);
    attributeAffects(proWater::amplitude1, proWater::outputGeom);
    //
    
    //frequency1 parameter
    MFnNumericAttribute freqAttr1;
    frequency1 = freqAttr1.create("firstFrequency", "freq1", MFnNumericData::kDouble);
    freqAttr1.setDefault(0.5);
    freqAttr1.setKeyable(true);
    freqAttr1.setSoftMin(0.0);
    freqAttr1.setSoftMax(100);
    freqAttr1.setMin(0.0);
    freqAttr1.setMax(100);
    addAttribute(frequency1);
    attributeAffects(proWater::frequency1, proWater::outputGeom);
    //
    
    //amplitude2 parameter
    MFnNumericAttribute ampAttr2;
    amplitude2 = ampAttr2.create("secondOctaveAmplitude", "amp2", MFnNumericData::kDouble);
    ampAttr2.setDefault(1.3);
    ampAttr2.setKeyable(true);
    ampAttr2.setSoftMin(0.0);
    ampAttr2.setSoftMax(100);
    ampAttr2.setMin(0.0);
    ampAttr2.setMax(100);
    addAttribute(amplitude2);
    attributeAffects(proWater::amplitude2, proWater::outputGeom);
    //
    
    //frequency2 parameter
    MFnNumericAttribute freqAttr2;
    frequency2 = freqAttr2.create("secondFrequency", "freq2", MFnNumericData::kDouble);
    freqAttr2.setDefault(0.7);
    freqAttr2.setKeyable(true);
    freqAttr2.setSoftMin(0.0);
    freqAttr2.setSoftMax(100);
    freqAttr2.setMin(0.0);
    freqAttr2.setMax(100);
    addAttribute(frequency2);
    attributeAffects(proWater::frequency2, proWater::outputGeom);
    //
    
    
    
	MFnMatrixAttribute  mAttr;
	offsetMatrix=mAttr.create( "locateMatrix", "lm");
	    mAttr.setStorable(false);
		mAttr.setConnectable(true);

	//  deformation attributes
	addAttribute( offsetMatrix);

	attributeAffects( proWater::offsetMatrix, proWater::outputGeom );

	return MStatus::kSuccess;
}
コード例 #12
0
ファイル: ropeGenerator.cpp プロジェクト: skarone/PipeL
MStatus ropeGenerator::initialize()
{
	MStatus stat;
	MFnTypedAttribute tAttr;
	MFnNumericAttribute nAttr;
	MRampAttribute rAttr;

	inCurve = tAttr.create( "inCurve", "inCurve", MFnData::kNurbsCurve );
	tAttr.setHidden( true);

	divisions = nAttr.create( "divisions", "divisions", MFnNumericData::kInt, 15 );
	nAttr.setMin( 2 );
	nAttr.setSoftMax( 100 );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	createRope = nAttr.create( "createRope", "createRope", MFnNumericData::kBoolean, false );
	nAttr.setWritable( true );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );

	ropesCount = nAttr.create( "ropesCount", "ropesCount", MFnNumericData::kInt, 5 );
	nAttr.setMin( 3 );
	nAttr.setSoftMax( 10 );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	pointsPerRope = nAttr.create( "pointsPerRope", "pointsPerRope", MFnNumericData::kInt, 6 );
	nAttr.setMin( 3 );
	nAttr.setSoftMax( 15 );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	ropesStrength = nAttr.create( "ropesStrength", "ropesStrength", MFnNumericData::kFloat, 1.0f );
	nAttr.setMin( 0.0 );
	nAttr.setMax( 1.0 );
	nAttr.setWritable( true );
	nAttr.setStorable( true );
	nAttr.setKeyable( true );

	pointsCount = nAttr.create( "pointsCount", "pointsCount", MFnNumericData::kInt, 5 );
	nAttr.setMin(3);
	nAttr.setSoftMax( 20 );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	radius = nAttr.create( "radius", "radius", MFnNumericData::kFloat, 1.0f );
	nAttr.setMin( 0.0 );
	nAttr.setSoftMax( 30.0 );
	nAttr.setKeyable( true );
	nAttr.setWritable( true );
	nAttr.setStorable( true );

	taperRamp = rAttr.createCurveRamp( "tapper", "tapper" );

	twist = nAttr.create( "twist", "twist", MFnNumericData::kFloat, 0.0f );
	nAttr.setSoftMin( -3600.0 );
	nAttr.setSoftMax( 3600.0 );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	twistRamp = rAttr.createCurveRamp( "twistRamp", "twistRamp" );

	uvWidth = nAttr.create( "uvWidth", "uvWidth", MFnNumericData::kFloat, 1.0f );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	uvHeight = nAttr.create( "uvHeight", "uvHeight", MFnNumericData::kFloat, 1.0f );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	uvCapSize = nAttr.create( "uvCapSize", "uvCapSize", MFnNumericData::kFloat, 1.0f );
	nAttr.setWritable( true );
	nAttr.setKeyable( true );
	nAttr.setStorable( true );

	outMesh = tAttr.create( "outMesh", "outMesh", MFnData::kMesh );
	tAttr.setWritable( false );
	tAttr.setStorable( false );

	stat = addAttribute( inCurve );
	if (!stat) { stat.perror("addAttribute inCurve"); return stat;}
	stat = addAttribute( divisions );
	if (!stat) { stat.perror("addAttribute divisions"); return stat;}
	stat = addAttribute( createRope );
	if (!stat) { stat.perror("addAttribute createRope"); return stat;}
	stat = addAttribute( ropesCount );
	if (!stat) { stat.perror("addAttribute ropesCount"); return stat;}
	stat = addAttribute( pointsPerRope );
	if (!stat) { stat.perror("addAttribute pointsPerRope"); return stat;}
	stat = addAttribute( ropesStrength );
	if (!stat) { stat.perror("addAttribute ropesStrength"); return stat;}
	stat = addAttribute( pointsCount );
	if (!stat) { stat.perror("addAttribute pointsCount"); return stat;}
	stat = addAttribute( radius );
	if (!stat) { stat.perror("addAttribute radius"); return stat;}
	stat = addAttribute( taperRamp );
	if (!stat) { stat.perror("addAttribute taperRamp"); return stat;}
	stat = addAttribute( twist );
	if (!stat) { stat.perror("addAttribute twist"); return stat;}
	stat = addAttribute( twistRamp );
	if (!stat) { stat.perror("addAttribute twistRamp"); return stat;}
	stat = addAttribute( uvWidth );
	if (!stat) { stat.perror("addAttribute uvWidth"); return stat;}
	stat = addAttribute( uvHeight );
	if (!stat) { stat.perror("addAttribute uvHeight"); return stat;}
	stat = addAttribute( uvCapSize );
	if (!stat) { stat.perror("addAttribute uvCapSize"); return stat;}
	stat = addAttribute( outMesh );
	if (!stat) { stat.perror("addAttribute outMesh"); return stat;}


	stat = attributeAffects( inCurve, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( divisions, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( createRope, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( ropesCount, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( pointsPerRope, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( ropesStrength, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( pointsCount, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( radius, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( taperRamp, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( twist, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( twistRamp, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( uvWidth, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( uvHeight, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( uvCapSize, outMesh );
	if (!stat) { stat.perror("attributeAffects"); return stat;}

	return MS::kSuccess;
}
コード例 #13
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;
}
コード例 #14
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;
	}