void GridCommand::writeProperties(QXmlStreamWriter* writer) { AbstractCommand::writeProperties(writer); writer->writeTextElement("grid", QString::number(getGrid())); writer->writeTextElement("transitionDuration", QString::number(getTransitionDuration())); writer->writeTextElement("tween", getTween()); writer->writeTextElement("defer", (getDefer() == true) ? "true" : "false"); }
void SolidColorCommand::writeProperties(QXmlStreamWriter* writer) { AbstractCommand::writeProperties(writer); writer->writeTextElement("transition", getTransition()); writer->writeTextElement("transtitionDuration", QString::number(getTransitionDuration())); writer->writeTextElement("tween", getTween()); writer->writeTextElement("direction", getDirection()); writer->writeTextElement("solidcolor", getColor()); writer->writeTextElement("triggeronnext", (getTriggerOnNext() == true) ? "true" : "false"); }
void AudioCommand::writeProperties(QXmlStreamWriter* writer) { AbstractCommand::writeProperties(writer); writer->writeTextElement("transition", getTransition()); writer->writeTextElement("transitionDuration", QString::number(getTransitionDuration())); writer->writeTextElement("tween", getTween()); writer->writeTextElement("direction", getDirection()); writer->writeTextElement("loop", (getLoop() == true) ? "true" : "false"); writer->writeTextElement("useauto", (getUseAuto() == true) ? "true" : "false"); writer->writeTextElement("triggeronnext", (getTriggerOnNext() == true) ? "true" : "false"); }
void LevelsCommand::writeProperties(QXmlStreamWriter* writer) { AbstractCommand::writeProperties(writer); writer->writeTextElement("minin", QString::number(getMinIn())); writer->writeTextElement("maxin", QString::number(getMaxIn())); writer->writeTextElement("minout", QString::number(getMinOut())); writer->writeTextElement("maxout", QString::number(getMaxOut())); writer->writeTextElement("gamma", QString::number(getGamma())); writer->writeTextElement("transtitionDuration", QString::number(getTransitionDuration())); writer->writeTextElement("tween", getTween()); writer->writeTextElement("defer", (getDefer() == true) ? "true" : "false"); }
void TweenInfo::on_btnPlay_clicked() { Magic3D::Tween* tween = getTween(); if (tween) { tweens->saveObject(tween); tween->play(); mainWindow->setProjectChanged(true); mainWindow->update(); update(); } }
void DrawingExample::addControlPointWithUXEvent(shared_ptr<UXEvent> event){ if (!event->referenceNode) { auto store = View::viewWithSize(size.get().xy); canvas->addChild(store); event->referenceNode = store; auto layer = MeshBatcher::nodeWithPrimitive(NKPrimitiveRect, Texture::textureWithImageFile("soft64.png"), BLACK, 1); layer->setIs2d(true); //auto layer = SpriteEmitter::nodeWithTexture(Texture::textureWithImageFile("soft64.png"), Color(0)); store->addChild(layer); layer->position.set(event->screenLocation - (scene()->size.get().xy / 2.0)); // DO FIRST POINT auto cp = Node::node(Color(0,0),1); layer->addChild(cp); auto point = Node::node(BLACK,V3(3)); cp->addChild(point); } else { auto& lastCP = event->referenceNode->child()->children().back(); auto& lastPoint = lastCP->children().back(); auto delta = event->screenLocation - event->previousScreenLocation; F1t velocity = sqrtf(event->avgVelocity().length()); F1t brushScale = 10.0; if (event->scale.x < 1.0) event->scale.x = 1.0; F1t targetSize = (velocity+.2) * brushScale * event->scale.x; F1t density = .6 / Platform::Screen::scale(); auto cp = Node::node(Color(0), V3(1)); cp->position.set(lastCP->position.get() + lastPoint->position.get()); event->referenceNode->child()->addChild(cp); int numSteps = (delta.length() * density) + 1; for (int i = 0; i < numSteps; i++){ F1t mu = (i+1) / (F1t)numSteps; auto point = Node::node(BLACK,V3(getTween(lastPoint->size.get().x, targetSize , mu))); cp->addChild(point); point->position.set(delta * mu); point->scale.set(1.0 - mu); // nkLog("pos: %f, %f, scale %f",point->position.get().x,point->position.get().y, 1.0 - mu); } } }
void TweenInfo::update() { updating = true; Magic3D::PhysicsObject* physicsObject = getPhysicsObject(); Magic3D::Tween* tween = getTween(); if (physicsObject && tween) { ui->lblTitle->setText(tr("%0 - %1").arg(tweenIndex).arg(getTweenType(tween))); ui->chkPlayAtStart->setChecked(tween->isPlayingAtStart()); ui->chkAllwaysUpdate->setChecked(tween->isAllwaysUpdated()); ui->chkIgnoreTimeScale->setChecked(tween->isIgnoringTimeScale()); ui->cmbUpdateType->setCurrentIndex(tween->getTweenUpdateType()); if (!ui->txtRepeat->hasFocus()) { ui->txtRepeat->setValue(tween->getRepeat()); } if (!ui->txtStartValue->hasFocus()) { ui->txtStartValue->setValue(tween->getStartValue()); } if (!ui->txtSpeed->hasFocus()) { ui->txtSpeed->setValue(tween->getSpeed()); } if (!ui->txtDuration->hasFocus()) { ui->txtDuration->setValue(tween->getDuration()); } switch (tween->getType()) { case Magic3D::eTWEEN_ALPHA: { if (!ui->txtX->hasFocus()) { ui->lblX->setText("Alpha:"); ui->txtX->setValue(static_cast<Magic3D::TweenAlpha*>(tween)->getAlpha()); } break; } case Magic3D::eTWEEN_ROTATE: { ui->lblX->setText("Rotate x:"); Magic3D::TweenRotate* rotate = static_cast<Magic3D::TweenRotate*>(tween); if (!ui->txtX->hasFocus()) { ui->txtX->setValue(rotate->getEuler().getX()); } if (!ui->txtY->hasFocus()) { ui->txtY->setValue(rotate->getEuler().getY()); } if (!ui->txtZ->hasFocus()) { ui->txtZ->setValue(rotate->getEuler().getZ()); } break; } case Magic3D::eTWEEN_SCALE: { ui->lblX->setText("Scale x:"); Magic3D::TweenScale* scale = static_cast<Magic3D::TweenScale*>(tween); if (!ui->txtX->hasFocus()) { ui->txtX->setValue(scale->getScale().getX()); } if (!ui->txtY->hasFocus()) { ui->txtY->setValue(scale->getScale().getY()); } if (!ui->txtZ->hasFocus()) { ui->txtZ->setValue(scale->getScale().getZ()); } break; } case Magic3D::eTWEEN_TRANSLATE: { ui->lblX->setText("Translate x:"); Magic3D::TweenTranslate* translate = static_cast<Magic3D::TweenTranslate*>(tween); if (!ui->txtX->hasFocus()) { ui->txtX->setValue(translate->getPosition().getX()); } if (!ui->txtY->hasFocus()) { ui->txtY->setValue(translate->getPosition().getY()); } if (!ui->txtZ->hasFocus()) { ui->txtZ->setValue(translate->getPosition().getZ()); } break; } case Magic3D::eTWEEN_GOTO: { ui->lblX->setText("Position x:"); Magic3D::TweenGoTo* goTo = static_cast<Magic3D::TweenGoTo*>(tween); if (!ui->txtX->hasFocus()) { ui->txtX->setValue(goTo->getPosition().getX()); } if (!ui->txtY->hasFocus()) { ui->txtY->setValue(goTo->getPosition().getY()); } if (!ui->txtZ->hasFocus()) { ui->txtZ->setValue(goTo->getPosition().getZ()); } break; } case Magic3D::eTWEEN_LOOKAT: { ui->lblX->setText("Rotation x:"); Magic3D::TweenLookAt* lookAt = static_cast<Magic3D::TweenLookAt*>(tween); if (!ui->txtX->hasFocus()) { ui->txtX->setValue(lookAt->getRotation().getX()); } if (!ui->txtY->hasFocus()) { ui->txtY->setValue(lookAt->getRotation().getY()); } if (!ui->txtZ->hasFocus()) { ui->txtZ->setValue(lookAt->getRotation().getZ()); } break; } //case Magic3D::eTWEEN_DELAY: break; //case Magic3D::eTWEEN_CUSTOM: break; default: break; } bool visible = tween->getType() != Magic3D::eTWEEN_CUSTOM && tween->getType() != Magic3D::eTWEEN_DELAY; ui->lblX->setVisible(visible); ui->txtX->setVisible(visible); ui->lblY->setVisible(visible && tween->getType() != Magic3D::eTWEEN_ALPHA); ui->txtY->setVisible(visible && tween->getType() != Magic3D::eTWEEN_ALPHA); ui->lblZ->setVisible(visible && tween->getType() != Magic3D::eTWEEN_ALPHA); ui->txtZ->setVisible(visible && tween->getType() != Magic3D::eTWEEN_ALPHA); ui->spacerCustom->setVisible(visible && tween->getType() == Magic3D::eTWEEN_ALPHA); ui->spacerCustom2->setVisible(visible && tween->getType() == Magic3D::eTWEEN_ALPHA); ui->cmbNextTweenObject->clear(); mainWindow->setComboList(tweens->getParentsList(), ui->cmbNextTweenObject); if (!tween->getNextTweenObject().empty()) { ui->cmbNextTweenObject->setCurrentIndex(ui->cmbNextTweenObject->findText(QString::fromStdString(tween->getNextTweenObject()))); if (!ui->txtNextIndex->hasFocus()) { ui->txtNextIndex->setValue(tween->getNextTweenIndex()); } } else { ui->cmbNextTweenObject->setCurrentIndex(ui->cmbNextTweenObject->findText(UTILS_NONE)); ui->txtNextIndex->setValue(0); } ui->cmbNextTweenBone->setCurrentIndex(0); if (getModel(tween->getNextTweenObject())) { updateBoneCombo(ui->cmbNextTweenBone, tween->getNextTweenObject()); ui->cmbNextTweenBone->setEnabled(true); if (!tween->getNextTweenBone().empty()) { ui->cmbNextTweenBone->setCurrentIndex(ui->cmbNextTweenBone->findText(QString::fromStdString(tween->getNextTweenBone()))); } } else { ui->cmbNextTweenBone->setEnabled(false); } } updating = false; }
void TweenInfo::updateObject() { Magic3D::Tween* tween = getTween(); if (!updating && tween) { std::string nextObject; std::string nextBone; tween->setPlayingAtStart(ui->chkPlayAtStart->isChecked()); tween->setAllwaysUpdate(ui->chkAllwaysUpdate->isChecked()); tween->setIgnoreTimeScale(ui->chkIgnoreTimeScale->isChecked()); tween->setTweenUpdateType((Magic3D::TweenUpdateType)ui->cmbUpdateType->currentIndex()); tween->setRepeat(ui->txtRepeat->value()); tween->setStartValue(ui->txtStartValue->value()); tween->setSpeed(ui->txtSpeed->value()); tween->setDuration(ui->txtDuration->value()); switch (tween->getType()) { case Magic3D::eTWEEN_ALPHA: { static_cast<Magic3D::TweenAlpha*>(tween)->setAlpha(ui->txtX->value()); break; } case Magic3D::eTWEEN_ROTATE: { Magic3D::TweenRotate* rotate = static_cast<Magic3D::TweenRotate*>(tween); rotate->setEuler(Magic3D::Vector3(ui->txtX->value(), ui->txtY->value(), ui->txtZ->value())); break; } case Magic3D::eTWEEN_SCALE: { Magic3D::TweenScale* scale = static_cast<Magic3D::TweenScale*>(tween); scale->setScale(Magic3D::Vector3(ui->txtX->value(), ui->txtY->value(), ui->txtZ->value())); break; } case Magic3D::eTWEEN_TRANSLATE: { Magic3D::TweenTranslate* translate = static_cast<Magic3D::TweenTranslate*>(tween); translate->setPosition(Magic3D::Vector3(ui->txtX->value(), ui->txtY->value(), ui->txtZ->value())); break; } case Magic3D::eTWEEN_GOTO: { Magic3D::TweenGoTo* goTo = static_cast<Magic3D::TweenGoTo*>(tween); goTo->setPosition(Magic3D::Vector3(ui->txtX->value(), ui->txtY->value(), ui->txtZ->value())); break; } case Magic3D::eTWEEN_LOOKAT: { Magic3D::TweenLookAt* lookAt = static_cast<Magic3D::TweenLookAt*>(tween); lookAt->setRotation(Magic3D::Vector3(ui->txtX->value(), ui->txtY->value(), ui->txtZ->value())); break; } //case Magic3D::eTWEEN_DELAY: break; //case Magic3D::eTWEEN_CUSTOM: break; default: break; } if (ui->cmbNextTweenObject->currentIndex() > 0) { nextObject = ui->cmbNextTweenObject->currentText().toStdString(); } else { nextObject.clear(); } if (ui->cmbNextTweenBone->currentIndex() > 0) { nextBone = ui->cmbNextTweenBone->currentText().toStdString(); Magic3D::Model* model = getModel(nextObject); if (model && model->getSkeleton()) { if (!model->getSkeleton()->getBoneByName(nextBone)) { nextBone.clear(); } } } else { nextBone.clear(); } tween->setNextTween(nextObject, nextBone, ui->txtNextIndex->value()); mainWindow->setProjectChanged(true); mainWindow->update(); update(); } }