void NifKFAnimationImporter::ImportAnimation( NiInterpolatorRef interpolator,MString& targetObject ) {
	MObject object = this->GetObjectByName(targetObject);

	if(object.isNull()) {
		return;
	}

	vector<Key<Vector3>> translationKeys;
	vector<Key<float>> scaleKeys;
	vector<Key<Quaternion>> rotationQuaternionKeys;

	vector<Key<float>> rotationXKeys;
	vector<Key<float>> rotationYKeys;
	vector<Key<float>> rotationZKeys;
	
	MFnTransform transformNode(object);
	MPlug plug = transformNode.findPlug("interpolatorType");
	MString node_name = transformNode.name();
	MString mel_command = "addAttr -dataType \"string\" -shortName \"interpolatorType\" ";

	if(plug.isNull()) {	
		MGlobal::executeCommand(mel_command + node_name);
	}

	if(interpolator->GetType().IsSameType(NiTransformInterpolator::TYPE)) {
		NiTransformInterpolatorRef transformInterpolator = DynamicCast<NiTransformInterpolator>(interpolator);

		NiTransformDataRef transformData = transformInterpolator->GetData();

		if(transformData != NULL) {
			if(transformData->GetRotateType() == KeyType::XYZ_ROTATION_KEY) {
				rotationXKeys = transformData->GetXRotateKeys();
				rotationYKeys = transformData->GetYRotateKeys();
				rotationZKeys = transformData->GetZRotateKeys();
			} else {
				rotationQuaternionKeys = transformData->GetQuatRotateKeys();
			}

			translationKeys = transformData->GetTranslateKeys();
			scaleKeys = transformData->GetScaleKeys();
		}

		mel_command = "setAttr -type \"string\" ";
		MGlobal::executeCommand(mel_command + node_name + "\.interpolatorType \"NiTransformInterpolator\"");
	}
void TR_ExpressionsSimplification::tranformStoreMotionCandidate(TR::TreeTop *treeTop, bool *isPreheaderBlockInvalid)
   {
   TR::Node *node = treeTop->getNode();

   TR_ASSERT(node->getOpCode().isStore() && !node->getSymbol()->isStatic() && !node->getSymbol()->holdsMonitoredObject(),
      "node %p was expected to be a non-static non-monitored object store and was not.", node);

   // this candidate should be valid, either direct or indirect

   if (trace())
      comp()->getDebug()->print(comp()->getOutFile(), node, 0, true);

   TR::Block *entryBlock = _currentRegion->getEntryBlock();
   TR::Block *preheaderBlock = findPredecessorBlock(entryBlock);

   if (!preheaderBlock)
      {
      if (trace())
         traceMsg(comp(), "Fail to find a place to put the hoist code in\n");
      *isPreheaderBlockInvalid = true;
      return;
      }

   // Earlier post-dominance test ensures that the loop is executed as least once, or is canonicalized.
   // but to be safe we still perform on canonicalized loops only.
   if (_currentRegion->isCanonicalizedLoop())  // make sure that the loop is canonicalized, in which case the preheader is
      {                                        // executed in its first iteration and is protected.
      if (performTransformation(comp(), "%sMove out loop-invariant store [%p] to block_%d\n", OPT_DETAILS, node, preheaderBlock->getNumber()))
         {
         TR::Node *newNode = node->duplicateTree();
         transformNode(newNode, preheaderBlock);
         TR::TransformUtil::removeTree(comp(), treeTop);
         }
      }
   else
      {
      if (trace())
         traceMsg(comp(), "No canonicalized loop for this candidate\n");
      }
   }
Beispiel #3
0
void OpenNISkeleton::update()
{
    if (trackedUser != NULL)
    {
        transformNode(0, XN_SKEL_TORSO);
        transformNode(1, XN_SKEL_WAIST);
        transformNode(2, XN_SKEL_LEFT_SHOULDER);
        transformNode(3, XN_SKEL_RIGHT_SHOULDER);
        transformNode(4, XN_SKEL_LEFT_ELBOW);
        transformNode(5, XN_SKEL_RIGHT_ELBOW);
        transformNode(6, XN_SKEL_LEFT_HIP);
        transformNode(7, XN_SKEL_RIGHT_HIP);
        transformNode(8, XN_SKEL_LEFT_KNEE);
        transformNode(9, XN_SKEL_RIGHT_KNEE);
        transformNode(10, XN_SKEL_NECK);
    }
}
bool TR_ExpressionsSimplification::tranformSummationReductionCandidate(TR::TreeTop *treeTop, LoopInfo *loopInfo, bool *isPreheaderBlockInvalid)
   {
   TR::Node *node = treeTop->getNode();
   TR::Node *opNode = node->getFirstChild();
   TR::Node *expNode = NULL;
   int32_t expChildNumber = 0;
   bool removeOnly = false;
   bool replaceWithNewNode = false;

   if (opNode->getOpCodeValue() == TR::iadd || opNode->getOpCodeValue() == TR::isub)
      {
      if (opNode->getSecondChild()->getOpCode().hasSymbolReference() &&
            node->getSymbolReference() == opNode->getSecondChild()->getSymbolReference())
         {
         expChildNumber = 0;
         expNode = opNode->getFirstChild();
         }
      else
         {
         expChildNumber = 1;
         expNode = opNode->getSecondChild();
         }
      expNode = iaddisubSimplifier(expNode, loopInfo);
      replaceWithNewNode = true;
      }
   else if (opNode->getOpCodeValue() == TR::ixor || opNode->getOpCodeValue() == TR::ineg)
      {
      expNode = ixorinegSimplifier(opNode, loopInfo, &removeOnly);
      }

   if (expNode)
      {
      if (trace())
         comp()->getDebug()->print(comp()->getOutFile(), expNode, 0, true);

      TR::Block *entryBlock = _currentRegion->getEntryBlock();
      TR::Block *preheaderBlock = findPredecessorBlock(entryBlock);

      if (!preheaderBlock)
         {
         if (trace())
            traceMsg(comp(), "Fail to find a place to put the hoist code in\n");
         *isPreheaderBlockInvalid = true;
         return true;
         }

      if (loopInfo->getNumIterations() > 0 ||     // make sure that the loop is going to be executed at least once
            _currentRegion->isCanonicalizedLoop())  // or that the loop is canonicalized, in which case the preheader is
         {                                        // executed in its first iteration and is protected.
         if (performTransformation(comp(), "%sMove out loop-invariant node [%p] to block_%d\n", OPT_DETAILS, node, preheaderBlock->getNumber()))
            {
            if (!(removeOnly))
               {
               TR::Node *newNode = node->duplicateTree();
               if (replaceWithNewNode)
                  newNode->getFirstChild()->setAndIncChild(expChildNumber, expNode);
               transformNode(newNode, preheaderBlock);
               }
            TR::TransformUtil::removeTree(comp(), treeTop);
            }
         }
      }
      return (expNode != NULL);
   }
Beispiel #5
0
void testApp::update()
{
	static bool lastRecording = false;

	context.update();
	depth.update();
	user.update();

	if (recording)
	{
		recorder.update();
	}

	if (recording != lastRecording)
	{
		if (recording)
		{
			recorder.startRecord("recording-" + timeStamp() + ".oni");
		}
		else
		{
			recorder.stopRecord();
		}
	}
	lastRecording = recording;

	XnUserID userId = user.getTrackedUser(1)->id;

	xn::SkeletonCapability pUserSkel = user.getXnUserGenerator().GetSkeletonCap();
	if (pUserSkel.IsTracking(userId))
	{
        transformNode(0, XN_SKEL_TORSO);
        transformNode(1, XN_SKEL_WAIST);
        transformNode(2, XN_SKEL_LEFT_SHOULDER);
        transformNode(3, XN_SKEL_RIGHT_SHOULDER);
        transformNode(4, XN_SKEL_LEFT_ELBOW);
        transformNode(5, XN_SKEL_RIGHT_ELBOW);
        transformNode(6, XN_SKEL_LEFT_HIP);
        transformNode(7, XN_SKEL_RIGHT_HIP);
        transformNode(8, XN_SKEL_LEFT_KNEE);
        transformNode(9, XN_SKEL_RIGHT_KNEE);
        transformNode(10, XN_SKEL_NECK);
    }
}
Beispiel #6
0
MStatus swissArmyLocatorManip::connectToDependNode(const MObject &node)
{
    MStatus stat;

	// Get the DAG path
	//
	MFnDagNode dagNodeFn(node);
	dagNodeFn.getPath(fNodePath);
	MObject parentNode = dagNodeFn.parent(0);
	MFnDagNode parentNodeFn(parentNode);

    // Connect the plugs
    //    
    MFnDependencyNode nodeFn;
    nodeFn.setObject(node);    

	// FreePointTriadManip
	//
    MFnFreePointTriadManip freePointTriadManipFn(fFreePointTriadManip);
	MPlug translationPlug = parentNodeFn.findPlug("t", &stat);
    if (MStatus::kFailure != stat) {
	    freePointTriadManipFn.connectToPointPlug(translationPlug);
	}

	// DirectionManip
	//
    MFnDirectionManip directionManipFn;
    directionManipFn.setObject(fDirectionManip);
	MPlug directionPlug = nodeFn.findPlug("arrow2Direction", &stat);
    if (MStatus::kFailure != stat) {
	    directionManipFn.connectToDirectionPlug(directionPlug);
		unsigned startPointIndex = directionManipFn.startPointIndex();
	    addPlugToManipConversionCallback(startPointIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// DistanceManip
	//
    MFnDistanceManip distanceManipFn;
    distanceManipFn.setObject(fDistanceManip);
	MPlug sizePlug = nodeFn.findPlug("size", &stat);
    if (MStatus::kFailure != stat) {
	    distanceManipFn.connectToDistancePlug(sizePlug);
		unsigned startPointIndex = distanceManipFn.startPointIndex();
	    addPlugToManipConversionCallback(startPointIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// CircleSweepManip
	//
	MFnCircleSweepManip circleSweepManipFn(fCircleSweepManip);
	MPlug arrow1AnglePlug = nodeFn.findPlug("arrow1Angle", &stat);
    if (MStatus::kFailure != stat) {
	    circleSweepManipFn.connectToAnglePlug(arrow1AnglePlug);
		unsigned centerIndex = circleSweepManipFn.centerIndex();
	    addPlugToManipConversionCallback(centerIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// DiscManip
	//
	MFnDiscManip discManipFn(fDiscManip);
	MPlug arrow3AnglePlug = nodeFn.findPlug("arrow3Angle", &stat);
    if (MStatus::kFailure != stat) {
	    discManipFn.connectToAnglePlug(arrow3AnglePlug);
		unsigned centerIndex = discManipFn.centerIndex();
	    addPlugToManipConversionCallback(centerIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// StateManip
	//
	MFnStateManip stateManipFn(fStateManip);

	MPlug statePlug = nodeFn.findPlug("state", &stat);
    if (MStatus::kFailure != stat) {
	    stateManipFn.connectToStatePlug(statePlug);
		unsigned positionIndex = stateManipFn.positionIndex();
	    addPlugToManipConversionCallback(positionIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// ToggleManip
	//
	MFnToggleManip toggleManipFn(fToggleManip);

	MPlug togglePlug = nodeFn.findPlug("toggle", &stat);
    if (MStatus::kFailure != stat) {
	    toggleManipFn.connectToTogglePlug(togglePlug);
		unsigned startPointIndex = toggleManipFn.startPointIndex();
	    addPlugToManipConversionCallback(startPointIndex, 
										 (plugToManipConversionCallback) 
										 &swissArmyLocatorManip::startPointCallback);
	}

	// Determine the transform node for the locator
	//
	MDagPath transformPath(fNodePath);
	transformPath.pop();

	MFnTransform transformNode(transformPath);

	// RotateManip
	//
	MFnRotateManip rotateManipFn(fRotateManip);

	MPlug rotatePlug = transformNode.findPlug("rotate", &stat);
	if (MStatus::kFailure != stat) {
	    rotateManipFn.connectToRotationPlug(rotatePlug);
		rotateManipFn.displayWithNode(node);
	}

	// ScaleManip
	//
	MFnScaleManip scaleManipFn(fScaleManip);

	MPlug scalePlug = transformNode.findPlug("scale", &stat);
    if (MStatus::kFailure != stat) {
	    scaleManipFn.connectToScalePlug(scalePlug);
		scaleManipFn.displayWithNode(node);
	}

	finishAddingManips();
	MPxManipContainer::connectToDependNode(node);
	
    return stat;
}