Esempio n. 1
0
MStatus volumeLight::doIt( const MArgList& args )
{
	MStatus stat;

	double arc = 180.0f;
	double coneEndRadius = 0.0f;
	MFnVolumeLight::MLightDirection volumeLightDirection = MFnVolumeLight::kOutward;
	MFnVolumeLight::MLightShape lightShape = MFnVolumeLight::kConeVolume;
	bool emitAmbient = true;

	unsigned	i;

	// Parse the arguments.
	for ( i = 0; i < args.length(); i++ )
	{
		if ( MString( "-a" ) == args.asString( i, &stat )
				&& MS::kSuccess == stat)
		{
			double tmp = args.asDouble( ++i, &stat );
			if ( MS::kSuccess == stat )
				arc = tmp;
		}
		else if ( MString( "-c" ) == args.asString( i, &stat )
				&& MS::kSuccess == stat)
		{
			double tmp = args.asDouble( ++i, &stat );
			if ( MS::kSuccess == stat )
				coneEndRadius = tmp;
		}
		else if ( MString( "-e" ) == args.asString( i, &stat )
				&& MS::kSuccess == stat)
		{
			bool tmp = args.asBool( ++i, &stat );
			if ( MS::kSuccess == stat )
				emitAmbient = tmp;
		}

	}

	MFnVolumeLight light;

	light.create( true, &stat);

	cout<<"What's up?";

	if ( MS::kSuccess != stat )
	{
		cout<<"Error creating light."<<endl;
		return stat;
	}
	
	stat = light.setArc ((float)arc);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error setting \"arc\" attribute."<<endl;
		return stat;
	}

	stat = light.setVolumeLightDirection (volumeLightDirection);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error setting \"volumeLightDirection\" attribute."<<endl;
		return stat;
	}

	stat = light.setConeEndRadius ((float)coneEndRadius);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error setting \"coneEndRadius\" attribute."<<endl;
		return stat;
	}

	stat = light.setEmitAmbient (emitAmbient);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error setting \"emitAmbient\" attribute."<<endl;
		return stat;
	}

	stat = light.setLightShape (lightShape);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error setting \"lightShape\" attribute."<<endl;
		return stat;
	}

	double arcGet = light.arc (&stat);
	if ( MS::kSuccess != stat || arcGet != arc)
	{
		cout<<"Error getting \"arc\" attribute."<<endl;
		return stat;
	}

	MFnVolumeLight::MLightDirection volumeLightDirectionGet = light.volumeLightDirection (&stat);
	if ( MS::kSuccess != stat || volumeLightDirectionGet != volumeLightDirection)
	{
		cout<<"Error getting \"volumeLightDirection\" attribute."<<endl;
		return stat;
	}

	double coneEndRadiusGet = light.coneEndRadius (&stat);
	if ( MS::kSuccess != stat || coneEndRadiusGet != coneEndRadius)
	{
		cout<<"Error getting \"coneEndRadius\" attribute."<<endl;
		return stat;
	}

	bool emitAmbientGet = light.emitAmbient (&stat);
	if ( MS::kSuccess != stat || emitAmbientGet != emitAmbient)
	{
		cout<<"Error getting \"emitAmbient\" attribute."<<endl;
		return stat;
	}

	MFnVolumeLight::MLightShape lightShapeGet = light.lightShape (&stat);
	if ( MS::kSuccess != stat || lightShapeGet != lightShape)
	{
		cout<<"Error getting \"lightShape\" attribute."<<endl;
		return stat;
	}

	// Get reference to the penumbra ramp.
	MRampAttribute ramp = light.penumbraRamp (&stat);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error getting \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	MFloatArray a, b;
	MIntArray c,d;

	// Get the entries in the ramp
	ramp.getEntries (d, a, b, c, &stat);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error getting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	// There should be 2 entries by default.
	if (d.length() != 2)
	{
		cout<<"Invalid number of entries in \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	MFloatArray a1, b1;
	MIntArray c1;

	// Prepare an array of entries to add.
	// In this case we are just adding 1 more entry
	// at position 0.5 with a curve value of 0.25 and a linear interpolation.
	a1.append (0.5f);
	b1.append (0.25f);
	c1.append (MRampAttribute::kLinear);

	// Add it to the curve ramp
	ramp.addEntries (a1, b1, c1, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error adding entries to \"penumbraRamp\" attribute."<<endl;
		return stat;
	}


	// Get the entries to make sure that the above add actually worked.
	MFloatArray a2, b2;
	MIntArray c2,d2;
	ramp.getEntries (d2, a2, b2, c2, &stat);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error getting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	if ( a.length() + a1.length() != a2.length())
	{
		cout<<"Invalid number of entries in \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	// Now try to interpolate the value at a point
	float newVal = -1;
	ramp.getValueAtPosition(.3f, newVal, &stat);

	if ( MS::kSuccess != stat )
	{
		cout<<"Error interpolating value from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	if ( !EQUAL(newVal, .15f))
	{
		cout<<"Invalid interpolation in  \"penumbraRamp\" expected .15 got "<<newVal
			<<" ."<<endl;
	}

	// Try to delete an entry in an incorrect manner. 
	// This delete will work because there is an entry at 0, 
	// However we should never do it this way, because the entries
	// array can become sparse, so trying to delete an entry without 
	// checking whether an entry exists at that index can cause a failure.
	MIntArray entriesToDelete;
	entriesToDelete.append (0);
	ramp.deleteEntries (entriesToDelete, &stat);
	if ( MS::kSuccess != stat )
	{
		cout<<"Error deleting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	// Check to see whether the above delete worked.
	// As mentioned earlier it did work, but we shouldn't do it this way.
	// To illustrate why we shouldn't do it this way, we'll try to delete
	// entry at index 0 ( this no longer exists)
	ramp.getEntries (d2, a2, b2, c2, &stat);

	if ( a2.length() != 2)
	{
		cout<<"Invalid number of entries in \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	// Trying to delete entry at 0.
	entriesToDelete.clear();
	entriesToDelete.append (0);
	ramp.deleteEntries (entriesToDelete, &stat);

	// It will fail because no entry exists.
	if ( MS::kSuccess == stat)
	{
		cout<<"Error deleting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	if ( a2.length() != 2)
	{
		cout<<"Invalid number of entries in \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	// The proper way to delete is to retrieve the index by calling "getEntries"
	ramp.getEntries (d2, a2, b2, c2, &stat);
	entriesToDelete.clear();
	entriesToDelete.append (d2[0]);

	// Delete the first logical entry in the entry array.
	ramp.deleteEntries (entriesToDelete, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error deleting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	// There should be only 1 entry left.
	ramp.getEntries (d2, a2, b2, c2, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error getting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	entriesToDelete.clear();
	entriesToDelete.append (d2[0]);

	// Can't delete the last entry, should return failure.
	ramp.deleteEntries (entriesToDelete, &stat);
	if ( MS::kSuccess == stat)
	{
		cout<<"Error deleting entries from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}

	ramp.setPositionAtIndex (0.0f, d2[0], &stat);
	if ( MS::kSuccess != stat)
	{
		printf("Error setting position at index: %d, of \"penumbraRamp\" attribute.\n", d2[0]);
		return stat;
	}

	ramp.setValueAtIndex (1.0f, d2[0], &stat);
	if ( MS::kSuccess != stat)
	{
		printf("Error setting value at index: %d, of \"penumbraRamp\" attribute.\n", d2[0]);
		return stat;
	}

	ramp.setInterpolationAtIndex (MRampAttribute::kNone, d2[0], &stat);
	if ( MS::kSuccess != stat)
	{
		printf("Error setting interpolation at index: %d, of \"penumbraRamp\" attribute.\n", d2[0]);
		return stat;
	}

  	MRampAttribute ramp2 = light.colorRamp (&stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error getting  \"colorRamp\" attribute."<<endl;
		return stat;
	}	
	MFloatArray a3;
	MColorArray b3;
	MIntArray c3,d3;

  	// Get the entries in the ramp
	ramp2.getEntries (d3, a3, b3, c3, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error getting entries from \"colorRamp\" attribute."<<endl;
		return stat;
	}
	// There should be 2 entries by default.
	if ( d3.length() != 2)
	{
		cout<<"Invalid number of entries in \"colorRamp\" attribute."<<endl;
		return stat;
	}

	MFloatArray a4;
	MColorArray b4;
	MIntArray c4;

	// Prepare an array of entries to add.
	// In this case we are just adding 1 more entry
	// at position 0.5 withe curve value of 0.5 and a linear interpolation.
	a4.append (0.5f);
	b4.append (MColor (0.0f, 0.0f, 0.75f));
	c4.append (MRampAttribute::kLinear);

	// Add it to the curve ramp
	ramp2.addEntries (a4, b4, c4, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error adding entries to \"colorRamp\" attribute."<<endl;
		return stat;
	}
	// Get the entries to make sure that the above add actually worked.
	MFloatArray a5;
	MColorArray b5;
	MIntArray c5,d5;
	ramp2.getEntries (d5, a5, b5, c5, &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error getting entries from \"colorRamp\" attribute."<<endl;
		return stat;
	}
	if (  a3.length() + a4.length() != a5.length())
	{
		cout<<"Invalid number of entries in \"colorRamp\" attribute."<<endl;
		return stat;
	}

	// Now try to interpolate the color at a point
	MColor newCol(0.0, 0.0, 0.0);
	ramp2.getColorAtPosition(.3f, newCol, &stat);

	if ( MS::kSuccess != stat )
	{
		cout<<"Error interpolating color from \"penumbraRamp\" attribute."<<endl;
		return stat;
	}
	if ( !EQUAL(newCol[2], .45))
	{
		cout<<"Invalid color interpolation in  \"colorRamp\" expected .45 got "<<newCol[2]<<endl;
	}

	MColor clr (0.5, 0.5, 0.0);
	ramp2.setColorAtIndex (clr, d5[0], &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error setting color at index: "<<d5[0]
			<<", of \"colorRamp\" attribute."<<endl;
		return stat;
	}

	ramp2.setInterpolationAtIndex (MRampAttribute::kSpline, d5[1], &stat);
	if ( MS::kSuccess != stat)
	{
		cout<<"Error setting interpolation at index: "<<d5[1]
			<<", of \"colorRamp\" attribute."<<endl;
		return stat;
	}

	return stat;
}
Esempio n. 2
0
MStatus testExCameraSetCmd::parseArgs( const MArgList& args)
//
// Parses the command line arguments.
//
{
	MStatus status;

	//	Get the flags.  If the create or help flags are used, return success and ignore the other flags.
	createUsed = (args.flagIndex(kCreateFlag, kCreateFlagLong) != MArgList::kInvalidArgIndex);
	editUsed = (args.flagIndex(kEditFlag, kEditFlagLong) != MArgList::kInvalidArgIndex);
	queryUsed = (args.flagIndex(kQueryFlag, kQueryFlagLong) != MArgList::kInvalidArgIndex);
	helpUsed = (args.flagIndex(kHelpFlag, kHelpFlagLong) != MArgList::kInvalidArgIndex);
	numLayersUsed = (args.flagIndex(kNumLayersFlag, kNumLayersFlagLong) != MArgList::kInvalidArgIndex);

	// If flags are used which require no other information, return now.
	if (createUsed || helpUsed)
		return MS::kSuccess;

	unsigned int maxArg = args.length() - 1;
	unsigned int activeIndex = args.flagIndex(kActiveFlag, kActiveFlagLong);
	unsigned int appendCameraIndex = args.flagIndex(kAppendCameraFlag, kAppendCameraFlagLong);
	unsigned int appendCameraAndSetIndex = args.flagIndex(kAppendCameraAndSetFlag, kAppendCameraAndSetFlagLong);
	unsigned int cameraIndex = args.flagIndex(kCameraFlag, kCameraFlagLong);
	unsigned int deleteLayerIndex = args.flagIndex(kDeleteLayerFlag, kDeleteLayerFlagLong);
	unsigned int layerIndex = args.flagIndex(kLayerFlag, kLayerFlagLong);
	unsigned int layerTypeIndex = args.flagIndex(kLayerTypeFlag, kLayerTypeFlagLong);
	unsigned int setIndex = args.flagIndex(kSetFlag, kSetFlagLong);
	activeUsed = (activeIndex != MArgList::kInvalidArgIndex);
	appendCameraUsed = (appendCameraIndex != MArgList::kInvalidArgIndex);
	appendCameraAndSetUsed = (appendCameraAndSetIndex != MArgList::kInvalidArgIndex);
	cameraUsed = (cameraIndex != MArgList::kInvalidArgIndex);
	deleteLayerUsed = (deleteLayerIndex != MArgList::kInvalidArgIndex);
	layerUsed = (layerIndex != MArgList::kInvalidArgIndex);
	layerTypeUsed = (layerTypeIndex != MArgList::kInvalidArgIndex);
	setUsed = (setIndex != MArgList::kInvalidArgIndex);

	// Process each flag.
	bool maxArgUsed = false;
	if (activeUsed)
	{
		if (editUsed)
		{
			activeVal = args.asBool((activeIndex+1), &status);
			if (status != MS::kSuccess)
			{
				MGlobal::displayError("-active must be either true or false");
				return status;
			}
			if ((layerTypeIndex+1) == maxArg)
				maxArgUsed = true;
		}
	}
	if (appendCameraUsed)
	{
		camName = args.asString((appendCameraIndex+1), &status);
		if (status != MS::kSuccess)
		{
			MGlobal::displayError("-appendCamera must have a valid camera node specified");
			return status;
		}

		if ((appendCameraIndex+1) == maxArg)
			maxArgUsed = true;
	}
	if (appendCameraAndSetUsed)
	{
		camName = args.asString((appendCameraAndSetIndex+1));
		setName = args.asString((appendCameraAndSetIndex+2));
		if ((appendCameraAndSetIndex+2) == maxArg)
			maxArgUsed = true;
	}
	if (cameraUsed)
	{
		if (editUsed)
		{
			camName = args.asString(cameraIndex+1);
			if ((cameraIndex+1) == maxArg)
				maxArgUsed = true;
		}
	}
	if (deleteLayerUsed)
	{
		cameraLayer = args.asInt(deleteLayerIndex+1);
		if ((deleteLayerIndex+1) == maxArg)
			maxArgUsed = true;
	}
	if (layerUsed)
	{
		cameraLayer = args.asInt(layerIndex+1);
		if ((layerIndex+1) == maxArg)
			maxArgUsed = true;
	}
	if (layerTypeUsed)
	{
		if (editUsed)
		{
			layerTypeVal = args.asString(layerTypeIndex+1);
			if ((layerTypeIndex+1) == maxArg)
				maxArgUsed = true;
		}
	}
	if (setUsed)
	{
		if (editUsed)
		{
			setName = args.asString(setIndex+1);
			if ((setIndex+1) == maxArg)
				maxArgUsed = true;
		}
	}

	// If all of the arguments have been used, get the cameraSet node from the selection list.
	// Otherwise, get it from the last argument.
	if (maxArgUsed)
		MGlobal::getActiveSelectionList(list);
	else
		list.add(args.asString(maxArg));

	return MS::kSuccess;
}
Esempio n. 3
0
MStatus unCreateParticleSystem::doIt( const MArgList& args )
{
	bool create = true;

	MSelectionList activeList;
	MStatus stat = MGlobal::getActiveSelectionList(activeList);
	if (MS::kSuccess != stat)
	{
		MessageBox(0,"please select one joint first!",0,0);
		return MS::kFailure;
	}

	if(activeList.length() != 1)
	{
		MessageBox(0,"please select ONLY one joint!",0,0);
		return MS::kFailure;
	}
	MItSelectionList iter(activeList);
	MDagPath dagPath;
	for ( ; !iter.isDone(); iter.next())
	{
		stat = iter.getDagPath(dagPath);
		break;
	}
	if(!stat)
	{
		MessageBox(0,"can't getDagPath!",0,0);
		return MS::kFailure;
	}

	if(!dagPath.hasFn(MFn::kJoint))
	{
		MessageBox(0,"muse select joint node!",0,0);
		return MS::kFailure;
	}

	MFnIkJoint joint(dagPath);

	if(args.length())
		create = args.asBool(0);

	if(!create)
	{
		if(!joint.hasAttribute("unParticleEnabled"))
		{
			MessageBox(0,"no particle system exists!",0,0);
			return MS::kFailure;
		}
		removeParticleAttributes(joint);
		return MS::kSuccess;
	}

	if(joint.hasAttribute("unParticleEnabled"))
	{
		MessageBox(0,"particle system already exists!",0,0);
		return MS::kSuccess;
	}

	if(joint.hasAttribute("unRibbonEnabled"))
	{
		if(MessageBox(0,"will delete ribbon system and attach a particle system to the joint,continue?",0,MB_YESNO) == IDNO)return MS::kFailure;
		removeRibbonAttributes(joint);
	}

	MFnNumericAttribute attr;
	unParticleEnabled = attr.create("unParticleEnabled","Enabled",MFnNumericData::kBoolean,true);
	attr.setStorable(true);

	unParticleVisible = attr.create("unParticleVisible","Visible",MFnNumericData::kBoolean,true);
	attr.setStorable(true);
	attr.setKeyable(true);

	unParticleSpeed = attr.create("unParticleSpeed","Speed",MFnNumericData::kFloat,40.0f);
	attr.setStorable(true);
	attr.setMin(-1000.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	unParticleVariation = attr.create("unParticleVariationPercent","VariationPercent",MFnNumericData::kFloat,2.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(100.0f);
	attr.setKeyable(true);

	unParticleConeAngle = attr.create("unParticleConeAngle","ConeAngle",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(180.0f);
	attr.setKeyable(true);

	unParticleGravity = attr.create("unParticleGravity","Gravity",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-1000.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	unParticleExplosiveForce = attr.create("unParticleExplosiveForce","ExplosiveForce",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-100.0f);
	attr.setMax(100.0f);
	attr.setKeyable(true);

	unParticleLife = attr.create("unParticleLife","Life",MFnNumericData::kFloat,1.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1000.0f);

	unParticleLifeVariation = attr.create("unParticleLifeVariation","LifeVar",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-16.0f);
	attr.setMax(16.0f);

	unParticleEmissionRate = attr.create("unParticleEmissionRate","EmissionRate",MFnNumericData::kFloat,50.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	//版本号17加入,初始粒子数
	unParticleInitialNum = attr.create("unParticleInitialNum","InitialNum",MFnNumericData	::kShort,0);
	attr.setStorable(true);
	attr.setMin(0);
	attr.setMax(512);

	//版本号11加入,最大粒子数
	unParticleLimitNum = attr.create("unParticleLimitNum","LimitNum",MFnNumericData	::kShort,32);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(512);

	//版本号13加入,粒子全部跟随发射点
	unParticleAttachToEmitter = attr.create("unParticleAttachToEmitter","AttachToEmitter",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	//版本号18加入,粒子跟随发射点移动
	unParticleMoveWithEmitter = attr.create("unParticleMoveWithEmitter","MoveWithEmitter",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	//版本号23加入,粒子指向速度方向
	unParticleForTheSword = attr.create("unParticleForTheSword","ForTheSword",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	//版本号24加入,粒子指向速度方向,提供一个角度供初始化
	unParticleForTheSwordInitialAngle = attr.create("unParticleForTheSwordInitialAngle","ForTheSwordInitialAngle",MFnNumericData::kFloat,0);
	attr.setStorable(true);
	attr.setMin(-180.0f);
	attr.setMax(180.0f);

	//版本号25,Wander
	unParticleWander = attr.create("unParticleWander","Wander",MFnNumericData::kBoolean,false);
	attr.setStorable(true);
	//版本号25,WanderRadius
	unParticleWanderRadius = attr.create("unParticleWanderRadius","WanderRadius",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1024.0f);
	//版本号25,WanderSpeed
	unParticleWanderSpeed = attr.create("unParticleWanderSpeed","WanderSpeed",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(16.0f);

	unParticleAspectRatio = attr.create("unParticleAspectRatio","AspectRatio",MFnNumericData::kFloat,1.0f);
	attr.setStorable(true);
	attr.setMin(0.0625f);
	attr.setMax(16.0f);

	unParticleInitialAngleBegin = attr.create("unParticleInitialAngleBegin","InitialAngleBegin",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-180.0f);
	attr.setMax(180.0f);

	unParticleInitialAngleEnd = attr.create("unParticleInitialAngleEnd","InitialAngleEnd",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-180.0f);
	attr.setMax(180.0f);

	unParticleRotationSpeed = attr.create("unParticleRotationSpeed","RotationSpeed",MFnNumericData::kFloat,0);
	attr.setStorable(true);
	attr.setMin(-64.0f);	//原来默认为16,鲍振伟要求改大
	attr.setMax(64.0f);

	unParticleRotationSpeedVar = attr.create("unParticleRotationSpeedVar","RotationSpeedVar",MFnNumericData::kFloat,0);
	attr.setStorable(true);
	attr.setMin(0);
	attr.setMax(64);

	unParticleEmitterWidth = attr.create("unParticleEmitterWidth","EmitterWidth",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	unParticleEmitterLength = attr.create("unParticleEmitterLength","EmitterLength",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	unParticleEmitterHeight = attr.create("unParticleEmitterHeight","EmitterHeight",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1000.0f);
	attr.setKeyable(true);

	MFnEnumAttribute eAttr;
	unParticleBlendMode = eAttr.create("unParticleBlendMode","BlendMode",3);
	eAttr.setStorable(true);
	eAttr.addField("Opaque",0);
	eAttr.addField("Transparent",1);
	eAttr.addField("AlphaBlend",2);
	eAttr.addField("Additive",3);
	eAttr.addField("AdditiveAlpha",4);
	eAttr.addField("Modulate",5);

	/*unParticleBlendModeSrc = eAttr.create("unParticleBlendModeSrc","BlendModeSrc",3);
	eAttr.setStorable(true);
	eAttr.addField("SBF_ONE",0);
	eAttr.addField("SBF_ZERO",1);
	eAttr.addField("SBF_DEST_COLOR",2);
	eAttr.addField("SBF_SOURCE_COLOR",3);
	eAttr.addField("SBF_ONE_MINUS_DEST_COLOR",4);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_COLOR",5);
	eAttr.addField("SBF_DEST_ALPHA",6);
	eAttr.addField("SBF_SOURCE_ALPHA",7);
	eAttr.addField("SBF_ONE_MINUS_DEST_ALPHA",8);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_ALPHA",9);

	unParticleBlendModeDst = eAttr.create("unParticleBlendModeDst","BlendModeDst",0);
	eAttr.setStorable(true);
	eAttr.addField("SBF_ONE",0);
	eAttr.addField("SBF_ZERO",1);
	eAttr.addField("SBF_DEST_COLOR",2);
	eAttr.addField("SBF_SOURCE_COLOR",3);
	eAttr.addField("SBF_ONE_MINUS_DEST_COLOR",4);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_COLOR",5);
	eAttr.addField("SBF_DEST_ALPHA",6);
	eAttr.addField("SBF_SOURCE_ALPHA",7);
	eAttr.addField("SBF_ONE_MINUS_DEST_ALPHA",8);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_ALPHA",9);*/

	unParticleTextureFilename = attr.createColor("unParticleTextureFilename","TextureFilename");
	attr.setStorable(true);

	unParticleTextureRows = attr.create("unParticleTextureRows","TextureRows",MFnNumericData::kShort,1);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(16);

	unParticleTextureCols = attr.create("unParticleTextureCols","TextureCols",MFnNumericData::kShort,1);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(16);

	unParticleTextureChangeStyle = eAttr.create("unParticleTextureChangeStyle","TextureChangeStyle",0);
	eAttr.setStorable(true);
	eAttr.addField("Sequence",0);
	eAttr.addField("Random",1);

	unParticleTextureChangeInterval = attr.create("unParticleTextureChangeInterval","TextureChangeInterval",MFnNumericData::kShort,30);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(5000);

	unParticleTailLength = attr.create("unParticleTailLength","TailLength",MFnNumericData::kFloat,1.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(10.0f);

	unParticleTimeMiddle = attr.create("unParticleTimeMiddle","TimeMiddle",MFnNumericData::kFloat,0.3f);
	attr.setStorable(true);
	attr.setMin(0.05f);
	attr.setMax(0.95f);

	unParticleColorStart = attr.createColor("unParticleColorStart","ColorStart");
	attr.setStorable(true);
	attr.setDefault(1.0f,1.0f,1.0f);

	unParticleColorMiddle = attr.createColor("unParticleColorMiddle","ColorMiddle");
	attr.setStorable(true);
	attr.setDefault(1.0f,1.0f,1.0f);

	unParticleColorEnd = attr.createColor("unParticleColorEnd","ColorEnd");
	attr.setStorable(true);
	attr.setDefault(1.0f,1.0f,1.0f);

	unParticleAlpha = attr.create("unParticleAlpha","Alpha",MFnNumericData::k3Float);
	attr.setStorable(true);
	attr.setDefault(1.0f,1.0f,0.0f);
	attr.setMin(0.0f,0.0f,0.0f);
	attr.setMax(1.0f,1.0f,1.0f);

	unParticleScale = attr.create("unParticleScale","Scale",MFnNumericData::k3Float);
	attr.setStorable(true);
	attr.setDefault(10.0f,10.0f,10.0f);
	attr.setMin(0.001f,0.001f,0.001f);
	attr.setMax(1500.0f,1500.0f,1500.0f);	//原来是500,鲍振伟要求改大

	unParticleScaleVar = attr.create("unParticleScaleVar","ScaleVar",MFnNumericData::k3Float);
	attr.setStorable(true);
	attr.setDefault(0.0f,0.0f,0.0f);
	attr.setMin(0.0f,0.0f,0.0f);
	attr.setMax(500.0f,500.0f,500.0f);//原来是100,鲍振伟要求改大

	unParticleFixedSize = attr.create("unParticleFixedSize","FixedSize",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	unParticleHeadLifeSpan = attr.create("unParticleHeadLifeSpan","HeadLifeSpan",MFnNumericData::k3Short);
	attr.setStorable(true);
	attr.setDefault(0,0,1);
	attr.setMin(0,0,1);
	attr.setMax(255,255,255);

	unParticleHeadDecay = attr.create("unParticleHeadDecay","HeadDecay",MFnNumericData::k3Short);
	attr.setStorable(true);
	attr.setDefault(0,0,1);
	attr.setMin(0,0,1);
	attr.setMax(255,255,255);

	unParticleTailLifeSpan = attr.create("unParticleTailLifeSpan","TailLifeSpan",MFnNumericData::k3Short);
	attr.setStorable(true);
	attr.setDefault(0,0,1);
	attr.setMin(0,0,1);
	attr.setMax(255,255,255);

	unParticleTailDecay = attr.create("unParticleTailDecay","TailDecay",MFnNumericData::k3Short);
	attr.setStorable(true);
	attr.setDefault(0,0,1);
	attr.setMin(0,0,1);
	attr.setMax(255,255,255);

	unParticleHead = attr.create("unParticleHead","Head",MFnNumericData::kBoolean,true);
	attr.setStorable(true);

	unParticleTail = attr.create("unParticleTail","Tail",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	unParticleUnShaded = attr.create("unParticleUnShaded","UnShaded",MFnNumericData::kBoolean,true);
	attr.setStorable(true);

	unParticleUnFogged = attr.create("unParticleUnFogged","UnFogged",MFnNumericData::kBoolean,true);
	attr.setStorable(true);

	unParticleBlockByY0 = attr.create("unParticleBlockByY0","blockByY0",MFnNumericData::kBoolean,false);
	attr.setStorable(true);

	addParticleAttributes(joint);

	return MS::kSuccess;
}
Esempio n. 4
0
MStatus unCreateRibbonSystem::doIt( const MArgList& args )
{
	bool create = true;

	MSelectionList activeList;
	MStatus stat = MGlobal::getActiveSelectionList(activeList);
	if (MS::kSuccess != stat)
	{
		MessageBox(0,"please select one joint first!",0,0);
		return MS::kFailure;
	}

	if(activeList.length() != 1)
	{
		MessageBox(0,"please select ONLY one joint!",0,0);
		return MS::kFailure;
	}
	MItSelectionList iter(activeList);
	MDagPath dagPath;
	for ( ; !iter.isDone(); iter.next())
	{
		stat = iter.getDagPath(dagPath);
		break;
	}
	if(!stat)
	{
		MessageBox(0,"can't getDagPath!",0,0);
		return MS::kFailure;
	}

	if(!dagPath.hasFn(MFn::kJoint))
	{
		MessageBox(0,"muse select joint node!",0,0);
		return MS::kFailure;
	}

	MFnIkJoint joint(dagPath);

	if(args.length())
		create = args.asBool(0);

	if(!create)
	{
		if(!joint.hasAttribute("unRibbonEnabled"))
		{
			MessageBox(0,"no ribbon system exists!",0,0);
			return MS::kFailure;
		}
		removeRibbonAttributes(joint);
		return MS::kSuccess;
	}

	if(joint.hasAttribute("unRibbonEnabled"))
	{
		MessageBox(0,"ribbon system already exists!",0,0);
		return MS::kSuccess;
	}

	if(joint.hasAttribute("unParticleEnabled"))
	{
		if(MessageBox(0,"will delete particle system and attach a ribbon system to the joint,continue?",0,MB_YESNO) == IDNO)return MS::kFailure;
		removeParticleAttributes(joint);
	}

	MFnNumericAttribute attr;
	unRibbonEnabled = attr.create("unRibbonEnabled","enabled",MFnNumericData::kBoolean,true);
	attr.setStorable(true);
	unRibbonVisible = attr.create("unRibbonVisible","visible",MFnNumericData::kBoolean,true);
	attr.setStorable(true);
	attr.setKeyable(true);
	unRibbonAbove = attr.create("unRibbonAbove","above",MFnNumericData::kFloat,20.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(5000.0f);
	attr.setKeyable(true);
	unRibbonBelow = attr.create("unRibbonBelow","below",MFnNumericData::kFloat,20.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(5000.0f);
	attr.setKeyable(true);
	unRibbonEdgesPerSecond = attr.create("unRibbonEdgesPerSecond","EdgePerSec",MFnNumericData::kShort,10);
	attr.setStorable(true);
	attr.setMin(0);
	attr.setMax(100);
	unRibbonEdgeLife = attr.create("unRibbonEdgeLife","EdgeLife",MFnNumericData::kFloat,2.0f);
	attr.setStorable(true);
	attr.setMin(0.001f);
	attr.setMax(100.0f);
	unRibbonGravity = attr.create("unRibbonGravity","Gravity",MFnNumericData::kFloat,0.0f);
	attr.setStorable(true);
	attr.setMin(-1000.0f);
	attr.setMax(1000.0f);
	unRibbonTextureRows = attr.create("unRibbonTextureRows","TextureRows",MFnNumericData::kShort,1);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(16);
	unRibbonTextureCols = attr.create("unRibbonTextureCols","TextureCols",MFnNumericData::kShort,1);
	attr.setStorable(true);
	attr.setMin(1);
	attr.setMax(16);
	unRibbonTextureSlot = attr.create("unRibbonTextureSlot","TextureSlot",MFnNumericData::kShort,0);
	attr.setStorable(true);
	attr.setMin(0);
	attr.setMax(255);
	attr.setKeyable(true);
	unRibbonVertexColor = attr.create("unRibbonVertexColor","VertexColor",MFnNumericData::k3Float);
	attr.setStorable(true);
	attr.setDefault(1.0f,0.0f,0.0f);
	attr.setUsedAsColor(true);
	attr.setKeyable(true);
	unRibbonVertexAlpha = attr.create("unRibbonVertexAlpha","VertexAlpha",MFnNumericData::kFloat,1.0f);
	attr.setStorable(true);
	attr.setMin(0.0f);
	attr.setMax(1.0f);
	attr.setKeyable(true);
	MFnEnumAttribute eAttr;
	unRibbonBlendMode = eAttr.create("unRibbonBlendMode","BlendMode",3);
	eAttr.setStorable(true);
	eAttr.addField("Opaque",0);
	eAttr.addField("Transparent",1);
	eAttr.addField("AlphaBlend",2);
	eAttr.addField("Additive",3);
	eAttr.addField("AdditiveAlpha",4);
	eAttr.addField("Modulate",5);
	{
		MFnEnumAttribute eAttr;
		unRibbonWanderMode = eAttr.create("unRibbonWanderMode","WanderMode",0);
		eAttr.setStorable(true);
		eAttr.addField("0",0);
		eAttr.addField("1",1);
	}
	/*unRibbonBlendModeSrc = eAttr.create("unRibbonBlendModeSrc","BlendModeSrc",3);
	eAttr.setStorable(true);
	eAttr.addField("SBF_ONE",0);
	eAttr.addField("SBF_ZERO",1);
	eAttr.addField("SBF_DEST_COLOR",2);
	eAttr.addField("SBF_SOURCE_COLOR",3);
	eAttr.addField("SBF_ONE_MINUS_DEST_COLOR",4);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_COLOR",5);
	eAttr.addField("SBF_DEST_ALPHA",6);
	eAttr.addField("SBF_SOURCE_ALPHA",7);
	eAttr.addField("SBF_ONE_MINUS_DEST_ALPHA",8);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_ALPHA",9);
	unRibbonBlendModeDst = eAttr.create("unRibbonBlendModeDst","BlendModeDst",0);
	eAttr.setStorable(true);
	eAttr.addField("SBF_ONE",0);
	eAttr.addField("SBF_ZERO",1);
	eAttr.addField("SBF_DEST_COLOR",2);
	eAttr.addField("SBF_SOURCE_COLOR",3);
	eAttr.addField("SBF_ONE_MINUS_DEST_COLOR",4);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_COLOR",5);
	eAttr.addField("SBF_DEST_ALPHA",6);
	eAttr.addField("SBF_SOURCE_ALPHA",7);
	eAttr.addField("SBF_ONE_MINUS_DEST_ALPHA",8);
	eAttr.addField("SBF_ONE_MINUS_SOURCE_ALPHA",9);*/
	unRibbonTextureFilename = attr.createColor("unRibbonTextureFilename","TextureFilename");
	attr.setStorable(true);

	addRibbonAttributes(joint);

	return MS::kSuccess;
}
Esempio n. 5
0
MStatus pointOnMeshCommand::doIt(const MArgList& args)

{

    // INITIALIZE PRIVATE DATA FOR THE COMMAND:

    nodeCreated = positionSpecified = normalSpecified = faceIndexSpecified = relativeSpecified = parameterUSpecified = parameterVSpecified = false;

    meshNodeName = pointOnMeshInfoName = "";



    // PARSE THE COMMAND'S ARGUMENTS:

    for (unsigned i=0; i<args.length(); i++)

    {

        if ((MString("-name")==args.asString(i)) || (MString("-na")==args.asString(i)))

            pointOnMeshInfoName = args.asString(++i);

        else if ((MString("-position")==args.asString(i)) || (MString("-p")==args.asString(i)))

            positionSpecified = true;

        else if ((MString("-normal")==args.asString(i)) || (MString("-nr")==args.asString(i)))

            normalSpecified = true;

        else if ((MString("-faceIndex")==args.asString(i)) || (MString("-f")==args.asString(i)))

        {

            faceIndexSpecified = true;

            int temp = args.asInt(++i);

            if (temp<0)

            {

                displayError("Invalid faceIndex!");

                return MS::kFailure;

            }

            faceIndex = temp;

        }

        else if ((MString("-relative")==args.asString(i)) || (MString("-r")==args.asString(i)))

        {

            relativeSpecified = true;

            relative = args.asBool(++i);

        }

        else if ((MString("-parameterU")==args.asString(i)) || (MString("-u")==args.asString(i)))

        {

            parameterUSpecified = true;

            double temp = args.asDouble(++i);

            if ((temp<0) || (temp>1))

            {

                displayError("Invalid parameterU!");

                return MS::kFailure;

            }

            parameterU = temp;

        }

        else if ((MString("-parameterV")==args.asString(i)) || (MString("-v")==args.asString(i)))

        {

            parameterVSpecified = true;

            double temp = args.asDouble(++i);

            if ((temp<0) || (temp>1))

            {

                displayError("Invalid parameterV!");

                return MS::kFailure;

            }

            parameterV = temp;

        }

        else if (i==(args.length()-1))

            meshNodeName = args.asString(i);

        else

        {

            MString errorMessage = "Invalid flag: ";

            errorMessage += args.asString(i);

            displayError(errorMessage);

            return MS::kFailure;

        }

    }



    // MAKE SURE UNSPECIFIED INPUT PARAMETER FLAGS GET DEFAULT VALUES:

    if (!faceIndexSpecified)

        faceIndex = 0;

    if (!relativeSpecified)

        relative = true;

    if (!parameterUSpecified)

        parameterU = 0.5;

    if (!parameterVSpecified)

        parameterV = 0.5;



    // DO THE WORK:

    return redoIt();

}