mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:29:01 +02:00
Script commands to start/stop animations by role.
This commit is contained in:
parent
8458477b9f
commit
2a50b5451f
2 changed files with 50 additions and 1 deletions
|
@ -459,6 +459,47 @@ void MyAvatar::startAnimation(const QString& url, float fps, float priority,
|
||||||
handle->start();
|
handle->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::startAnimationByRole(const QString& role, const QString& url, float fps, float priority,
|
||||||
|
bool loop, bool hold, int firstFrame, int lastFrame, const QStringList& maskedJoints) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "startAnimationByRole", Q_ARG(const QString&, role), Q_ARG(const QString&, url),
|
||||||
|
Q_ARG(float, fps), Q_ARG(float, priority), Q_ARG(bool, loop), Q_ARG(bool, hold), Q_ARG(int, firstFrame),
|
||||||
|
Q_ARG(int, lastFrame), Q_ARG(const QStringList&, maskedJoints));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// check for a configured animation for the role
|
||||||
|
foreach (const AnimationHandlePointer& handle, _animationHandles) {
|
||||||
|
if (handle->getRole() == role) {
|
||||||
|
handle->start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// no joy; use the parameters provided
|
||||||
|
AnimationHandlePointer handle = _skeletonModel.createAnimationHandle();
|
||||||
|
handle->setRole(role);
|
||||||
|
handle->setURL(url);
|
||||||
|
handle->setFPS(fps);
|
||||||
|
handle->setPriority(priority);
|
||||||
|
handle->setLoop(loop);
|
||||||
|
handle->setHold(hold);
|
||||||
|
handle->setFirstFrame(firstFrame);
|
||||||
|
handle->setLastFrame(lastFrame);
|
||||||
|
handle->setMaskedJoints(maskedJoints);
|
||||||
|
handle->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::stopAnimationByRole(const QString& role) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "stopAnimationByRole", Q_ARG(const QString&, role));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (const AnimationHandlePointer& handle, _skeletonModel.getRunningAnimations()) {
|
||||||
|
if (handle->getRole() == role) {
|
||||||
|
handle->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::stopAnimation(const QString& url) {
|
void MyAvatar::stopAnimation(const QString& url) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "stopAnimation", Q_ARG(const QString&, url));
|
QMetaObject::invokeMethod(this, "stopAnimation", Q_ARG(const QString&, url));
|
||||||
|
@ -467,7 +508,6 @@ void MyAvatar::stopAnimation(const QString& url) {
|
||||||
foreach (const AnimationHandlePointer& handle, _skeletonModel.getRunningAnimations()) {
|
foreach (const AnimationHandlePointer& handle, _skeletonModel.getRunningAnimations()) {
|
||||||
if (handle->getURL() == url) {
|
if (handle->getURL() == url) {
|
||||||
handle->stop();
|
handle->stop();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,15 @@ public:
|
||||||
/// Stops an animation as identified by a URL.
|
/// Stops an animation as identified by a URL.
|
||||||
Q_INVOKABLE void stopAnimation(const QString& url);
|
Q_INVOKABLE void stopAnimation(const QString& url);
|
||||||
|
|
||||||
|
/// Starts an animation by its role, using the provided URL and parameters if the avatar doesn't have a custom
|
||||||
|
/// animation for the role.
|
||||||
|
Q_INVOKABLE void startAnimationByRole(const QString& role, const QString& url = QString(), float fps = 30.0f,
|
||||||
|
float priority = 1.0f, bool loop = false, bool hold = false, int firstFrame = 0,
|
||||||
|
int lastFrame = INT_MAX, const QStringList& maskedJoints = QStringList());
|
||||||
|
|
||||||
|
/// Stops an animation identified by its role.
|
||||||
|
Q_INVOKABLE void stopAnimationByRole(const QString& role);
|
||||||
|
|
||||||
// get/set avatar data
|
// get/set avatar data
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
|
|
Loading…
Reference in a new issue