void GraphicsLayerBlackBerry::updateLayerPreserves3D() { if (m_preserves3D && !m_transformLayer) { // Create the transform layer. m_transformLayer = LayerWebKitThread::create(LayerData::TransformLayer, this); // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateAnimations(); m_layer->setPosition(FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f)); m_layer->setAnchorPoint(FloatPoint(0.5f, 0.5f)); TransformationMatrix identity; m_layer->setTransform(identity); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer->setOpacity(1); // Move this layer to be a child of the transform layer. if (m_layer->superlayer()) m_layer->superlayer()->replaceSublayer(m_layer.get(), m_transformLayer.get()); m_transformLayer->addSublayer(m_layer.get()); m_transformLayer->setPreserves3D(true); m_layer->setPreserves3D(true); updateSublayerList(); } else if (!m_preserves3D && m_transformLayer) { // Relace the transformLayer in the parent with this layer. m_layer->removeFromSuperlayer(); if (m_transformLayer->superlayer()) m_transformLayer->superlayer()->replaceSublayer(m_transformLayer.get(), m_layer.get()); // Release the transform layer. m_transformLayer = 0; updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateAnimations(); m_layer->setPreserves3D(false); updateSublayerList(); } updateOpacityOnLayer(); }
void SMILTimeContainer::begin() { RELEASE_ASSERT(!m_beginTime); if (!handleAnimationPolicy(RestartOnceTimerIfNotPaused)) return; double now = currentTime(); // If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began. // In this case pass on 'seekToTime=true' to updateAnimations(). m_beginTime = now - m_presetStartTime; #if !ENABLE(OILPAN) DiscardScope discardScope(m_ownerSVGElement); #endif SMILTime earliestFireTime = updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false); m_presetStartTime = 0; if (m_pauseTime) { m_pauseTime = now; // If updateAnimations() caused new syncbase instance to be generated, // we don't want to cancel those. Excepting that, no frame should've // been scheduled at this point. ASSERT(m_frameSchedulingState == Idle || m_frameSchedulingState == SynchronizeAnimations); } else if (!hasPendingSynchronization()) { ASSERT(isTimelineRunning()); // If the timeline is running, and there's pending animation updates, // always perform the first update after the timeline was started using // the wake-up mechanism. if (earliestFireTime.isFinite()) { SMILTime delay = earliestFireTime - elapsed(); scheduleWakeUp(std::max(initialFrameDelay, delay.value()), SynchronizeAnimations); } } }
void GraphicsLayerBlackBerry::pauseAnimation(const String& animationName, double timeOffset) { // WebCore might have added several animations with the same name, but for different properties while (RefPtr<LayerAnimation> animation = removeAnimationByName(animationName, m_runningAnimations)) { #if DEBUG_LAYER_ANIMATION fprintf(stderr, "LayerAnimation 0x%08x: Pausing animation %s\n", animation.get(), animation->name().latin1().data()); #endif // LayerAnimation is readonly. Create a new animation with the same data except for timeOffset. // WebCore will adjust the timeOffset for paused animations so it can be used to calculate the // progress for the paused animation without knowing the exact timestamp when the animation was // paused. // If an animation was started with a timeOffset dt_orig and paused dt_pause seconds later, the // cloned animation will have a timeOffset of dt_pause + dt_orig. animation = animation->clone(timeOffset); m_suspendedAnimations.append(animation); #if DEBUG_LAYER_ANIMATION fprintf(stderr, "LayerAnimation 0x%08x: Paused animation %s\n", animation.get(), animation->name().latin1().data()); #endif }; updateAnimations(); }
void SMILTimeContainer::setElapsed(SMILTime time) { // If the documment didn't begin yet, record a new start time, we'll seek to once its possible. if (!m_beginTime) { m_presetStartTime = time.value(); return; } if (m_beginTime) m_timer.stop(); double now = currentTime(); m_beginTime = now - time.value(); m_accumulatedPauseTime = 0; if (m_pauseTime) m_pauseTime = now; #ifndef NDEBUG m_preventScheduledAnimationsChanges = true; #endif GroupedAnimationsMap::iterator end = m_scheduledAnimations.end(); for (GroupedAnimationsMap::iterator it = m_scheduledAnimations.begin(); it != end; ++it) { AnimationsVector* scheduled = it->second; unsigned size = scheduled->size(); for (unsigned n = 0; n < size; n++) scheduled->at(n)->reset(); } #ifndef NDEBUG m_preventScheduledAnimationsChanges = false; #endif updateAnimations(time, true); }
void AnimationControllerPrivate::scheduleService() { double timeToNextService = -1; double timeToNextEvent = -1; updateAnimations(timeToNextService, timeToNextEvent, DoNotCallSetNeedsStyleRecalc); scheduleService(timeToNextService, timeToNextEvent); }
/** * Runs the game! WHOO! */ int Game::start() { game_running = true; while(window.isOpen()) { while(game_running) { sf::Event event; while(window.pollEvent(event)) { if(event.type == sf::Event::Closed) { window.close(); game_running = false; game_over = true; } } bullets = p.getBullets(); spawnEnemies(); checkInput(); checkBorderCollision(p); checkEntityCollision(); checkDeath(); updateAnimations(); updateScore(); updateInterface(); updateGameClocks(); for(std::vector<Enemy*>::iterator iter = enemies.begin(); iter != enemies.end(); ++iter) { Enemy *eni = *iter; eni->stalkPlayer(p); } window.clear(sf::Color(0,230,0)); Sword * s = p.getSword(); if(s->isSwung()) { window.draw(s->shape); } window.draw(p.shape); for(std::vector<Enemy*>::iterator iter = enemies.begin(); iter != enemies.end(); ++iter) { Enemy *eni = *iter; window.draw(eni->shape); } for(std::vector<Bullet*>::iterator iter = bullets.begin(); iter != bullets.end(); ++iter) { Bullet *b = *iter; window.draw(b->shape); } for(std::vector<sf::Drawable*>::iterator iter = interface.begin(); iter != interface.end(); ++iter) { sf::Drawable *d = *iter; window.draw(*d); } window.display(); } setupEntities(); game_running = true; } return 0; }
bool GraphicsLayerBlackBerry::addAnimation(const KeyframeValueList& values, const IntSize& boxSize, const Animation* animation, const String& animationName, double timeOffset) { // This is what GraphicsLayerCA checks for. if (!animation || animation->isEmptyOrZeroDuration() || values.size() < 2) return false; // We only support these two kinds of properties at the moment. if (values.property() != AnimatedPropertyWebkitTransform && values.property() != AnimatedPropertyOpacity) return false; // Remove any running animation for the same property. // FIXME: Maybe this is superstition, I got the idea from GraphicsLayerQt // WebCore might be adding an animation with the same name, but for a different property removeAnimationByIdAndProperty(LayerAnimation::idFromAnimation(animation), values.property(), m_runningAnimations); removeAnimationByIdAndProperty(LayerAnimation::idFromAnimation(animation), values.property(), m_suspendedAnimations); RefPtr<LayerAnimation> layerAnimation = LayerAnimation::create(values, boxSize, animation, animationName, timeOffset); #if DEBUG_LAYER_ANIMATION fprintf(stderr, "LayerAnimation 0x%08x: Adding animation %s for property %d\n", layerAnimation.get(), animationName.latin1().data(), values.property()); #endif m_runningAnimations.append(layerAnimation); updateAnimations(); return true; }
void AnimationControllerPrivate::animationFrameCallbackFired() { double timeToNextService = updateAnimations(CallSetChanged); if (timeToNextService >= 0) m_frame.document()->view()->scheduleAnimation(); }
void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*) { ASSERT(m_beginTime); ASSERT(!m_pauseTime); SMILTime elapsed = this->elapsed(); updateAnimations(elapsed); }
void Application::go() { Ogre::Timer loopTimer; bool continueRunning = true; while ( continueRunning ) { Ogre::WindowEventUtilities::messagePump(); SimpleInputManager::capture(); // Update logic stuff float elapsedSeconds = loopTimer.getMicroseconds() * 1.0 / 1000000; updateLogic( elapsedSeconds ); // Update graphics stuff updateAnimations( elapsedSeconds ); bool windowClosed = m_window->isClosed(); continueRunning &= ! windowClosed; updateStats(); loopTimer.reset(); bool renderFrameSuccess = m_root->renderOneFrame(); continueRunning &= renderFrameSuccess; continueRunning &= ! m_exitRequested; } }
void SMILTimeContainer::setElapsed(SMILTime time) { // If the documment didn't begin yet, record a new start time, we'll seek to once its possible. if (!m_beginTime) { m_presetStartTime = time.value(); return; } if (m_beginTime) m_timer.stop(); double now = currentTime(); m_beginTime = now - time.value(); m_accumulatedPauseTime = 0; if (m_pauseTime) m_pauseTime = now; Vector<SVGSMILElement*> toReset; copyToVector(m_scheduledAnimations, toReset); for (unsigned n = 0; n < toReset.size(); ++n) toReset[n]->reset(); updateAnimations(time, true); }
void SMILTimeContainer::setElapsed(SMILTime time) { // If the documment didn't begin yet, record a new start time, we'll seek to once its possible. if (!m_beginTime) { m_presetStartTime = time.value(); return; } if (m_beginTime) m_timer.stop(); double now = monotonicallyIncreasingTime(); m_beginTime = now - time.value(); if (m_pauseTime) { m_resumeTime = m_pauseTime = now; m_accumulatedActiveTime = time.value(); } else m_resumeTime = m_beginTime; #ifndef NDEBUG m_preventScheduledAnimationsChanges = true; #endif for (auto& it : m_scheduledAnimations) { AnimationsVector* scheduled = it.value.get(); unsigned size = scheduled->size(); for (unsigned n = 0; n < size; n++) scheduled->at(n)->reset(); } #ifndef NDEBUG m_preventScheduledAnimationsChanges = false; #endif updateAnimations(time, true); }
void Model::update( float delta ) { mesh = meshHandle.Resolve(); if( !mesh || !mesh->isLoaded() ) return; if( !modelBuilt ) build(); if(updateSkin) { updateSkinning(); updateSkin = false; } if( mesh->isAnimated() ) { if( animations.empty() ) setAnimation( mesh->getBindPose().get() ); if( animationEnabled ) { updateAnimations(delta); updateFinalAnimationBones(); } updateAttachments(); } //updateDebugRenderable(); Geometry::update(delta); }
//------------------------------------------- update. void ofxAssimpModelLoader::update() { updateAnimations(); updateMeshes(scene->mRootNode, ofMatrix4x4()); if(hasAnimations() == false) { return; } updateBones(); updateGLResources(); }
void SMILTimeContainer::sampleAnimationAtTime(const String& elementId, double newTime) { ASSERT(m_beginTime); ASSERT(!isPaused()); // Fast-forward to the time DRT wants to sample m_timer.stop(); updateAnimations(elapsed(), newTime, elementId); }
void AnimationControllerPrivate::serviceAnimations() { double timeToNextService = -1; double timeToNextEvent = -1; updateAnimations(timeToNextService, timeToNextEvent, CallSetNeedsStyleRecalc); scheduleService(timeToNextService, timeToNextEvent); // Fire events right away, to avoid a flash of unanimated style after an animation completes, and before // the 'end' event fires. fireEventsAndUpdateStyle(); }
void AnimationControllerPrivate::scrollWasUpdated() { auto* view = m_frame.view(); if (!view || !wantsScrollUpdates()) return; m_scrollPosition = view->scrollOffsetForFixedPosition().height().toFloat(); // FIXME: This is updating all the animations, rather than just the ones // that are dependent on scroll. We to go from our AnimationBase to its CompositeAnimation // so we can execute code similar to updateAnimations. // https://bugs.webkit.org/show_bug.cgi?id=144170 updateAnimations(CallSetChanged); }
void GraphicsLayerBlackBerry::removeAnimation(const String& animationName) { // WebCore might have added several animations with the same name, but for different properties #if DEBUG_LAYER_ANIMATION fprintf(stderr, "LayerAnimation: Removing animation %s\n", animationName.latin1().data()); #endif while (removeAnimationByName(animationName, m_runningAnimations)) { } while (removeAnimationByName(animationName, m_suspendedAnimations)) { } updateAnimations(); }
void SMILTimeContainer::begin() { ASSERT(!m_beginTime); double now = currentTime(); m_beginTime = now - m_presetStartTime; updateAnimations(SMILTime(m_presetStartTime)); m_presetStartTime = 0; if (m_pauseTime) { m_pauseTime = now; m_timer.stop(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Inicializace programu actualPosition = Vector2(0,0); ui->setupUi(this); animationTimer = new QTimer(this); actualPositionSet = false; iterations = 1; // Přiřazení referencí z GUI playB = ui->playButton; stopB = ui->stopButton; animationCheckBox = ui->animCheckBox; speedSlider = ui->speedSlider; speedText = ui->speedText; drawer = new Drawer(ui->graphicsView); iterationSlider = ui->iterationsSlider; progressBar = ui->progressBar; comboBox = ui->comboBox; // Vytvoření křivek hilbertCurve = new HilbertCurve(drawer,&iterations,progressBar); sierpinskiCurve = new SierpinskiCurve(drawer,&iterations,progressBar); comboBox->addItem("Hilbert"); // Prvotní vygenerování křivky handleSliderChange(); // Propojení prvků programu s funkcemi connect(iterationSlider,SIGNAL(valueChanged(int)), this, SLOT(handleSliderChange())); connect(comboBox,SIGNAL(currentIndexChanged(int)),this, SLOT(handleCurveChange())); connect(animationCheckBox,SIGNAL(stateChanged(int)),this,SLOT(handleAnimationChange())); connect(animationTimer,SIGNAL(timeout()),this,SLOT(updateAnimations())); connect(playB,SIGNAL(released()),this,SLOT(play())); connect(stopB,SIGNAL(released()),this,SLOT(stop())); animationTimer->start(2); handleAnimationChange(); actualPosition = hilbertCurve->sortedAnimationPoints[0]->center; }
void Player::update( float deltaTime, OIS::Mouse* mouse, OIS::Keyboard* keyboard ) { Cegui::getInstance()->setAmmo( numOfBullet ,30 ); updateRay(); updateMissile(); updateMouseMove( mouse ); updateKeyboardMove( keyboard, deltaTime ); if( mFireFlash->isAlive() ) mFireFlash->update(deltaTime); updateAnimations( deltaTime ); }
void SMILTimeContainer::begin() { ASSERT(!m_beginTime); double now = currentTime(); // If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began. // In this case pass on 'seekToTime=true' to updateAnimations(). m_beginTime = now - m_presetStartTime; updateAnimations(SMILTime(m_presetStartTime), m_presetStartTime ? true : false); m_presetStartTime = 0; if (m_pauseTime) { m_pauseTime = now; m_timer.stop(); } }
void displayCB(void) { static OSG::Time prevT = OSG::getSystemTime(); OSG::Time currT = OSG::getSystemTime(); OSG::Time deltaT = currT - prevT; updateAnimations(currT, deltaT); updatePosition (deltaT); OSG::FrameHandler::the()->frame(currT); OSG::commitChangesAndClear(); g->mgr->idle (); g->mgr->redraw(); prevT = currT; }
void update(int value) { updateAnimations(); updatePointer(); updatePlayer(); updateBullet(); updateCubes(); updateExplosions(); updateScore(); // comunica cata cuburi mai sunt sprintf_s(_windowTitle, 39, "JakCube - %d cubes left", _evilCubes.size()); _windowTitle[39] = NULL; glutSetWindowTitle(_windowTitle); glutPostRedisplay(); glutTimerFunc(25, update, 0); }
void SMILTimeContainer::setElapsed(SMILTime time) { if (!m_beginTime) { m_presetStartTime = time.value(); return; } double now = currentTime(); m_beginTime = now - time.value(); m_accumulatedPauseTime = 0; Vector<SVGSMILElement*> toReset; copyToVector(m_scheduledAnimations, toReset); for (unsigned n = 0; n < toReset.size(); ++n) toReset[n]->reset(); if (isPaused()) updateAnimations(now - m_beginTime - m_accumulatedPauseTime); }
void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToTime) { if (!document().isActive()) return; SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); // If updateAnimations() ended up triggering a synchronization (most likely // via syncbases), then give that priority. if (hasPendingSynchronization()) return; if (!isTimelineRunning()) return; if (!earliestFireTime.isFinite()) return; scheduleAnimationFrame(earliestFireTime); }
void SMILTimeContainer::updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToTime) { #if !ENABLE(OILPAN) DiscardScope discardScope(m_ownerSVGElement); #endif SMILTime earliestFireTime = updateAnimations(elapsed, seekToTime); // If updateAnimations() ended up triggering a synchronization (most likely // via syncbases), then give that priority. if (hasPendingSynchronization()) return; if (!isTimelineRunning()) return; if (!earliestFireTime.isFinite()) return; scheduleAnimationFrame(earliestFireTime); }
void AnimationControllerPrivate::updateAnimationTimer(SetChanged callSetChanged/* = DoNotCallSetChanged*/) { double timeToNextService = updateAnimations(callSetChanged); LOG(Animations, "updateAnimationTimer: timeToNextService is %.2f", timeToNextService); // If we want service immediately, we start a repeating timer to reduce the overhead of starting if (!timeToNextService) { if (!m_animationTimer.isActive() || m_animationTimer.repeatInterval() == 0) m_animationTimer.startRepeating(cAnimationTimerDelay); return; } // If we don't need service, we want to make sure the timer is no longer running if (timeToNextService < 0) { if (m_animationTimer.isActive()) m_animationTimer.stop(); return; } // Otherwise, we want to start a one-shot timer so we get here again m_animationTimer.startOneShot(timeToNextService); }
void Application::update() { bool continueRunning = true; Ogre::Timer loopTimer; while (continueRunning) { Ogre::WindowEventUtilities::messagePump(); SimpleInputManager::capture(); float elapsedSeconds = loopTimer.getMicroseconds() * 1.0 / 1000000; updateLogic( elapsedSeconds ); updateAnimations( elapsedSeconds ); m_NXOgreVisualDebugger->draw(); m_NXOgreVisualDebuggerNode->needUpdate(); m_NXOgreTimeController->advance(elapsedSeconds); updateOverlayInfo(); loopTimer.reset(); bool renderFrameSuccess = m_root->renderOneFrame(); if (!renderFrameSuccess || m_exitRequested) { continueRunning = false; } } }
void SMILTimeContainer::timerFired() { ASSERT(m_beginTime); ASSERT(!m_pauseTime); updateAnimations(elapsed()); }