예제 #1
0
파일: tweener.cpp 프로젝트: bedna-KU/tupi
void Tweener::init(TupGraphicsScene *scene)
{
    k->scene = scene;
    k->objects.clear();
    // if (k->target)
    //     k->scene->removeItem(k->target);

    k->mode = TupToolPlugin::View;
    k->editMode = TupToolPlugin::None;
    k->baseZValue = (2*ZLAYER_LIMIT) + (scene->scene()->layersCount() * ZLAYER_LIMIT);
    k->initFrame = k->scene->currentFrameIndex();
    k->initLayer = k->scene->currentLayerIndex();
    k->initScene = k->scene->currentSceneIndex();

    k->configurator->resetUI();

    QList<QString> tweenList = k->scene->scene()->getTweenNames(TupItemTweener::Scale);
    if (tweenList.size() > 0) {
        k->configurator->loadTweenList(tweenList);
        QString tweenName = tweenList.at(0);
        setCurrentTween(tweenName);
    }

    int total = framesCount();
    k->configurator->initStartCombo(total, k->initFrame);
}
예제 #2
0
bool Movement::next() {
  if (position >= framesCount())
    return false;

  position++;

  return true;
}
예제 #3
0
bool Movement::frame(float fill, Bone* root) {
  if (position >= framesCount()) {
    return false;
  }

  int c = 0;
  int d = 0;
  Bone* current;

  for (std::map<unsigned long long,glm::vec3>::iterator kv = sequence[position].begin(); kv != sequence[position].end(); ++kv) {
    glm::vec3 dv = glm::abs(sequence[position-1][kv->first] - kv->second);
/*
    if (dv.x > 180)
      dv.x = 360 - dv.x;

    if (dv.y > 180)
      dv.y = 360 - dv.y;

    if (dv.z > 180)
      dv.z = 360 - dv.z;
*/
    glm::vec3 s = sgn(sequence[position-1][kv->first], kv->second);

    //d += fabs(dv.x) < 0.01f;
    //d += fabs(dv.y) < 0.01f;
    //d += fabs(dv.z) < 0.01f;

    dv.x *= s.x * fill;
    dv.y *= s.y * fill;
    dv.z *= s.z * fill;

    moved[position][kv->first] += glm::abs(dv);
    current = root->bone(kv->first);

    d+=3;

    if (glm::abs(moved[position][kv->first]).x >= glm::abs(sequence[position-1][kv->first] - kv->second).x) {
      c++;
    } else {
      current->rotate(dv.x, 0, 0);
    }

    if (glm::abs(moved[position][kv->first]).y >= glm::abs(sequence[position-1][kv->first] - kv->second).y) {
        c++;
    } else {
      current->rotate(0, dv.y, 0);
    }

    if (glm::abs(moved[position][kv->first]).z >= glm::abs(sequence[position-1][kv->first] - kv->second).z) {
        c++;
    } else {
      current->rotate(0, 0, dv.z);
    }
  }

  printf("c=%d, d=%d\n", c,d);
  return c < d;
}
예제 #4
0
void Tweener::init(TupGraphicsScene *scene)
{
    #ifdef K_DEBUG
        #ifdef Q_OS_WIN
            qDebug() << "[Tweener::init()]";
        #else
            T_FUNCINFO;
        #endif
    #endif

    if (k->isPathInScene) {
        if (k->nodesGroup) {
            k->nodesGroup->clear();
            delete k->nodesGroup;
            k->nodesGroup = 0;
        }

        if (k->path) {
            delete k->path;
            k->path = 0;
        }

        k->isPathInScene = false;
    }

    k->scene = scene;
    k->objects.clear();
    k->baseZValue = (2*ZLAYER_LIMIT) + (scene->scene()->layersCount() * ZLAYER_LIMIT);

    k->pathOffset = QPointF(0, 0); 
    k->firstNode = QPointF(0, 0);
    k->itemObjectReference = QPointF(0, 0);

    k->mode = TupToolPlugin::View;
    k->editMode = TupToolPlugin::None;

    k->configurator->resetUI();

    QList<QString> tweenList = k->scene->scene()->getTweenNames(TupItemTweener::Position);
    if (tweenList.size() > 0) {
        k->configurator->loadTweenList(tweenList);
        setCurrentTween(tweenList.at(0));
    }

    int total = framesCount();
    k->configurator->initStartCombo(total, k->scene->currentFrameIndex());
}