Message 1 of 3
Animating with the c++ API, viewport stops refreshing...
Not applicable
02-18-2018
08:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to wrap my head around moving an object using the API.
I create a joint, using:
MFnIkJoint* rootJoint = new MFnIkJoint(); MObject rootTransform = rootJoint->create(MObject::kNullObj, &status);
Then I launch a thread that moves this joint:
MStatus stat = MThreadAsync::init();
if (MStatus::kSuccess != stat) {
MString str = MString("Error creating MThreadAsync");
MGlobal::displayError(str);
}
else
{
MThreadAsync::createTask(ApplyData, this, NULL, NULL);
}
Where the thread function contains:
MVector currentPos;
while(dataExit == false) { currentPos.x += 0.0001; MStatus status = rootJoint->setTranslation(currentPos, MSpace::kTransform); }
I run this function, and it works great. the joint is created in the viewport, and starts moving. Then, after a few seconds, it stops. When i stop the thread, the translation value does not match where the joint is in the viewport.
It is as if the thread keeps assigning data, but the viewport stops updating. Do I need to add a `refreshviewport` of some kind here?
Thank you.