コード例 #1
0
ファイル: animation.cpp プロジェクト: tapple/qavimator
Animation::Animation(BVH* newBVH,const QString& bvhFile) :
  frame(0),totalFrames(0),mirrored(false)
{
  qDebug("Animation::Animation(%px)",this);

  bvh=newBVH;
  if(!bvh)
  {
    qDebug("Animation::Animation(): BVH initialisation failed.");
    return;
  }

  QString fileName;

  // pick up path from src.pro qmake file's DEFINES section, i.e. usr/share/qavimator
  //dataPath=QAVIMATOR_DATAPATH;
#ifdef __APPLE__
  dataPath=QApplication::applicationDirPath() + "/../Resources";
#else
  dataPath=QAVIMATOR_DATAPATH;
#endif

  // load BVH that defines motion
  if (!bvhFile.isEmpty())
    fileName=bvhFile;
  else
    fileName=dataPath+"/"+DEFAULT_POSE;

  loadBVH(fileName);
  calcPartMirrors();
  useRotationLimits(true);
  setNumberOfFrames(bvh->lastLoadedNumberOfFrames);
  setAvatarScale(bvh->lastLoadedAvatarScale);
  setFigureType(bvh->lastLoadedFigureType);
  setLoopInPoint(bvh->lastLoadedLoopIn);
  setLoopOutPoint(bvh->lastLoadedLoopOut);
  setFrameTime(bvh->lastLoadedFrameTime);
  positionNode=bvh->lastLoadedPositionNode;
  addKeyFrameAllJoints();

  ikTree.set(frames);
  setIK(IK_LHAND, false);
  setIK(IK_RHAND, false);
  setIK(IK_LFOOT, false);
  setIK(IK_RFOOT, false);

  setLoop(false);
  setDirty(false);

  currentPlayTime=0.0;
  setPlaystate(PLAYSTATE_STOPPED);

  connect(&timer,SIGNAL(timeout()),this,SLOT(playbackTimeout()));
}
コード例 #2
0
ファイル: AvatarBookmarks.cpp プロジェクト: ZappoMan/hifi
void AvatarBookmarks::changeToBookmarkedAvatar() {
    QAction* action = qobject_cast<QAction*>(sender());
    auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();



    if (action->data().type() == QVariant::String) {
        // TODO: Phase this out eventually.
        // Legacy avatar bookmark.

        myAvatar->useFullAvatarURL(action->data().toString());
        qCDebug(interfaceapp) << " Using Legacy V1 Avatar Bookmark ";
    } else {

        const QMap<QString, QVariant> bookmark = action->data().toMap();
        // Not magic value. This is the current made version, and if it changes this interpreter should be updated to
        // handle the new one separately.
        // This is where the avatar bookmark entry is parsed. If adding new Value, make sure to have backward compatability with previous
        if (bookmark.value(ENTRY_VERSION) == 3) {
            myAvatar->removeAvatarEntities();
            const QString& avatarUrl = bookmark.value(ENTRY_AVATAR_URL, "").toString();
            myAvatar->useFullAvatarURL(avatarUrl);
            qCDebug(interfaceapp) << "Avatar On " << avatarUrl;
            const QList<QVariant>& attachments = bookmark.value(ENTRY_AVATAR_ATTACHMENTS, QList<QVariant>()).toList();

            qCDebug(interfaceapp) << "Attach " << attachments;
            myAvatar->setAttachmentsVariant(attachments);

            const float& qScale = bookmark.value(ENTRY_AVATAR_SCALE, 1.0f).toFloat();
            myAvatar->setAvatarScale(qScale);

            const QVariantList& avatarEntities = bookmark.value(ENTRY_AVATAR_ENTITIES, QVariantList()).toList();
            addAvatarEntities(avatarEntities);

        } else {
            qCDebug(interfaceapp) << " Bookmark entry does not match client version, make sure client has a handler for the new AvatarBookmark";
        }
    }

}