Make MyAvatar.get/setAnimGraphUrl take a url(!), and make setting it

actually do something.
This commit is contained in:
howard-stearns 2015-12-03 16:16:01 -08:00
parent e0ca1c0f4c
commit 1b42c5a172
3 changed files with 19 additions and 7 deletions

View file

@ -1283,6 +1283,15 @@ void MyAvatar::initHeadBones() {
} }
} }
void MyAvatar::setAnimGraphUrl(const QUrl& url) {
if (_animGraphUrl == url) {
return;
}
destroyAnimGraph();
_animGraphUrl = url;
initAnimGraph();
}
void MyAvatar::initAnimGraph() { void MyAvatar::initAnimGraph() {
// avatar.json // avatar.json
// https://gist.github.com/hyperlogic/7d6a0892a7319c69e2b9 // https://gist.github.com/hyperlogic/7d6a0892a7319c69e2b9
@ -1299,16 +1308,19 @@ void MyAvatar::initAnimGraph() {
// or run a local web-server // or run a local web-server
// python -m SimpleHTTPServer& // python -m SimpleHTTPServer&
//auto graphUrl = QUrl("http://localhost:8000/avatar.json"); //auto graphUrl = QUrl("http://localhost:8000/avatar.json");
auto graphUrl = QUrl(_animGraphUrl.isEmpty() ? auto graphUrl =_animGraphUrl.isEmpty() ?
QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_full/avatar-animation.json") : QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_full/avatar-animation.json") :
_animGraphUrl); QUrl(_animGraphUrl);
qCDebug(interfaceapp) << "*** FIXME initAnimGraph" << graphUrl.toString();
_rig->initAnimGraph(graphUrl); _rig->initAnimGraph(graphUrl);
_bodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation.. _bodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation..
updateSensorToWorldMatrix(); // Uses updated position/orientation and _bodySensorMatrix changes updateSensorToWorldMatrix(); // Uses updated position/orientation and _bodySensorMatrix changes
qCDebug(interfaceapp) << "*** FIXME initAnimGraph ready" << graphUrl.toString();
} }
void MyAvatar::destroyAnimGraph() { void MyAvatar::destroyAnimGraph() {
qCDebug(interfaceapp) << "*** FIXME destroyAnimGraph" << _animGraphUrl.toString();
_rig->destroyAnimGraph(); _rig->destroyAnimGraph();
} }

View file

@ -253,13 +253,13 @@ public slots:
virtual void rebuildSkeletonBody() override; virtual void rebuildSkeletonBody() override;
const QString& getAnimGraphUrl() const { return _animGraphUrl; } Q_INVOKABLE QUrl getAnimGraphUrl() const { return _animGraphUrl; }
void setEnableDebugDrawDefaultPose(bool isEnabled); void setEnableDebugDrawDefaultPose(bool isEnabled);
void setEnableDebugDrawAnimPose(bool isEnabled); void setEnableDebugDrawAnimPose(bool isEnabled);
void setEnableDebugDrawPosition(bool isEnabled); void setEnableDebugDrawPosition(bool isEnabled);
void setEnableMeshVisible(bool isEnabled); void setEnableMeshVisible(bool isEnabled);
void setAnimGraphUrl(const QString& url) { _animGraphUrl = url; } Q_INVOKABLE void setAnimGraphUrl(const QUrl& url);
glm::vec3 getPositionForAudio(); glm::vec3 getPositionForAudio();
glm::quat getOrientationForAudio(); glm::quat getOrientationForAudio();
@ -360,7 +360,7 @@ private:
// Avatar Preferences // Avatar Preferences
QUrl _fullAvatarURLFromPreferences; QUrl _fullAvatarURLFromPreferences;
QString _fullAvatarModelName; QString _fullAvatarModelName;
QString _animGraphUrl {""}; QUrl _animGraphUrl {""};
// cache of the current HMD sensor position and orientation // cache of the current HMD sensor position and orientation
// in sensor space. // in sensor space.

View file

@ -190,7 +190,7 @@ void PreferencesDialog::loadPreferences() {
ui.leanScaleSpin->setValue(myAvatar->getLeanScale()); ui.leanScaleSpin->setValue(myAvatar->getLeanScale());
ui.avatarScaleSpin->setValue(myAvatar->getScale()); ui.avatarScaleSpin->setValue(myAvatar->getScale());
ui.avatarAnimationEdit->setText(myAvatar->getAnimGraphUrl()); ui.avatarAnimationEdit->setText(myAvatar->getAnimGraphUrl().toString());
ui.maxOctreePPSSpin->setValue(qApp->getMaxOctreePacketsPerSecond()); ui.maxOctreePPSSpin->setValue(qApp->getMaxOctreePacketsPerSecond());