void DocumentExporter::saveParamClip()
	{
		int length = 0;
		
		MItDependencyNodes CharacterItr(MFn::kCharacter);
		for (int i1 = 0; !CharacterItr.isDone(); CharacterItr.next(), i1++)
		{
			MFnCharacter character;
			if (!character.setObject(CharacterItr.item())) continue;

			MPlugArray array;
			character.getMemberPlugs(array);

			length = array.length();
		}

		MIntArray  arrayChannelAttribute(length, 0);


		MItDependencyNodes clipItr(MFn::kClip);
		MFnClip clipFn;
		for (int i1 = 0; !clipItr.isDone(); clipItr.next(), i1++)
		{

			if (!clipFn.setObject(clipItr.item())) continue;

			// save original param
			MIntArray  arrayOriginalChannelAttribute(length);
			clipFn.getAbsoluteChannelSettings(arrayOriginalChannelAttribute);
			ParamClipVec.push_back(arrayOriginalChannelAttribute);

			// set relativeClip on
			clipFn.setAbsoluteChannelSettings(arrayChannelAttribute);
		}
	}
Exemple #2
0
MStatus createClip::doIt( const MArgList& args )
{
	// parse the command arguments
	//
	MStatus stat = parseArgs(args);
	if (stat != MS::kSuccess) {
		return stat;
	}
	
	unsigned int count = 0;

	// if the character flag was used, create the clip on the specified
	// character, otherwise, create a character
	//
	MFnCharacter fnCharacter;
	if (fCharacter.isNull()) {
		MSelectionList activeList;
		MGlobal::getActiveSelectionList (activeList);
		if (0 == activeList.length()) {
			MString errMsg("No character was specified, and no objects were selected.");
			displayError(errMsg);
			return MS::kFailure;
		}
		// create a character using the selection list
		//
		fCharacter = fnCharacter.create(activeList,MFnSet::kNone,&stat);
		if (stat != MS::kSuccess) {
			MString errMsg("Failed to create character using the selection.");
			displayError(errMsg);
			return MS::kFailure;
		}
	} else {
		fnCharacter.setObject(fCharacter);
	}

	// Get the array of members of the character. We will create a clip
	// for them.
	//
	MPlugArray plugs;
	fnCharacter.getMemberPlugs(plugs);

	// Now create a animCurves to use as a clip for the character.
	// The curves will be set up between frames 0 and 10;
	//
	MTime start(0.0);
	MTime duration(10.0);
	MObjectArray clipCurves;
	
	for (count = 0; count < plugs.length(); ++count) {
		// Now create a bunch of animCurves to use as a clip for the
		// character
		//
		MFnAnimCurve fnCurve;
//		AnimCurveType plugType = fnCurve.timedAnimCurveTypeForPlug(plugs[count]);
		MObject curve = fnCurve.create(MFnAnimCurve::kAnimCurveTL); // plugType);
		fnCurve.addKeyframe(start,5.0);
		fnCurve.addKeyframe(duration,15.0);
		clipCurves.append(curve);
	}
	
	// Create a source clip node and add the animation to it
	//
	MFnClip fnClipCreate;
	MObject sourceClip = fnClipCreate.createSourceClip(start,duration,fMod,&stat);
	fnCharacter.attachSourceToCharacter(sourceClip,fMod);	
	for (count = 0; count < plugs.length(); ++count) {
		MPlug animPlug = plugs[count];
		fnCharacter.addCurveToClip(clipCurves[count],sourceClip,animPlug,fMod);
	}

	// instance the clip
	//
	MTime schedStart(15.0);
	MObject instancedClip = fnClipCreate.createInstancedClip(sourceClip,
															 schedStart,
															 fMod,
															 &stat);
	fnCharacter.attachInstanceToCharacter(instancedClip,fMod);

	// instance the clip a second time, at time 30
	//
	schedStart.setValue(30.0);
	MObject instancedClip2 = fnClipCreate.createInstancedClip(sourceClip,
															  schedStart,
															  fMod,
															  &stat);
	fnCharacter.attachInstanceToCharacter(instancedClip2,fMod);

	return stat;
}