Tank::Tank(QObject *parent) : QGLSceneNode(parent) , m_texture(0) { QSequentialAnimationGroup *seq = new QSequentialAnimationGroup(this); QGraphicsScale3D *scale = new QGraphicsScale3D(this); addTransform(scale); QPropertyAnimation *anim = new QPropertyAnimation(scale, "scale"); anim->setDuration(10000); anim->setStartValue(QVector3D(1.0f, 0.1f, 1.0f)); anim->setEndValue(QVector3D(1.0f, 1.2f, 1.0f)); anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad)); seq->addAnimation(anim); seq->addPause(2000); anim = new QPropertyAnimation(scale, "scale"); anim->setDuration(10000); anim->setStartValue(QVector3D(1.0f, 1.2f, 1.0f)); anim->setEndValue(QVector3D(1.0f, 0.1f, 1.0f)); anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad)); seq->addAnimation(anim); seq->setLoopCount(-1); seq->start(); addNode(tankObject()); QGLMaterial *mat = qCreateFluid(); m_texture = mat->texture(); setMaterial(mat); }
void DockModeWindow::setPrepareAddedToWindowManager() { m_prepareAddedToWm = true; if (G_LIKELY(s_dockGlow == 0)) { QString path(Settings::LunaSettings()->lunaSystemResourcesPath.c_str()); path.append("/dockmode/dock-loading-glow.png"); s_dockGlow = new QPixmap(path); if(s_dockGlow) s_dockGlowRefCount++; if (!s_dockGlow || s_dockGlow->isNull()) { g_critical("%s: Failed to load image '%s'", __PRETTY_FUNCTION__, qPrintable(path)); } } else { s_dockGlowRefCount++; } ApplicationDescription* appDesc = static_cast<Window*>(this)->appDescription(); int size = Settings::LunaSettings()->splashIconSize; m_icon.load(appDesc->splashIconName().c_str()); if (!m_icon.isNull()) { // scale splash icon to fit the devices screen dimensions m_icon = m_icon.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation); } else { // just use the launcher icon m_icon = appDesc->getDefaultLaunchPoint()->icon(); int newWidth = qMin((int)(m_icon.width()*1.5), size); int newHeight = qMin((int)(m_icon.height()*1.5), size); m_icon = m_icon.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); } // set up the pulsing animation QPropertyAnimation* pulseIn = new QPropertyAnimation(this, "pulseOpacity"); pulseIn->setDuration(AS(cardLoadingPulseDuration)); pulseIn->setEasingCurve(AS_CURVE(cardLoadingPulseCurve)); pulseIn->setEndValue(1.0); QPropertyAnimation* pulseOut = new QPropertyAnimation(this, "pulseOpacity"); pulseOut->setDuration(AS(cardLoadingPulseDuration)); pulseOut->setEasingCurve(AS_CURVE(cardLoadingPulseCurve)); pulseOut->setEndValue(0.0); QSequentialAnimationGroup* pulseGroup = new QSequentialAnimationGroup; pulseGroup->addAnimation(pulseIn); pulseGroup->addAnimation(pulseOut); pulseGroup->setLoopCount(-1); m_pulseAnimation.addPause(AS(cardLoadingTimeBeforeShowingPulsing)); m_pulseAnimation.addAnimation(pulseGroup); m_loadingOverlayEnabled = true; m_pulseAnimation.start(); update(); }
void ContactsViewDelegate::startAlertAnimation() { if (!m_alertAnimation) { QSequentialAnimationGroup *ag = new QSequentialAnimationGroup(this); m_alertAnimation = ag; QPropertyAnimation *aIn = new QPropertyAnimation(this, "alertOpacity"); aIn->setEndValue(qreal(1)); aIn->setEasingCurve(QEasingCurve::OutQuad); aIn->setDuration(750); QPropertyAnimation *aOut = new QPropertyAnimation(this, "alertOpacity"); aOut->setEndValue(qreal(0.2)); aOut->setEasingCurve(QEasingCurve::InQuad); aOut->setDuration(750); ag->addAnimation(aIn); ag->addPause(150); ag->addAnimation(aOut); ag->setLoopCount(-1); ag->start(); } }
void Barbel::Scene::initScene() { //Setup Framegraph if (m_frameGraph == Q_NULLPTR) m_frameGraph = new Qt3D::QFrameGraph(); if (m_forwardRenderer == Q_NULLPTR) m_forwardRenderer = new Qt3D::QForwardRenderer(); m_forwardRenderer->setClearColor(Qt::black); m_frameGraph->setActiveFrameGraph(m_forwardRenderer); m_rootEntity->addComponent(m_frameGraph); //Test Objects Barbel::Player *player = new Barbel::Player(m_rootEntity); player->setTranslation(QVector3D(0.0f, 0.0f, 0.0f)); setActiveCamera(player->camera()); activeCamera()->lens()->setAspectRatio(m_cameraAspectRatio); QVector3D startPostion(0.0f, 0.0f, 0.0f); QVector3D secondPosition(10.0f, 10.0f, 10.0f); QVector3D thirdPosition(-10.0f, 0.0f, 10.0f); QVector3D startAngles(0.0f, 0.0f, 0.0f); QVector3D secondAngles(45.0f, 150.0f, 0.0f); QVector3D thirdAngles(0.0f, 200.0f, 0.0f); QVector3D finalAngles(0.0f, 360.0f, 0.0f); QSequentialAnimationGroup *animationGroup = new QSequentialAnimationGroup(this); QParallelAnimationGroup *parallelAnimationGroup1 = new QParallelAnimationGroup(this); QPropertyAnimation *animation = new QPropertyAnimation(player, "translation", this); animation->setDuration(5000); animation->setStartValue(startPostion); animation->setEndValue(secondPosition); parallelAnimationGroup1->addAnimation(animation); QPropertyAnimation *rotationAnimation = new QPropertyAnimation(player, "rotation", this); rotationAnimation->setDuration(5000); rotationAnimation->setStartValue(startAngles); rotationAnimation->setEndValue(secondAngles); parallelAnimationGroup1->addAnimation(rotationAnimation); animationGroup->addAnimation(parallelAnimationGroup1); QParallelAnimationGroup *parallelAnimationGroup2 = new QParallelAnimationGroup(this); animation = new QPropertyAnimation(player, "translation", this); animation->setDuration(5000); animation->setStartValue(secondPosition); animation->setEndValue(thirdPosition); parallelAnimationGroup2->addAnimation(animation); rotationAnimation = new QPropertyAnimation(player, "rotation", this); rotationAnimation->setDuration(5000); rotationAnimation->setStartValue(secondAngles); rotationAnimation->setEndValue(thirdAngles); parallelAnimationGroup2->addAnimation(rotationAnimation); animationGroup->addAnimation(parallelAnimationGroup2); QParallelAnimationGroup *parallelAnimationGroup3 = new QParallelAnimationGroup(this); animation = new QPropertyAnimation(player, "translation", this); animation->setDuration(5000); animation->setStartValue(thirdPosition); animation->setEndValue(startPostion); parallelAnimationGroup3->addAnimation(animation); rotationAnimation = new QPropertyAnimation(player, "rotation", this); rotationAnimation->setDuration(5000); rotationAnimation->setStartValue(thirdAngles); rotationAnimation->setEndValue(finalAngles); parallelAnimationGroup3->addAnimation(rotationAnimation); animationGroup->addAnimation(parallelAnimationGroup3); animationGroup->setLoopCount(-1); animationGroup->start(); //Test Cubes Qt3D::QPhongMaterial *phongMaterial1 = new Qt3D::QPhongMaterial(); phongMaterial1->setDiffuse(QColor(94, 141, 25)); phongMaterial1->setSpecular(Qt::white); Qt3D::QPhongMaterial *phongMaterial2 = new Qt3D::QPhongMaterial(); phongMaterial2->setDiffuse(QColor(129, 23, 71)); phongMaterial2->setSpecular(Qt::white); for (int z = -5; z < 5; z++) { for (int y = -5; y < 5; y++) { for (int x = -5; x < 5; x++) { float xSize = (rand() % 10000) / 10000.0; float ySize = (rand() % 10000) / 10000.0; float zSize = (rand() % 10000) / 10000.0; Barbel::TestCube *cube = new TestCube(QVector3D(x, y, z), QVector3D(xSize, ySize, zSize), m_rootEntity); if (y % 2) cube->addComponent(phongMaterial1); else cube->addComponent(phongMaterial2); } } } }