コード例 #1
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;
}
コード例 #2
0
MStatus collisionShapeNode::initialize()
{
    MStatus status;
    MFnMessageAttribute fnMsgAttr;
    MFnNumericAttribute fnNumericAttr;
    MFnEnumAttribute fnEnumAttr;

    ia_type = fnEnumAttr.create("type", "tp", 5, &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.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.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;
}
コード例 #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
ファイル: puttyNode.cpp プロジェクト: Leopardob/puttynodes
MStatus puttyNode::initialize()
{
	MStatus status;
	MFnNumericAttribute		nAttr;
  	MFnEnumAttribute		eAttr;
    MFnTypedAttribute       tAttr;
    MFnMatrixAttribute       mAttr;

    // the script


    aScript = tAttr.create( "script", "scr", MFnData::kString);
    tAttr.setStorable(true);
    tAttr.setKeyable(false);
	SYS_ERROR_CHECK( addAttribute( aScript ), "adding aScript" );  

	aCmdBaseName = tAttr.create( "cmdBaseName", "cbn", MFnData::kString);
    tAttr.setStorable(true);
    tAttr.setKeyable(false);
    tAttr.setHidden(true);    
	SYS_ERROR_CHECK( addAttribute( aCmdBaseName ), "adding aCmdBaseName" );  

    // refresh
    
    aSource = nAttr.create( "source", "src", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aSource ), "adding aSource" ); 
    
	// it is important that script sourced is initialised false and not storable
    // so this way the function gets sourced on maya startup    
    aScriptSourced = nAttr.create( "scriptSourced", "ssrc", MFnNumericData::kBoolean, 0 );
    nAttr.setStorable(false);
    nAttr.setHidden(true);        
    SYS_ERROR_CHECK( addAttribute( aScriptSourced ), "adding aScriptSourced" ); 


    aNodeReady = nAttr.create( "nodeReady", "nr", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aNodeReady ), "adding aNodeReady" ); 

    aDynDirty = nAttr.create( "dynDirty", "dd", MFnNumericData::kBoolean, 0 );
    nAttr.setHidden(true);    
    SYS_ERROR_CHECK( addAttribute( aDynDirty ), "adding aDynDirty" ); 

  
    // space
   	aDefSpace = eAttr.create("deformerSpace", "dsp", MSD_SPACE_OBJECT, &status);
	eAttr.addField("object (default)", MSD_SPACE_OBJECT);
	eAttr.addField("world (automatic conversion)", MSD_SPACE_WORLD);
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefSpace ), "adding aDefSpace" );

    // envelope
   	aDefEnvelope = eAttr.create("deformerEnvelope", "de", MSD_ENVELOPE_AUTO, &status);
	eAttr.addField("auto", MSD_ENVELOPE_AUTO);
    eAttr.addField("user", MSD_ENVELOPE_USER);    
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefEnvelope ), "adding aDefEnvelope" );

    // weights
   	aDefWeights = eAttr.create("deformerWeights", "dw", MSD_WEIGHTS_AUTO, &status);
	eAttr.addField("auto", MSD_WEIGHTS_AUTO);
    eAttr.addField("user", MSD_WEIGHTS_USER);    
   	eAttr.setKeyable(false);
	eAttr.setStorable(true);
	SYS_ERROR_CHECK( addAttribute( aDefWeights ), "adding aDefWeights" );

    /////////////////////////////////////////////////////////////////////////////    
    // current values
    aCurrPosition = tAttr.create( "currentPosition", "cpos", MFnData::kVectorArray);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrPosition ), "adding aCurrPos" );          

    aCurrWeight = tAttr.create( "currentWeight", "cwgh", MFnData::kDoubleArray);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrWeight ), "adding aCurrWeight" );          
    
    aCurrMultiIndex = nAttr.create("currentMultiIndex","cmi",MFnNumericData::kInt);
    nAttr.setStorable(false);
    nAttr.setKeyable(false);
    nAttr.setConnectable(false);
    nAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrMultiIndex ), "adding aCurrMultiIndex" );          

    aCurrWorldMatrix = mAttr.create("currentWorldMatrix","cwm"); 
    mAttr.setStorable(false);
    mAttr.setKeyable(false);
    mAttr.setConnectable(false);
    mAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrWorldMatrix ), "adding aCurrObjectName" );          

/*
    aCurrGeometryName= tAttr.create( "currentGeometryName", "con", MFnData::kString);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrGeometryName ), "adding aCurrObjectName" );          
*/       
    aCurrGeometryType= tAttr.create( "currentGeometryType", "cot", MFnData::kString);
    tAttr.setStorable(false);
    tAttr.setKeyable(false);
    tAttr.setConnectable(false);
    tAttr.setWritable(false);
	SYS_ERROR_CHECK( addAttribute( aCurrGeometryType ), "adding aCurrGeometryType" );


    /////////////////////////////////////////////////////////////////////////////    
    // affects
    attributeAffects( aScript ,aNodeReady);          
    attributeAffects( aSource, aNodeReady  );
    attributeAffects( aScriptSourced, aNodeReady  );
    
	attributeAffects( aScript,aScriptSourced);
	attributeAffects( aSource,aScriptSourced);
	
    attributeAffects( aScriptSourced, outputGeom  );    
	attributeAffects( aDynDirty,outputGeom ); 
	attributeAffects( aNodeReady,outputGeom ); 
    attributeAffects( aScript ,outputGeom); 
	attributeAffects(  aCmdBaseName  ,outputGeom);   
    attributeAffects( aSource ,outputGeom );        
    attributeAffects( aDefSpace, outputGeom  );
    attributeAffects( aDefWeights,outputGeom);
    attributeAffects( aDefEnvelope,outputGeom ); 
	return MS::kSuccess;
}
コード例 #5
0
ファイル: snapMeshDeformer.cpp プロジェクト: dams31/maya
MStatus snapDeformer::initialize() {
	MStatus stat;

    MFnNumericAttribute FnNumeric;
    MFnNumericAttribute FnNumericA;
    MFnTypedAttribute FnTyped;
    MFnEnumAttribute FnEnum;

	//weight
	weight = FnNumeric.create("weight", "we", MFnNumericData::kFloat);
	FnNumeric.setKeyable(true);
	FnNumeric.setStorable(true);
	FnNumeric.setReadable(true);
	FnNumeric.setWritable(true);
    FnNumeric.setDefault( 1.0 );
	addAttribute( weight );


    ///space target
	space = FnEnum.create("space", "sp", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(space);

    ///space source
	spaceSource = FnEnum.create("spaceSource", "sps", 0);
	FnEnum.addField("world",0);
	FnEnum.addField("object",1);
	FnEnum.setStorable(true);
	FnEnum.setKeyable(true);
	addAttribute(spaceSource);


	//pointlist
	pointList = FnNumericA.create("pointList", "pl", MFnNumericData::kInt);
	FnNumericA.setArray( true );
	FnNumericA.setKeyable(false);
	FnNumericA.setStorable(true);
	FnNumericA.setReadable(true);
	FnNumericA.setWritable(true);
    FnNumericA.setIndexMatters(true);
	addAttribute( pointList );


	//snapMesh
	snapMesh = FnTyped.create("snapMesh", "sm", MFnData::kMesh);
	FnTyped.setArray( false );
	FnTyped.setReadable(true);
	FnTyped.setWritable(true);
	addAttribute( snapMesh );



	attributeAffects(snapMesh, outputGeom);
	attributeAffects(pointList, outputGeom);
	attributeAffects(space, outputGeom);
    attributeAffects(spaceSource, outputGeom);
	attributeAffects(weight, outputGeom);

    return stat;
}
コード例 #6
0
MStatus transCircle::initialize()
{
	MFnNumericAttribute nAttr;
	MStatus				stat;

	input = nAttr.create( "input", "in", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateX = nAttr.create( "inputTranslateX", "itX", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateY = nAttr.create( "inputTranslateY", "itY", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslateZ = nAttr.create( "inputTranslateZ", "itZ", MFnNumericData::kDouble, 0.0 );
	nAttr.setStorable(true);

	inputTranslate = nAttr.create( "inputTranslate", "it", 
									inputTranslateX,
									inputTranslateY,
									inputTranslateZ );
	nAttr.setStorable(true);
	nAttr.setDefault(0.0,0.0,0.0);

	outputTranslateX = nAttr.create( "outputTranslateX", "otX", MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslateY = nAttr.create( "outputTranslateY", "otY", MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslateZ = nAttr.create( "outputTranslateZ", "otZ", MFnNumericData::kDouble, 0.0 );
	nAttr.setWritable(false);
	nAttr.setStorable(true);

	outputTranslate = nAttr.create( "outputTranslate", "ot", 
									outputTranslateX,
									outputTranslateY,
									outputTranslateZ );
	nAttr.setWritable(false);
	nAttr.setStorable(true);
	nAttr.setDefault(0.0,0.0,0.0);

	scale = nAttr.create( "scale", "sc", MFnNumericData::kDouble, 10.0 );
	nAttr.setStorable(true);

	frames = nAttr.create( "frames", "fr", MFnNumericData::kDouble, 48.0 );
	nAttr.setStorable(true);

	addAttribute( inputTranslate );
	addAttribute( input );
	addAttribute( scale );
	addAttribute( frames );
	addAttribute( outputTranslate );

	attributeAffects( inputTranslateX, outputTranslateX );
	attributeAffects( inputTranslateY, outputTranslateY );
	attributeAffects( inputTranslateZ, outputTranslateZ );
	attributeAffects( inputTranslate, outputTranslateX );
	attributeAffects( inputTranslate, outputTranslateY );
	attributeAffects( inputTranslate, outputTranslateZ );
	attributeAffects( inputTranslate, outputTranslate );
	attributeAffects( input, outputTranslateX );
	attributeAffects( input, outputTranslateY );
	attributeAffects( scale, outputTranslateX );
	attributeAffects( scale, outputTranslateY );
	attributeAffects( frames, outputTranslateX );
	attributeAffects( frames, outputTranslateY );

	return MS::kSuccess;
}
コード例 #7
0
ファイル: MG_poseReader.cpp プロジェクト: bungnoid/MG_Tools
MStatus MG_poseReader::initialize()
	{ 
		//Declaring all the needed attribute function sets
		MFnEnumAttribute enumFn;
		MFnMatrixAttribute matrixFn;
		MFnNumericAttribute numFn;
		MFnCompoundAttribute compA;


		//Aim axis input attribute

		aimAxis = enumFn.create("aimAxis","aa",0);
		enumFn.addField("x",0);
		enumFn.addField("y",1);
		enumFn.addField("z",2);
		enumFn.setKeyable(true);
		enumFn.setStorable(true);
		addAttribute(aimAxis); 

		//Pose matrix input attribute

		
		poseMatrix =matrixFn.create("poseMatrix","psm");
		matrixFn.setKeyable(true);
		matrixFn.setStorable(true);
		addAttribute(poseMatrix); 

		//Reader matrix input attribute

		readerMatrix =matrixFn.create("readerMatrix","rm");
		matrixFn.setKeyable(true);
		matrixFn.setStorable(true);
		addAttribute(readerMatrix); 

		//Aim axis input attribute

		//Arrow size
		size =numFn.create("size","siz",MFnNumericData::kDouble,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(size);

		readerOnOff =numFn.create("readerOnOff","rof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(readerOnOff);
		

		axisOnOff =numFn.create("axisOnOff","aof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(axisOnOff);


		poseOnOff =numFn.create("poseOnOff","pof",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(poseOnOff);



		xPositive = numFn.create("xPositive","xp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(xPositive);

		xNegative = numFn.create("xNegative","xn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(xNegative);

		yPositive = numFn.create("yPositive","yp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(yPositive);

		yNegative = numFn.create("yNegative","yn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(yNegative);

		zPositive = numFn.create("zPositive","zp",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(zPositive);

		zNegative = numFn.create("zNegative","zn",MFnNumericData::kDouble,0);
		numFn.setStorable(false);
		numFn.setWritable(false);
		addAttribute(zNegative);



		attributeAffects (aimAxis,xPositive);
		attributeAffects (poseMatrix,xPositive);
		attributeAffects (readerMatrix,xPositive);
		attributeAffects (size,xPositive);

		attributeAffects (aimAxis,xNegative);
		attributeAffects (poseMatrix,xNegative);
		attributeAffects (readerMatrix,xNegative);
		attributeAffects (size,xNegative);

		attributeAffects (aimAxis,yPositive);
		attributeAffects (poseMatrix,yPositive);
		attributeAffects (readerMatrix,yPositive);
		attributeAffects (size,yPositive);

		attributeAffects (aimAxis,yNegative);
		attributeAffects (poseMatrix,yNegative);
		attributeAffects (readerMatrix,yNegative);
		attributeAffects (size,yNegative);


		attributeAffects (aimAxis,zPositive);
		attributeAffects (poseMatrix,zPositive);
		attributeAffects (readerMatrix,zPositive);
		attributeAffects (size,zPositive);

		attributeAffects (aimAxis,zNegative);
		attributeAffects (poseMatrix,zNegative);
		attributeAffects (readerMatrix,zNegative);
		attributeAffects (size,zNegative);

		return MS::kSuccess;
	

}
コード例 #8
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;
}
コード例 #9
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;
}
コード例 #10
0
MStatus glassNode::initialize()
{
	MFnNumericAttribute numAttr;

	mirrorTexLayer=numAttr.createColor("MirrorTextureLayer","mtl");
	MAKE_INPUT(numAttr);
	filterTexLayer=numAttr.createColor("FilterTextureLayer","ftl");
	MAKE_INPUT(numAttr);
	bumpTexLayer=numAttr.createColor("BumpTextureLayer","btl");
	MAKE_INPUT(numAttr);

	absorbColor=numAttr.createColor("AbsorbColor","gabco");
	MAKE_INPUT(numAttr);

	absorbDistance=numAttr.create("AbsorbDistance","gabdi",MFnNumericData::kFloat,1.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(0.0f);
	numAttr.setMax(100.0f);

	filterColor=numAttr.createColor("FilterColor","gfico");
	MAKE_INPUT(numAttr);

	mirrorColor=numAttr.createColor("MirrorColor","gmico");
	MAKE_INPUT(numAttr);

	IOR=numAttr.create("IOR","gior",MFnNumericData::kFloat,1.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(0.0f);
	numAttr.setMax(30.0f);

	transmitFilter=numAttr.create("TransmitFilter","gtrfi",MFnNumericData::kDouble,1.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(0.0);
	numAttr.setMax(1.0);

	dispersionPower=numAttr.create("DispersionPower","gdipo",MFnNumericData::kFloat,0.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(0.0f);
	numAttr.setMax(10000.0f);

	fakeShadows=numAttr.create("FakeShadows","gfash",MFnNumericData::kBoolean,false);
	MAKE_INPUT(numAttr);
	

	outGlass=numAttr.createColor("outColor","oc");
	numAttr.setHidden(true);
	MAKE_OUTPUT(numAttr);

	
	
	addAttribute(absorbColor);
	addAttribute(absorbDistance);	
	addAttribute( filterColor );
	addAttribute(filterTexLayer);
	addAttribute(mirrorColor);
	addAttribute(mirrorTexLayer);
	addAttribute(bumpTexLayer);
	addAttribute(IOR);
	addAttribute(transmitFilter);
	addAttribute(dispersionPower);
	addAttribute(fakeShadows);
	addAttribute(outGlass);

	attributeAffects(mirrorTexLayer,outGlass);
	attributeAffects(filterTexLayer,outGlass);
	attributeAffects(bumpTexLayer,outGlass);
	attributeAffects(absorbColor,outGlass);
	attributeAffects(absorbDistance,outGlass);
	attributeAffects(filterColor,outGlass);
	attributeAffects(mirrorColor,outGlass);
	attributeAffects(IOR,outGlass);
	attributeAffects(transmitFilter,outGlass);
	attributeAffects(dispersionPower,outGlass);
	attributeAffects(fakeShadows,outGlass);



	return MStatus::kSuccess;

}
コード例 #11
0
MStatus liqSurfaceNode::initialize()
{
  MFnTypedAttribute   tAttr;
  MFnStringData       tDefault;
  MFnNumericAttribute nAttr;
  MFnEnumAttribute    eAttr;
  MFnMessageAttribute mAttr;
  MFnLightDataAttribute lAttr;
  MStatus status;

  // Create input attributes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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


  // create attributes for maya renderer

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

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

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

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

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

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

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


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

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

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

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

  return MS::kSuccess;
}
コード例 #12
0
MStatus imageTexNode::initialize()
{
	MStatus stat;
	MFnNumericAttribute numAttr;
	MFnEnumAttribute enumAttr;
	MFnTypedAttribute tAttr;

	imageFile=tAttr.create("ImageFile","if",MFnData::kString);
	MAKE_INPUT(tAttr);

	imageRepeatX=numAttr.create("RepeatX","rx",MFnNumericData::kInt,1);
	MAKE_INPUT(numAttr);
	numAttr.setMin(1);
	numAttr.setMax(512);

	imagerepeatY=numAttr.create("RepeatY","ry",MFnNumericData::kInt,1);
	MAKE_INPUT(numAttr);
	numAttr.setMin(1);
	numAttr.setMax(512);

	imageUseAlpha=numAttr.create("UseAlpha","ua",MFnNumericData::kBoolean,0);
	MAKE_INPUT(numAttr);

	imageCalcAlpha=numAttr.create("CalculateAlpha","ca",MFnNumericData::kBoolean,0);
	MAKE_INPUT(numAttr);

	imageNormalMap=numAttr.create("NormalMap","nm",MFnNumericData::kBoolean,0);
	MAKE_INPUT(numAttr);

	imageMinX=numAttr.create("MinX","minx",MFnNumericData::kFloat,0.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	imageMinY=numAttr.create("MinY","miny",MFnNumericData::kFloat,0.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	imageMaxX=numAttr.create("MaxX","maxx",MFnNumericData::kFloat,1.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	imageMaxY=numAttr.create("MaxY","maxy",MFnNumericData::kFloat,1.0);
	MAKE_INPUT(numAttr);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	mappingMethod=enumAttr.create("MappingMethod","mame",0);
	enumAttr.addField("uv",0);
	enumAttr.addField("orco",1);
	enumAttr.addField("global",2);
	enumAttr.addField("window",3);
	MAKE_INPUT(enumAttr);

	texCo=enumAttr.create("TextureCoordinate","texco",0);
	enumAttr.addField("plain",0);
	enumAttr.addField("cube",1);
	enumAttr.addField("tube",2);
	enumAttr.addField("sphere",3);
	MAKE_INPUT(enumAttr);

	//*******************************layer texture attribute*********************************//
	layerMix=enumAttr.create("MixMethod","mm1",0);
	enumAttr.addField("mix",0);
	enumAttr.addField("add",1);
	enumAttr.addField("multiply",2);
	enumAttr.addField("subtract",3);
	enumAttr.addField("screen",4);
	enumAttr.addField("divide",5);
	enumAttr.addField("difference",6);
	enumAttr.addField("darken",7);
	enumAttr.addField("lighten",8);
	MAKE_INPUT(enumAttr);

	textureColor=numAttr.createColor("TextureColor","teco");
	numAttr.setDefault(1.0,0.0,1.0);
	MAKE_INPUT(numAttr);

	texColorFact=numAttr.create("TextureColorWeight","tcw",MFnNumericData::kFloat,1.0);
	numAttr.setMin(0.0);
	numAttr.setMax(1.0);
	MAKE_INPUT(numAttr);

	defVal=numAttr.create("DefValue","dev",MFnNumericData::kFloat,1.0);
	numAttr.setMin(0.0);
	numAttr.setMax(1.0);
	MAKE_INPUT(numAttr);

	valFact=numAttr.create("ValueWeight","vaw",MFnNumericData::kFloat,1.0);
	numAttr.setMin(0.0);
	numAttr.setMax(1.0);
	MAKE_INPUT(numAttr);

	doColor=numAttr.create("DoColor","doco",MFnNumericData::kBoolean,true);
	MAKE_INPUT(numAttr);

	negative=numAttr.create("Negative","nega",MFnNumericData::kBoolean,false);
	MAKE_INPUT(numAttr);

	noRGB=numAttr.create("NoRGB","nr",MFnNumericData::kBoolean,false);
	MAKE_INPUT(numAttr);

	stencil=numAttr.create("Stencil","sten",MFnNumericData::kBoolean,false);
	MAKE_INPUT(numAttr);
	//*******************************layer texture attribute end*********************************//

	MObject u=numAttr.create("uCoord","u",MFnNumericData::kFloat);
	MObject v=numAttr.create("vCoord","v",MFnNumericData::kFloat);
	UV=numAttr.create("uvCoord","uv",u,v);
	MAKE_INPUT(numAttr);

	MObject filterX=numAttr.create("uvFilterSizeX", "fsx", MFnNumericData::kFloat);
	MObject filterY=numAttr.create( "uvFilterSizeY", "fsy", MFnNumericData::kFloat);
	UVFilterSize=numAttr.create("uvFilterSize", "fs", filterX, filterY);
	MAKE_INPUT(numAttr);

	Output=numAttr.createColor("outColor","oc");
	numAttr.setHidden(true);
	MAKE_OUTPUT(numAttr);

	addAttribute(imageFile);
	addAttribute(imageRepeatX);
	addAttribute(imagerepeatY);
	addAttribute(imageUseAlpha);
	addAttribute(imageCalcAlpha);
	addAttribute(imageNormalMap);
	addAttribute(imageMinX);
	addAttribute(imageMinY);
	addAttribute(imageMaxX);
	addAttribute(imageMaxY);
	addAttribute(mappingMethod);
	addAttribute(texCo);

	addAttribute(layerMix);
	addAttribute(textureColor);
	addAttribute(texColorFact);
	addAttribute(defVal);
	addAttribute(valFact);
	addAttribute(doColor);
	addAttribute(negative);
	addAttribute(noRGB);
	addAttribute(stencil);

	addAttribute(UV);
	addAttribute(UVFilterSize);
	addAttribute(Output);

	attributeAffects(imageFile,Output);
	attributeAffects(imageRepeatX,Output);
	attributeAffects(imagerepeatY,Output);
	attributeAffects(imageUseAlpha,Output);
	attributeAffects(imageCalcAlpha,Output);
	attributeAffects(imageNormalMap,Output);
	attributeAffects(imageMinX,Output);
	attributeAffects(imageMinY,Output);
	attributeAffects(imageMaxX,Output);
	attributeAffects(imageMaxY,Output);
	attributeAffects(mappingMethod,Output);
	attributeAffects(texCo,Output);
	attributeAffects(layerMix,Output);
	attributeAffects(textureColor,Output);
	attributeAffects(texColorFact,Output);
	attributeAffects(defVal,Output);
	attributeAffects(valFact,Output);
	attributeAffects(doColor,Output);
	attributeAffects(negative,Output);
	attributeAffects(noRGB,Output);
	attributeAffects(stencil,Output);
	attributeAffects(UV,Output);
	attributeAffects(UVFilterSize,Output);

	return stat;
}
コード例 #13
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;
	}
コード例 #14
0
ファイル: renderGlobalsNode.cpp プロジェクト: MassW/OpenMaya
MStatus	MayaRenderGlobalsNode::initialize()
{
	
	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;
	MStatus stat = MStatus::kSuccess;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return MStatus::kSuccess;
}
コード例 #15
0
MStatus latticeNoiseNode::initialize()
{ 
	MFnUnitAttribute    unitAttr;
	MFnTypedAttribute   typedAttr;
	MFnNumericAttribute numAttr;

	MStatus stat;

	input = typedAttr.create( "input", "in", MFnData::kLattice, &stat );
	if ( !stat ) {
		stat.perror("ERROR creating latticeNoiseNode input lattice attribute");
		return stat;
	}

	amplitude = numAttr.create( "amplitude", "amp", 
											   MFnNumericData::kFloat,
											   DEF_AMPLITUDE,
											   &stat );
	if ( !stat ) {
		stat.perror("ERROR creating latticeNoiseNode amplitude attribute");
		return stat;
	}

	frequency = numAttr.create( "frequency", "fq", 
											   MFnNumericData::kFloat,
											   DEF_FREQ,
											   &stat );
	if ( !stat ) {
		stat.perror("ERROR creating latticeNoiseNode frequency attribute");
		return stat;
	}

	time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime,
											0.0, &stat );
	if ( !stat ) {
		stat.perror("ERROR creating latticeNoiseNode time attribute");
		return stat;
	}

	output = typedAttr.create( "output", "out", MFnData::kLattice, &stat ); 
	if ( !stat ) {
		stat.perror("ERROR creating latticeNoiseNode output attribute");
		return stat;
	}
	typedAttr.setWritable(false);

	stat = addAttribute( input );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( amplitude );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( frequency );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( time );
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute( output );
		if (!stat) { stat.perror("addAttribute"); return stat;}

	stat = attributeAffects( input, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( amplitude, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( frequency, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( time, output );
		if (!stat) { stat.perror("attributeAffects"); return stat;}


	return MS::kSuccess;
}
コード例 #16
0
ファイル: mixMaterial.cpp プロジェクト: UIKit0/OpenMaya
MStatus mix::initialize()
{
	MFnNumericAttribute nAttr;
	MFnLightDataAttribute lAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

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

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

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

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

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

	amount = nAttr.create("amount", "amount",  MFnNumericData::kFloat, 0.5);
	CHECK_MSTATUS(addAttribute( amount ));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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


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

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

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

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


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

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

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

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

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

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

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


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

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

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

    return( MS::kSuccess );
}
コード例 #17
0
ファイル: lambertShader.cpp プロジェクト: 2asoft/xray
MStatus CXRayMtl::initialize()
{
	MFnNumericAttribute nAttr; 
	MFnLightDataAttribute lAttr;
	MFnEnumAttribute eAttr;
	MFnTypedAttribute tAttr;

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

	// Attribute Initialization:
	//
	// create      - The create function creates a new attribute for the
	//				 node, it takes a long name for the attribute, a short
	//				 name for the attribute, the type of the attribute,
	//				 and a status object to determine if the api call was
	//				 successful.
	//
	// setKeyable  - Sets whether this attribute should accept keyframe
	//				 data, Attributes are not keyable by default.
	//
	// setStorable - Sets whether this attribute should be storable. If an
	//				 attribute is storable, then it will be writen out
	//				 when the node is stored to a file. Attributes are 
	//               storable by default.
	//
	// setDefault  - Sets the default value for this attribute.
	//
	// setUsedAsColor - Sets whether this attribute should be presented as
	//				 a color in the UI.
	//
	// setHidden   - Sets whether this attribute should be hidden from the
	//				 UI. This is useful if the attribute is being used for
	//				 blind data, or if it is being used as scratch space
	//				 for a geometry calculation (should also be marked
	//				 non-connectable in that case). Attributes are not
	//				 hidden by default.
	//
	// setReadable - Sets whether this attribute should be readable. If an
	//				 attribute is readable, then it can be used as the
	//				 source in a dependency graph connection. Attributes
	//				 are readable by default.
	//
	// setWritable - Sets whether this attribute should be readable. If an
	//				 attribute is writable, then it can be used as the
	//				 destination in a dependency graph connection. If an
	//			     attribute is not writable then setAttr commands will
	//				 fail to change the attribute. If both keyable and
	//				 writable for an attribute are set to true it will be
	//				 displayed in the channel box when the node is
	//				 selected. Attributes are writable by default.
	//
	// setArray    - Sets whether this attribute should have an array of
	//				 data. This should be set to true if the attribute
	//				 needs to accept multiple incoming connections.
	//				 Attributes are single elements by default.
	//


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

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

	aColorR = nAttr.create( "colorR", "cr",MFnNumericData::kFloat, 0,
		&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aColorG = nAttr.create( "colorG", "cg", MFnNumericData::kFloat, 0,
		&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.58824f ) );

	aColorB = nAttr.create( "colorB", "cb",MFnNumericData::kFloat, 0,
		&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.644f ) );

	aColor = nAttr.create( "color", "c", aColorR, aColorG, aColorB,
		&status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );

	aIncandescenceR = nAttr.create( "incandescenceR", "ir",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescenceG = nAttr.create( "incandescenceG", "ig",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescenceB = nAttr.create( "incandescenceB", "ib",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status);
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f ) );

	aIncandescence = nAttr.create( "incandescence", "ic", aIncandescenceR,
		aIncandescenceG, aIncandescenceB, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );

	aInTransR = nAttr.create( "transparencyR", "itr",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransG = nAttr.create( "transparencyG", "itg",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransB = nAttr.create( "transparencyB", "itb",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status);
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );

	aInTransparency = nAttr.create( "transparency", "it", aInTransR,
		aInTransG, aInTransB, &status );
	CHECK_MSTATUS( status );
	CHECK_MSTATUS( nAttr.setKeyable( true ) );
	CHECK_MSTATUS( nAttr.setStorable( true ) );
	CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) );
	CHECK_MSTATUS( nAttr.setUsedAsColor( true ) );


	// Output Attributes
	//

	// Color Output
	//
	aOutColorR = nAttr.create( "outColorR", "ocr", MFnNumericData::kFloat,
		0, &status );
	CHECK_MSTATUS( status );

	aOutColorG = nAttr.create( "outColorG", "ocg", MFnNumericData::kFloat,
		0, &status );
	CHECK_MSTATUS( status );

	aOutColorB = nAttr.create( "outColorB", "ocb", MFnNumericData::kFloat,
		0, &status );
	CHECK_MSTATUS( status );

	aOutColor = nAttr.create( "outColor", "oc", aOutColorR, aOutColorG,
		aOutColorB, &status );
	CHECK_MSTATUS( status );

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


	// Transparency Output
	//
	aOutTransR = nAttr.create( "outTransparencyR", "otr",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransG = nAttr.create( "outTransparencyG", "otg",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransB = nAttr.create( "outTransparencyB", "otb",
		MFnNumericData::kFloat, 0, &status );
	CHECK_MSTATUS( status );

	aOutTransparency = nAttr.create( "outTransparency", "ot",
		aOutTransR,aOutTransG,aOutTransB, &status );
	CHECK_MSTATUS( status );

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


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

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

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

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


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

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

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

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


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

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

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

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


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

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

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

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

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

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

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


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

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

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

	// loading x-ray part
	xrDoubleSide  = nAttr.create( "xrayDoubleSide", "xrd",  MFnNumericData::kBoolean, 0, &status );
	MAKE_INPUT(nAttr);

	LPSTRVec lst;
	LPSTRIt it;

	xrEngineData = eAttr.create( "xrayEngineShader", "xre");
	MAKE_INPUT(eAttr);
	LoadBlenderList(lst);
	for (it=lst.begin(); it!=lst.end(); it++)
	{
		_ChangeSymbol(*it,'\\','/');
		CHECK_MSTATUS (eAttr.addField(*it,crc16_calc((u8*)*it,xr_strlen(*it))));
	}
#if MAYA_API_VERSION > 450
	CHECK_MSTATUS ( eAttr.setDefault(eAttr.fieldIndex("default")));
#else	
#endif
	ClearList(lst);

	xrCompilerData = eAttr.create( "xrayCompilerShader", "xrc");
	MAKE_INPUT(eAttr);
	LoadShaderLCList(lst);
	for (it=lst.begin(); it!=lst.end(); it++){
		_ChangeSymbol(*it,'\\','/');
		CHECK_MSTATUS (eAttr.addField(*it,crc16_calc((u8*)*it,xr_strlen(*it))));
	}
#if MAYA_API_VERSION > 450
	CHECK_MSTATUS ( eAttr.setDefault(eAttr.fieldIndex("default")));
#else	
#endif
	ClearList(lst);

	xrMaterialData = eAttr.create( "xrayGameMaterial", " ");
	MAKE_INPUT(eAttr);
	LoadGameMtlList(lst);
	for (it=lst.begin(); it!=lst.end(); it++)
	{
		_ChangeSymbol(*it,'\\','/');
		CHECK_MSTATUS (eAttr.addField(*it,crc16_calc((u8*)*it,xr_strlen(*it))));
	}
#if MAYA_API_VERSION > 450
	CHECK_MSTATUS ( eAttr.setDefault(eAttr.fieldIndex("default")));
#else	
#endif
	ClearList(lst);

	CHECK_MSTATUS ( addAttribute(xrDoubleSide) );
	CHECK_MSTATUS ( addAttribute(xrEngineData) );
	CHECK_MSTATUS ( addAttribute(xrCompilerData) );
	CHECK_MSTATUS ( addAttribute(xrMaterialData) );
	// end x-ray part

	return( MS::kSuccess );
}
コード例 #18
0
ファイル: cvColorNode.cpp プロジェクト: DimondTheCat/xray
MStatus cvColor::initialize()
{ 
	MStatus				stat;
	MFnNumericAttribute	numericAttr;
	MFnTypedAttribute	typedAttr;

	drawingEnabled = numericAttr.create( "drawingEnabled", "en",
									MFnNumericData::kBoolean, 1, &stat );
	if (!stat) {
		stat.perror("create drawingEnabled attribute");
		return stat;
	}

	pointSize = numericAttr.create( "pointSize", "ps",
									MFnNumericData::kFloat, 4.0, &stat );
	if (!stat) {
		stat.perror("create pointSize attribute");
		return stat;
	}
	
	inputSurface = typedAttr.create( "inputSurface", "is",
							 MFnNurbsSurfaceData::kNurbsSurface, &stat);
	if (!stat) {
		stat.perror("create inputSurface attribute");
		return stat;
	}

	cvLocations = typedAttr.create( "cvLocations", "cv",
							 MFnPointArrayData::kPointArray, &stat);
	if (!stat) {
		stat.perror("create cvLocations attribute");
		return stat;
	}

	MPointArray			defaultPoints;
	MFnPointArrayData	defaultArray;
	MObject				defaultAttr;

	defaultPoints.clear(); // Empty array
	defaultAttr = defaultArray.create (defaultPoints);
	stat = typedAttr.setDefault(defaultAttr);
	if (!stat) {
		stat.perror("could not create default output attribute");
		return stat;
	}

	stat = addAttribute (drawingEnabled);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (pointSize);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (inputSurface);
		if (!stat) { stat.perror("addAttribute"); return stat;}
	stat = addAttribute (cvLocations);
		if (!stat) { stat.perror("addAttribute"); return stat;}

	stat = attributeAffects( inputSurface, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( drawingEnabled, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	stat = attributeAffects( pointSize, cvLocations );
		if (!stat) { stat.perror("attributeAffects"); return stat;}
	
	return MS::kSuccess;
}
コード例 #19
0
ファイル: dgTransform.cpp プロジェクト: jonntd/mayadev-1
MStatus dgTransform::initialize()
{
	MStatus status;

	MFnNumericAttribute nAttr;
	MFnMatrixAttribute mAttr;
	MFnUnitAttribute uAttr;

	aTranslateX = nAttr.create( "translateX", "tx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslateY = nAttr.create( "translateY", "ty", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslateZ = nAttr.create( "translateZ", "tz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aTranslate  = nAttr.create( "translate", "t", aTranslateX, aTranslateY, aTranslateZ );
	nAttr.setStorable( true );
	status = addAttribute( aTranslate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aRotateX = uAttr.create( "rotateX", "rx", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotateY = uAttr.create( "rotateY", "ry", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotateZ = uAttr.create( "rotateZ", "rz", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true );
	aRotate  = nAttr.create( "rotate", "r", aRotateX, aRotateY, aRotateZ );
	nAttr.setStorable( true );
	status = addAttribute( aRotate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aScaleX = nAttr.create( "scaleX", "sx", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScaleY = nAttr.create( "scaleY", "sy", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScaleZ = nAttr.create( "scaleZ", "sz", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true );
	aScale  = nAttr.create( "scale", "s", aScaleX, aScaleY, aScaleZ );
	nAttr.setStorable( true );
	status = addAttribute( aScale );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aShearX = nAttr.create( "shearX", "shx", MFnNumericData::kDouble, 0.0 );
	aShearY = nAttr.create( "shearY", "shy", MFnNumericData::kDouble, 0.0 );
	aShearZ = nAttr.create( "shearZ", "shz", MFnNumericData::kDouble, 0.0 );
	aShear  = nAttr.create( "shear", "sh", aShearX, aShearY, aShearZ );
	nAttr.setStorable( true );
	status = addAttribute( aShear );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aJointOrientX = uAttr.create( "jointOrientX", "jox", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrientY = uAttr.create( "jointOrientY", "joy", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrientZ = uAttr.create( "jointOrientZ", "joz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aJointOrient  = nAttr.create( "jointOrient", "jo", aJointOrientX, aJointOrientY, aJointOrientZ );
	nAttr.setStorable( true );
	status = addAttribute( aJointOrient );
	CHECK_MSTATUS_AND_RETURN_IT( status );


	aInputTranslateX = nAttr.create( "inputTranslateX", "itx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslateY = nAttr.create( "inputTranslateY", "ity", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslateZ = nAttr.create( "inputTranslateZ", "itz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputTranslate  = nAttr.create( "inputTranslate", "it", aInputTranslateX, aInputTranslateY, aInputTranslateZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputTranslate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputRotateX = uAttr.create( "inputRotateX", "irx", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotateY = uAttr.create( "inputRotateY", "iry", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotateZ = uAttr.create( "inputRotateZ", "irz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true );
	aInputRotate  = nAttr.create( "inputRotate", "ir", aInputRotateX, aInputRotateY, aInputRotateZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputRotate );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputScaleX = nAttr.create( "inputScaleX", "isx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScaleY = nAttr.create( "inputScaleY", "isy", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScaleZ = nAttr.create( "inputScaleZ", "isz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true );
	aInputScale  = nAttr.create( "inputScale", "is", aInputScaleX, aInputScaleY, aInputScaleZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputScale );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	aInputShearX = nAttr.create( "inputShearX", "ishx", MFnNumericData::kDouble, 0.0 );
	aInputShearY = nAttr.create( "inputShearY", "ishy", MFnNumericData::kDouble, 0.0 );
	aInputShearZ = nAttr.create( "inputShearZ", "ishz", MFnNumericData::kDouble, 0.0 );
	aInputShear  = nAttr.create( "inputShear", "ish", aInputShearX, aInputShearY, aInputShearZ );
	nAttr.setStorable( true );
	status = addAttribute( aInputShear );
	CHECK_MSTATUS_AND_RETURN_IT( status );


	MObject* affectedAttrs[6];

	aMatrix = mAttr.create( "matrix", "m" );
	nAttr.setStorable( false );
	status = addAttribute( aMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[0] = &aMatrix;

	aInverseMatrix = mAttr.create( "inverseMatrix", "im" );
	nAttr.setStorable( false );
	status = addAttribute( aInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[1] = &aInverseMatrix;

	aWorldMatrix = mAttr.create( "worldMatrix", "wm" );
	nAttr.setStorable( false );
	status = addAttribute( aWorldMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[2] = &aWorldMatrix;

	aWorldInverseMatrix = mAttr.create( "worldInverseMatrix", "wim" );
	nAttr.setStorable( false );
	status = addAttribute( aWorldInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[3] = &aWorldInverseMatrix;

	aParentMatrix = mAttr.create( "parentMatrix", "pm" );
	nAttr.setStorable( false );
	status = addAttribute( aParentMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[4] = &aParentMatrix;

	aParentInverseMatrix = mAttr.create( "parentInverseMatrix", "pim" );
	nAttr.setStorable( false );
	status = addAttribute( aParentInverseMatrix );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	affectedAttrs[5] = &aParentInverseMatrix;

	status = attributeAffectsArray( aTranslate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aRotate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aScale, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aShear, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aJointOrient, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputTranslate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputRotate, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputScale, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );
	status = attributeAffectsArray( aInputShear, affectedAttrs );
	CHECK_MSTATUS_AND_RETURN_IT( status );

	return MS::kSuccess;
}
コード例 #20
0
ファイル: n_remap.cpp プロジェクト: kremersa/arrayNodes
MStatus RemapArrayValuesNode::initialize()
{
    MStatus status;

    MFnCompoundAttribute C;
    MFnTypedAttribute T;
    MFnNumericAttribute N;
    MFnEnumAttribute E;

    aInput = T.create("input", "i", MFnData::kDoubleArray, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setStorable(true);
    T.setWritable(true);

    aInputMin = N.create("inputMin", "imn", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);

    aInputMax = N.create("inputMax", "imx", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(1.0);

    aOutputMin = N.create("outputMin", "omn", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);

    aOutputMax = N.create("outputMax", "omx", MFnNumericData::kDouble, 0.0, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    N.setKeyable(true);
    N.setChannelBox(true);
    N.setStorable(true);
    N.setWritable(true);
    N.setDefault(1.0);

    aRamp = MRampAttribute::createCurveRamp("values", "vl", &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    aOutput = T.create("output", "o", MFnData::kDoubleArray, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    T.setKeyable(false);
    T.setChannelBox(false);
    T.setWritable(false);
    T.setStorable(false);

    addAttribute(aInput);
    addAttribute(aInputMin);
    addAttribute(aInputMax);
    addAttribute(aOutputMin);
    addAttribute(aOutputMax);
    addAttribute(aRamp);
    addAttribute(aOutput);

    attributeAffects(aInput, aOutput);
    attributeAffects(aInputMin, aOutput);
    attributeAffects(aInputMax, aOutput);
    attributeAffects(aOutputMin, aOutput);
    attributeAffects(aOutputMax, aOutput);
    attributeAffects(aRamp, aOutput);

    return MS::kSuccess;
}
コード例 #21
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;
}
コード例 #22
0
ファイル: splineSolverNode.cpp プロジェクト: skarone/PipeL
MStatus splineSolverNode::preSolve()
{

    MStatus stat;
    setRotatePlane(false);
    setSingleChainOnly(true);
    setPositionOnly(false);
    //Get Handle
    MIkHandleGroup * handle_group = handleGroup();
    if (NULL == handle_group) {
        return MS::kFailure;
    }
    MObject handle = handle_group->handle( 0 );
    MDagPath handlePath = MDagPath::getAPathTo( handle );
    fnHandle.setObject( handlePath );
    //Get Curve
    MPlug inCurvePlug = fnHandle.findPlug( "inCurve" );
    MDataHandle curveHandle = inCurvePlug.asMDataHandle();
    MObject inputCurveObject = curveHandle.asNurbsCurveTransformed();
    curveFn.setObject( inputCurveObject );
    float initCurveLength = curveFn.length();
    MVector initNormal = curveFn.normal(0);
    MVector initTangent = curveFn.tangent(0);
    float stretchRatio = 1;
    // Get the position of the end_effector
    //
    MDagPath effectorPath;
    fnHandle.getEffector(effectorPath);
    tran.setObject( effectorPath );
    // Get the start joint position
    //
    MDagPath startJointPath;
    fnHandle.getStartJoint( startJointPath );
    joints.clear();
    //Get Joints
    while (true)
    {
        effectorPath.pop();
        joints.push_back( effectorPath );
        if (effectorPath == startJointPath)
            break;
    }
    std::reverse(joints.begin(), joints.end());
    if (!fnHandle.hasAttribute("str"))
    {
        //Add Custom Attributes to Handle
        MFnNumericAttribute fnAttr;
        MObject attr = fnAttr.create("stretchRatio", "str", MFnNumericData::kDouble, stretchRatio);
        fnAttr.setKeyable(1);
        fnAttr.setWritable(1);
        fnAttr.setMin(0);
        fnAttr.setMax(1);
        fnAttr.setHidden(0);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("anchorPosition", "ancp", MFnNumericData::kDouble, 0.0);
        fnAttr.setKeyable(1);
        fnAttr.setWritable(1);
        fnAttr.setMin(0);
        fnAttr.setMax(1);
        fnAttr.setHidden(0);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("curveLength", "cvLen", MFnNumericData::kDouble, initCurveLength);
        fnAttr.setKeyable(0);
        fnAttr.setWritable(1);
        fnAttr.setHidden(1);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("initNormal", "norm", MFnNumericData::k3Double);
        fnAttr.setDefault(initNormal.x, initNormal.y, initNormal.z);
        fnAttr.setKeyable(0);
        fnAttr.setWritable(1);
        fnAttr.setHidden(1);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("initTangent", "tang", MFnNumericData::k3Double);
        fnAttr.setDefault(initTangent.x, initTangent.y, initTangent.z);
        fnAttr.setKeyable(0);
        fnAttr.setWritable(1);
        fnAttr.setHidden(1);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("jointsLength", "jsLen", MFnNumericData::kDouble, getJointsTotalLenght());
        fnAttr.setKeyable(0);
        fnAttr.setWritable(1);
        fnAttr.setHidden(1);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("startTwist", "strtw", MFnNumericData::kDouble, 0.0);
        fnAttr.setKeyable(1);
        fnAttr.setWritable(1);
        fnAttr.setHidden(0);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        attr = fnAttr.create("endTwist", "endtw", MFnNumericData::kDouble, 0.0);
        fnAttr.setKeyable(1);
        fnAttr.setWritable(1);
        fnAttr.setHidden(0);
        fnAttr.setStorable(1);
        fnAttr.setReadable(1);
        fnHandle.addAttribute(attr, MFnDependencyNode::kLocalDynamicAttr);
        MObject twistRamp = MRampAttribute::createCurveRamp("twistRamp", "twr");
        fnHandle.addAttribute(twistRamp, MFnDependencyNode::kLocalDynamicAttr);
        MObject scaleRamp = MRampAttribute::createCurveRamp("scaleRamp", "scr");
        fnHandle.addAttribute(scaleRamp, MFnDependencyNode::kLocalDynamicAttr);
    } else
    {
        MPlug strPlug = fnHandle.findPlug("str");
        stretchRatio = strPlug.asDouble();
    }

    return MS::kSuccess;
}
コード例 #23
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;
}
コード例 #24
0
//initialize
MStatus Ocio_log_convert::initialize()
{

    //MFnSets
    MFnEnumAttribute eAttr;
    MFnNumericAttribute nAttr;
    MFnTypedAttribute tAttr;


    //a_verbose
    a_verbose = eAttr.create("verbose", "verbose", 1);
    eAttr.addField("no verbose", 0);
    eAttr.addField("verbose", 1);
    addAttribute(a_verbose);

    //a_input_color
    a_input_color = nAttr.createColor("input_color", "input_color");
    nAttr.setUsedAsColor(true);
    nAttr.setStorable(true);
    addAttribute(a_input_color);

    //a_output_color
    a_output_color = nAttr.createColor("output_color", "output_color");
    nAttr.setUsedAsColor(true);
    nAttr.setStorable(false);
    addAttribute(a_output_color);

    //a_env_or_file
    a_env_or_file = eAttr.create("env_or_file", "env_or_file", 0);
    eAttr.addField("OCIO Environment Variable", 0);
    eAttr.addField("Custom Path", 1);
    eAttr.setStorable(true);
    addAttribute(a_env_or_file);

    //a_last_env_or_file
    a_last_env_or_file = nAttr.create("last_env_or_file", "last_env_or_file", MFnNumericData::kInt, 0);
    nAttr.setHidden(true);
    nAttr.setStorable(true);
    addAttribute(a_last_env_or_file);

    //a_config_file_path
    a_config_file_path = tAttr.create("config_file_path", "config_file_path", MFnData::kString);
    tAttr.setUsedAsFilename(true);
    tAttr.setStorable(true);
    addAttribute(a_config_file_path);

    //a_last_config_file_path
    a_last_config_file_path = tAttr.create("last_config_file_path", "last_config_file_path", MFnData::kString);
    tAttr.setHidden(true);
    tAttr.setStorable(true);
    addAttribute(a_last_config_file_path);

    //a_operation
    a_operation = eAttr.create("operation", "operation", 0);
    eAttr.addField("Log to Lin", 0);
    eAttr.addField("Lin to Log", 1);
    addAttribute(a_operation);

    //a_last_operation
    a_last_operation = nAttr.create("last_operation", "last_operation", MFnNumericData::kInt, 0);
    nAttr.setHidden(true);
    nAttr.setStorable(true);
    addAttribute(a_last_operation);






    //Attribute affects
    attributeAffects(a_input_color, a_output_color);
    attributeAffects(a_env_or_file, a_output_color);
    attributeAffects(a_config_file_path, a_output_color);
    attributeAffects(a_operation, a_output_color);




    return MStatus::kSuccess;
}
コード例 #25
0
MStatus vixo_hairStyleMaya::initialize()
{
	MFnTypedAttribute tAttr;
	MFnNumericAttribute nAttr;

	hairInfoColorDir=tAttr.create("hairInfoColorDir","hcd",MFnData::kString);

	//follicle
	inMesh=tAttr.create("inMesh","im",MFnData::kMesh);
	hairNum=nAttr.create("hairNum","hn",MFnNumericData::kInt,0);
	refreshBasicInfo=nAttr.create("refreshBasicInfo","rbi",MFnNumericData::kBoolean,0);
	printBasicInfo=nAttr.create("printBasicInfo","pbi",MFnNumericData::kInt,1);
	//follicle

	//color
	refreshColorInfo=nAttr.create("refreshColorInfo","rci",MFnNumericData::kBoolean,0);
	printColorInfo=nAttr.create("printColorInfo","pci",MFnNumericData::kInt,1);
	densityMap=nAttr.createColor("densityMap","den");
	nAttr.setDefault(1.0f,1.0f,1.0f);

	tipColor=nAttr.createColor("tipColor","tc");
	nAttr.setDefault(1.0f,1.0f,1.0f);
	tipColorNoiseAmp=nAttr.create("tipColorNoiseAmp","tca",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	tipColorNoiseFreq=nAttr.create("tipColorNoiseFreq","tcf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);

	baseColor=nAttr.createColor("baseColor","bc");
	nAttr.setDefault(1.0f,1.0f,1.0f);
	baseColorNoiseAmp=nAttr.create("baseColorNoiseAmp","bca",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	baseColorNoiseFreq=nAttr.create("baseColorNoiseFreq","bcf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);

	tipOpacity=nAttr.createColor("tipOpacity","to");
	nAttr.setDefault(1.0f,1.0f,1.0f);
	tipOpacityNoiseAmp=nAttr.create("tipOpacityNoiseAmp","toa",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	tipOpacityNoiseFreq=nAttr.create("tipOpacityNoiseFreq","tof",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);

	baseOpacity=nAttr.createColor("baseOpacity","bo");
	nAttr.setDefault(1.0f,1.0f,1.0f);
	baseOpacityNoiseAmp=nAttr.create("baseOpacityNoiseAmp","boa",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	baseOpacityNoiseFreq=nAttr.create("baseOpacityNoiseFreq","bof",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);
	//color

	hairInfoStyleDir=tAttr.create("hairInfoStyleDir","hsd",MFnData::kString);

	//style
	//noiseSeed=nAttr.create("noiseSeed","ns",MFnNumericData::kInt,1);
	
	lengthNoiseAmp=nAttr.create("lengthNoiseAmp","lna",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	lengthNoiseFreq=nAttr.create("lengthNoiseFreq","lnf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);
	inclinationNoiseAmp=nAttr.create("inclinationNoiseAmp","ina",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	inclinationNoiseFreq=nAttr.create("inclinationNoiseFreq","inf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);
	polarNoiseAmp=nAttr.create("polarNoiseAmp","pna",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	polarNoiseFreq=nAttr.create("polarNoiseFreq","pnf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);
	tipCurlNoiseAmp=nAttr.create("tipCurlNoiseAmp","tcna",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	tipCurlNoiseFreq=nAttr.create("tipCurlNoiseFreq","tcnf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);
	baseCurlNoiseAmp=nAttr.create("baseCurlNoiseAmp","bcna",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(1.0);
	baseCurlNoiseFreq=nAttr.create("baseCurlNoiseFreq","bcnf",MFnNumericData::kFloat,0.0);
	nAttr.setMin(0.0);
	nAttr.setMax(100.0);

	refreshStyleInfo=nAttr.create("refreshStyleInfo","rsi",MFnNumericData::kBoolean,0);
	printStyleInfo=nAttr.create("printStyleInfo","psi",MFnNumericData::kInt,1);
	//style


	addAttribute(hairInfoColorDir);

	addAttribute(inMesh);
	addAttribute(hairNum);
	addAttribute(refreshBasicInfo);
	addAttribute(printBasicInfo);

	addAttribute(densityMap);
	addAttribute(tipColor);
	addAttribute(tipColorNoiseAmp);
	addAttribute(tipColorNoiseFreq);
	addAttribute(baseColor);
	addAttribute(baseColorNoiseAmp);
	addAttribute(baseColorNoiseFreq);
	addAttribute(tipOpacity);
	addAttribute(tipOpacityNoiseAmp);
	addAttribute(tipOpacityNoiseFreq);
	addAttribute(baseOpacity);
	addAttribute(baseOpacityNoiseAmp);
	addAttribute(baseOpacityNoiseFreq);
	addAttribute(refreshColorInfo);
	addAttribute(printColorInfo);

	addAttribute(hairInfoStyleDir);

	addAttribute(lengthNoiseAmp);
	addAttribute(lengthNoiseFreq);
	addAttribute(inclinationNoiseAmp);
	addAttribute(inclinationNoiseFreq);
	addAttribute(polarNoiseAmp);
	addAttribute(polarNoiseFreq);
	addAttribute(tipCurlNoiseAmp);
	addAttribute(tipCurlNoiseFreq);
	addAttribute(baseCurlNoiseAmp);
	addAttribute(baseCurlNoiseFreq);

	addAttribute(refreshStyleInfo);
	addAttribute(printStyleInfo);

	//attributeAffects(inMesh,printBasicInfo);
	//attributeAffects(hairNum,printBasicInfo);
	//attributeAffects(follicleFileName,printBasicInfo);
	attributeAffects(inMesh,printBasicInfo);
	attributeAffects(hairNum,printBasicInfo);
	attributeAffects(refreshBasicInfo,printBasicInfo);
	attributeAffects(refreshColorInfo,printColorInfo);
	attributeAffects(refreshStyleInfo,printStyleInfo);

	return MS::kSuccess;
}
コード例 #26
0
ファイル: wrinkledTexture.cpp プロジェクト: MassW/OpenMaya
//
// DESCRIPTION:
MStatus wrinkled::initialize()
{
	MFnNumericAttribute nAttr;
	MFnTypedAttribute tAttr;
	MFnGenericAttribute gAttr;
	MFnEnumAttribute eAttr;
	MFnMessageAttribute mAttr;

	MStatus status;

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

//---------------------------- automatically created attributes start ------------------------------------
	MObject scaleX = nAttr.create("scaleX", "scalex", MFnNumericData::kDouble, 0.0);
	MObject scaleY = nAttr.create("scaleY", "scaley", MFnNumericData::kDouble, 0.0);
	MObject scaleZ = nAttr.create("scaleZ", "scalez", MFnNumericData::kDouble, 0.0);
	scale = nAttr.create("scale", "scale", scaleX, scaleY, scaleZ);
	MAKE_INPUT(nAttr);
	nAttr.setDefault(1,1,1);
	CHECK_MSTATUS(addAttribute( scale ));

	octaves = nAttr.create("octaves", "octaves",  MFnNumericData::kInt, 8);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(addAttribute( octaves ));

	coordinates = eAttr.create("coordinates", "coordinates", 0, &status);
	status = eAttr.addField( "global", 0 );
	status = eAttr.addField( "local", 1 );
	status = eAttr.addField( "global normal", 2 );
	status = eAttr.addField( "localnormal", 3 );
	status = eAttr.addField( "uv", 4 );
	MAKE_INPUT(eAttr);
	CHECK_MSTATUS(addAttribute( coordinates ));

	roughness = nAttr.create("roughness", "roughness",  MFnNumericData::kFloat, 0.5);
	MAKE_INPUT(nAttr);
	CHECK_MSTATUS(addAttribute( roughness ));

	MObject rotateX = nAttr.create("rotateX", "rotatex", MFnNumericData::kDouble, 0.0);
	MObject rotateY = nAttr.create("rotateY", "rotatey", MFnNumericData::kDouble, 0.0);
	MObject rotateZ = nAttr.create("rotateZ", "rotatez", MFnNumericData::kDouble, 0.0);
	rotate = nAttr.create("rotate", "rotate", rotateX, rotateY, rotateZ);
	MAKE_INPUT(nAttr);
	nAttr.setDefault(0,0,0);
	CHECK_MSTATUS(addAttribute( rotate ));

	MObject translateX = nAttr.create("translateX", "translatex", MFnNumericData::kDouble, 0.0);
	MObject translateY = nAttr.create("translateY", "translatey", MFnNumericData::kDouble, 0.0);
	MObject translateZ = nAttr.create("translateZ", "translatez", MFnNumericData::kDouble, 0.0);
	translate = nAttr.create("translate", "translate", translateX, translateY, translateZ);
	MAKE_INPUT(nAttr);
	nAttr.setDefault(0,0,0);
	CHECK_MSTATUS(addAttribute( translate ));

	luxOutFloat = nAttr.create("luxOutFloat", "luxOutFloat",  MFnNumericData::kFloat);
	MAKE_OUTPUT(nAttr);
	CHECK_MSTATUS(addAttribute( luxOutFloat ));

	CHECK_MSTATUS ( attributeAffects( scale, luxOutFloat));
	CHECK_MSTATUS ( attributeAffects( scale, outColor));
//---------------------------- automatically created attributes end ------------------------------------

    return MS::kSuccess;
}
コード例 #27
0
ファイル: MG_nurbsRivet.cpp プロジェクト: bungnoid/MG_Tools
MStatus MG_nurbsRivet::initialize()
	{ 

		//This is the nurbs input attribute
		MFnTypedAttribute typedFn;
		MFnCompoundAttribute compund;
		MFnNumericAttribute numFn;
		MFnMatrixAttribute    matrixFn;

		inputNurbSurface  = typedFn.create("inputNurbSurface","in",MFnData::kNurbsSurface);
		typedFn.setStorable(true);
		addAttribute(inputNurbSurface);
		

		//This is the input point   attribute
		
		
		inputPointX = numFn.create("inputPointX","ipx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(inputPointX);

		inputPointY = numFn.create("inputPointY","ipy",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(inputPointY);
		

		inputPointZ = numFn.create("inputPointZ","ipz",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(inputPointZ);




		
		inputPoint= compund.create("inputPoint","ip");
		compund.addChild(inputPointX);
		compund.addChild(inputPointY);
		compund.addChild(inputPointZ);
		addAttribute(inputPoint);
	

		//This is the recompute point checkbox
	
		recompute = numFn.create("recompute","r",MFnNumericData::kBoolean,1);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(recompute);

		//This is U attribute
	
		uValue = numFn.create("uValue","u",MFnNumericData::kFloat , 0);
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(uValue);


		//This is V attribute
	
		vValue = numFn.create("vValue","v",MFnNumericData::kFloat , 0 );
		numFn.setKeyable(true);
		numFn.setStorable(true);
		addAttribute(vValue);



		//This is the output translate attribute 

		outputX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputX);

		outputY = numFn.create("outputTranslateY","oty",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputY);
		

		outputZ = numFn.create("outputTranslateZ","otz",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputZ);




		
		output= compund.create("outputTranslate","ot");
		compund.addChild(outputX);
		compund.addChild(outputY);
		compund.addChild(outputZ);
		compund.setKeyable(false);
		compund.setStorable(false);
		compund.setWritable(false);
		addAttribute(output);


		//output = numFn.createPoint("outputTranslate","ot");
		//numFn.setKeyable(false);
		//numFn.setStorable(false);
		//numFn.setWritable(false);
		//addAttribute(output);


		//This is the output rotate attribute 
		outputRotateX = numFn.create("outputRotateX","orx",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputRotateX);

		outputRotateY = numFn.create("outputRotateY","ory",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputRotateY);

		outputRotateZ = numFn.create("outputRotateZ","orz",MFnNumericData::kDouble,0);
		numFn.setStorable(true);
		numFn.setKeyable(true);
		addAttribute(outputRotateZ);


		outputRotate= compund.create("outputRotate","oro");
		compund.addChild(outputRotateX);
		compund.addChild(outputRotateY);
		compund.addChild(outputRotateZ);
		compund.setKeyable(false);
		compund.setStorable(false);
		compund.setWritable(false);
		addAttribute(outputRotate);

 
		//Those are all the matrix input 

		
		outputMatrix =matrixFn.create("outputMatrix","om");
		matrixFn.setKeyable(false);
		matrixFn.setStorable(false);
		matrixFn.setWritable(false);
		addAttribute(outputMatrix); 


		//offset matrix 

		offsetMatrix =matrixFn.create("offsetMatrix","ofm");
		MMatrix defMatrix;
		defMatrix.setToIdentity();
		matrixFn.setDefault(defMatrix);
		matrixFn.setKeyable(false);
		matrixFn.setStorable(true);
		matrixFn.setWritable(true);
		addAttribute(offsetMatrix); 

		//all the attr affects

		attributeAffects (recompute,output);
		attributeAffects (inputPoint,output);
		attributeAffects (inputNurbSurface,output);
		attributeAffects (uValue,output);
		attributeAffects (vValue,output);
		attributeAffects (offsetMatrix,output);

		attributeAffects (recompute,outputRotate);
		attributeAffects (inputPoint,outputRotate);
		attributeAffects (inputNurbSurface,outputRotate);
		attributeAffects (uValue,outputRotate);
		attributeAffects (vValue,outputRotate);
		attributeAffects (offsetMatrix,outputRotate);

		attributeAffects (recompute,outputMatrix);
		attributeAffects (inputPoint,outputMatrix);
		attributeAffects (inputNurbSurface,outputMatrix);
		attributeAffects (uValue,outputMatrix);
		attributeAffects (vValue,outputMatrix);
		attributeAffects (offsetMatrix,outputMatrix);

		return MS::kSuccess;
	}
コード例 #28
0
ファイル: phongShader.cpp プロジェクト: DimondTheCat/xray
//
// 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;
}
コード例 #29
0
MObject createPoly(double iFrame, Alembic::AbcGeom::IPolyMesh & iNode,
    MObject & iParent, std::vector<std::string> & oSampledPropNameList)
{
    Alembic::AbcGeom::IPolyMeshSchema schema = iNode.getSchema();
    MString name(iNode.getName().c_str());

    MStatus status = MS::kSuccess;

    MFnMesh fnMesh;
    MObject obj;

    // add other properties
    if (schema.getNumSamples() > 1)
    {
        MFloatPointArray emptyPt;
        MIntArray emptyInt;
        obj = fnMesh.create(0, 0, emptyPt, emptyInt, emptyInt, iParent);
        fnMesh.setName(name);
    }
    else
    {
        int64_t index, ceilIndex;
        double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(),
            schema.getNumSamples(), index, ceilIndex);

        Alembic::AbcGeom::IPolyMeshSchema::Sample samp;
        schema.get(samp, Alembic::Abc::ISampleSelector(index));

        MFloatPointArray ptArray;
        Alembic::Abc::V3fArraySamplePtr ceilPoints;
        if (index != ceilIndex)
        {
            Alembic::AbcGeom::IPolyMeshSchema::Sample ceilSamp;
            schema.get(ceilSamp, Alembic::Abc::ISampleSelector(ceilIndex));
            ceilPoints = ceilSamp.getPositions();
        }

        fillPoints(ptArray, samp.getPositions(), ceilPoints, alpha);
        fillTopology(fnMesh, iParent, ptArray, samp.getIndices(),
            samp.getCounts());
        fnMesh.setName(iNode.getName().c_str());
        setPolyNormals(iFrame, fnMesh, schema.getNormals());
        setUVs(iFrame, fnMesh, schema.getUVs());
        obj = fnMesh.object();
    }

    MString pathName = fnMesh.partialPathName();
    setInitialShadingGroup(pathName);

    if ( !schema.getNormals().valid() )
    {
        MFnNumericAttribute attr;
        MString attrName("noNormals");
        MObject attrObj = attr.create(attrName, attrName,
        MFnNumericData::kBoolean, true, &status);
        attr.setKeyable(true);
        attr.setHidden(false);
        MFnMesh fnMesh(obj);
        fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr);
    }

    return obj;
}
コード例 #30
0
MStatus worldSettingNode::initialize()
{
	MStatus stat;
	MFnNumericAttribute numAttr;
	MFnEnumAttribute enumAttr;

	backgroundTypes=enumAttr.create("BackgroundTypes","wbaty",0);
	enumAttr.addField("Single Color",0);
	enumAttr.addField("Gradient",1);
	enumAttr.addField("Texture",2);
	enumAttr.addField("Sunsky",3);
	enumAttr.addField("DarkTide's Sunsky",4);
	//MCHECKERROR(stat, "create background types");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);
	enumAttr.setHidden(true);

	volumeInitTypes=enumAttr.create("VolumeTypes","wvoty",0);
	enumAttr.addField("None",0);
	enumAttr.addField("Single Scatter",1);
    enumAttr.addField("Sky",2);
	//MCHECKERROR(stat, "create volume types");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);

	DSSkyColorSpaces=enumAttr.create("DarkTideSunskyColorSpaces","wdasu",0);
	enumAttr.addField("CIEE",0);
	enumAttr.addField("CIED50",1);
	enumAttr.addField("sRBGD65",2);
	enumAttr.addField("sRGBD50",3);
	//MCHECKERROR(stat, "create DarkTide's sunsky color spaces");
	enumAttr.setKeyable(true);
	enumAttr.setStorable(true);

	backgroundColor=numAttr.createColor("BackgroundColor","wbaco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.0,0.0,0.0);

	//gradient attribute
	horizonColor=numAttr.createColor("HorizonColor","whoco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.1,0.8,0.5);

	zenithColor=numAttr.createColor("ZenithColor","wzeco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.4,0.5,0.1);

	horGroundColor=numAttr.createColor("HorGroundColor","whgco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.4,0.5,0.6);

	zenGroundColor=numAttr.createColor("ZenGroundColor","wzgco");
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setDefault(0.9,0.5,0.2);

	//texture attribute
	texRotation=numAttr.create("TextureRotation","wtero",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(360.0f);

	//sunsky attribute
	turbidity=numAttr.create("Turbidity","wtu",MFnNumericData::kFloat,1.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(1.0f);
	numAttr.setMax(20.0f);

	AHorBrght=numAttr.create("AHorBrght","wahb",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	BHorSprd=numAttr.create("BHorSprd","wbhs",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	CSunBrght=numAttr.create("CSunBrght","wcsb",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	DSunSize=numAttr.create("DSunsize","wdss",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	EBacklight=numAttr.create("EBacklight","webl",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0f);
	numAttr.setMax(10.0f);

	xDirection=numAttr.create("xDirection","wxd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);


	yDirection=numAttr.create("yDirection","wyd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);

	zDirection=numAttr.create("zDirection","wzd",MFnNumericData::kDouble,0.000);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.000);
	numAttr.setMax(1.000);

	realSun=numAttr.create("AddRealSun","wads",MFnNumericData::kBoolean,0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	sunPower=numAttr.create("SunPower","wsupo",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(10.0);

	skyLight=numAttr.create("Skylight","wsk",MFnNumericData::kBoolean,1);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	skySamples=numAttr.create("SkySamples","wsksa",MFnNumericData::kInt,1);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(1);
	numAttr.setMax(128);

	//DarkTide's sunsky attribute
	DSTurbidity=numAttr.create("DarkTideTurbidity","wdatu",MFnNumericData::kFloat,2.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(2.0);
	numAttr.setMax(12.0);

	renderDSA=numAttr.create("BrightnessOfHorizonGradient","wbhg",MFnNumericData::kFloat,-10.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	renderDSB=numAttr.create("LuminanceOfHorizon","wloh",MFnNumericData::kFloat,-10.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-10.0);
	numAttr.setMax(10.0);

	renderDSC=numAttr.create("SolarRegionIntensity","wsri",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(50.0);

	renderDSD=numAttr.create("WidthOfCircumsolarRegion","wwocr",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(0.0);
	numAttr.setMax(50.0);

	renderDSE=numAttr.create("BackgroundLight","wbl",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-30.0);
	numAttr.setMax(30.0);

	//sun direction shared with sunsky
	 DSAltitude=numAttr.create("Altitude","wal",MFnNumericData::kFloat,0.0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);
	numAttr.setMin(-1.0);
	numAttr.setMax(2.0);

	DSNight=numAttr.create("Night","wni",MFnNumericData::kBoolean,0);
	numAttr.setKeyable(true);
	numAttr.setStorable(true);

	 DSRealSun=numAttr.create("AddDSRealSun","wadrs",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 DSSunPower=numAttr.create("DSSunPower","wdsp",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSSkyLight=numAttr.create("AddDSSkyLight","wadsl",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 DSSkyPower=numAttr.create("DSSkyPower","wdssp",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10000.0);

	 DSSkySamples=numAttr.create("DSSkySamples","wdsss",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(256);

	 DSSkyBright=numAttr.create("Brightness","wbr",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSExposure=numAttr.create("Exposure","wex",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10.0);

	 DSGammaEncoding=numAttr.create("GammaEncoding","wgaen",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	//these  appear in each type of background
	 useIBL=numAttr.create("UseIBL","wibl",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 IBLSamples=numAttr.create("IBLSamples","wibls",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(512);

	 backgroundDiffuse=numAttr.create("DiffusePhotons","wdiph",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 backgoundCaustic=numAttr.create("CausticPhotons","wcaph",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	 backgoundPower=numAttr.create("BackgroundPower","wbapo",MFnNumericData::kFloat,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0);
	 numAttr.setMax(10000.0);

	volumeStepSize=numAttr.create("StepSize","wvstsi",MFnNumericData::kInt,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0);
	 numAttr.setMax(100);

	volumeAdaptive=numAttr.create("Adaptive","wvad",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	volumeOptimize=numAttr.create("Optimize","wvop",MFnNumericData::kBoolean,0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);

	volumeAttMapScale=numAttr.create("AttGridResolution","wvagr",MFnNumericData::kInt,1);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(1);
	 numAttr.setMax(50);

	 volumeSkyST=numAttr.create("Scale","wvsc",MFnNumericData::kDouble,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0001);
	 numAttr.setMax(10.000);

	volumeAlpha=numAttr.create("Alpha","wval",MFnNumericData::kDouble,0.0);
	 numAttr.setKeyable(true);
	 numAttr.setStorable(true);
	 numAttr.setMin(0.0001);
	 numAttr.setMax(10.000);

	//the node needs an output, even we dont need it...
	worldOutput=numAttr.create("WorldSettingOutput","wwso",MFnNumericData::kBoolean);
	numAttr.setDefault(true);
	numAttr.setHidden(true);

	setAttribute();


	return stat;
}