double MovieDecoderBase::getMovieTime(double theSystemTime) { DB(AC_TRACE << "getMovieTime start: _myMovieTime: " << _myMovieTime << ", theSystemTime: " << theSystemTime << ", _myLastSystemTime: " << _myLastSystemTime); if (theSystemTime <= _myLastSystemTime) { return _myMovieTime; } float myPlaySpeed = _myMovie->get<PlaySpeedTag>(); if (_myLastSystemTime >= 0) { _myMovieTime += (theSystemTime - _myLastSystemTime) * myPlaySpeed; // if difference between last system time and current system time is bigger than movie duration if (getFrameCount() != -1 && _myMovieTime * getFrameRate() > getFrameCount()) { _myMovieTime = getFrameCount() / getFrameRate(); } // Calculate the wraparaound for reverse playback if (_myMovieTime < 0) { unsigned myFrameCount = getFrameCount(); if (myFrameCount == static_cast<unsigned>(-1) || myFrameCount == 0) { AC_WARNING << "Movie cannot play backwards, because its framecount is unknown (framecount=" << myFrameCount << ")"; _myMovieTime = 0; } else { double myIncrement = getFrameCount() / getFrameRate(); while (_myMovieTime < 0) { _myMovieTime += myIncrement; } } } } _myLastSystemTime = theSystemTime; DB(AC_TRACE << "getMovieTime end: _myMovieTime: " << _myMovieTime << ", theSystemTime: " << theSystemTime << ", _myLastSystemTime: " << _myLastSystemTime); return _myMovieTime; }
int PcmChunk::seek(int frames) { idx_ += frames; if (idx_ > getFrameCount()) idx_ = getFrameCount(); if (idx_ < 0) idx_ = 0; return idx_; }
int PcmChunk::seek(int frames) { if ((frames < 0) && (-frames > (int)idx_)) frames = -idx_; idx_ += frames; if (idx_ > getFrameCount()) idx_ = getFrameCount(); return idx_; }
void VMotiveFrame::increaseFrameIndex() { if (m_PlayBack) { if (m_CurrentFrameIdx > 0) --m_CurrentFrameIdx; else m_CurrentFrameIdx = m_CurrentFrameIdx < getFrameCount() - 1; } else { if (m_CurrentFrameIdx < getFrameCount() - 1) ++m_CurrentFrameIdx; else m_CurrentFrameIdx = 0; } }
void VMotiveFrame::playCount(long nCount, long nStartIdx) { if (nCount <= 0) return; if (nStartIdx < 0) nStartIdx = 0; if (nStartIdx >= getFrameCount()) nStartIdx = getFrameCount() - 1; stop(); m_bDoneStop = false; this->setIsVisible(true); m_PlayType = ptCount; m_PlayCount = nCount; m_CurrentFrameIdx = nStartIdx; doDrawFrame(m_CurrentFrameIdx); }
// set sample by frame and channel void AudioData::setSample(unsigned int frame, unsigned int channel, float value){ if(frame >= getFrameCount()){ std::ostringstream ss; ss << "Cannot set out-of-bounds frame (" << frame << "/" << getFrameCount() << ")"; throw Exception(ss.str().c_str()); } if(channel >= channels){ std::ostringstream ss; ss << "Cannot set out-of-bounds channel (" << channel << "/" << channels << ")"; throw Exception(ss.str().c_str()); } setSample(frame * channels + channel, value); }
// get sample by frame and channel float AudioData::getSample(unsigned int frame, unsigned int channel) const{ if(frame >= getFrameCount()){ std::ostringstream ss; ss << "Cannot get out-of-bounds frame (" << frame << "/" << getFrameCount() << ")"; throw Exception(ss.str().c_str()); } if(channel >= channels){ std::ostringstream ss; ss << "Cannot get out-of-bounds channel (" << channel << "/" << channels << ")"; throw Exception(ss.str().c_str()); } return getSample(frame * channels + channel); }
//该函数不支持多线程 string BaseManager::pickMovableObject( int x,int y ){ //如果相同的帧同时相同的x,y就直接返回结果 if( mPickFrameCount == getFrameCount() && mPickX == x && mPickY == y ){ return mPickName; } mRay = mCamera->getCameraToViewportRay( (Ogre::Real)x/(Ogre::Real)mWindow->getWidth(), (Ogre::Real)y/(Ogre::Real)mWindow->getHeight() ); mSceneQuery->setRay( mRay ); //距离排序 mSceneQuery->setSortByDistance(true); Ogre::RaySceneQueryResult result = mSceneQuery->execute(); //execute不能执行像素级的查询,它仅仅是和包围盒进行比较 //可以考虑使用渲染到纹理,使用1x1的纹理来对查询结果进行像素级别的查询 //这里使用逐个求交点的办法 Ogre::MovableObject* pmo = nullptr; Ogre::Real dis; for( size_t i = 0;i < result.size();++i ){ if( result[i].movable && result[i].movable->isVisible() && //不可见的 result[i].movable->isInScene() ){ //不在场景中的 mIntersect = false; result[i].movable->visitRenderables(this); if( mIntersect ){ //考虑到同一帧中间有多个地方的代码需要调用该函数 //这样使用内存换速度 if( !pmo || dis>mIntersectDistance ){ dis = mIntersectDistance; pmo = result[i].movable; } } } } if( pmo ){ mPickX = x; mPickY = y; mPickFrameCount = getFrameCount(); mPickName = pmo->getName(); return mPickName; } //返回一个空字串表示没有 return ""; }
void ProtoRootBall02::display(){ // wall push(); translate(0, 0, -14); scale(13.75, 12.75, 1); rotate(90, 1, 0, 0); plane.display(); pop(); // ground push(); translate(0, -7, 5); scale(13.75, 1, 10); ground.display(); pop(); float width = 5; float height = 5; float depth = 5; float colSpan = width / (W - 1); float rowSpan = height / (H - 1); float layerSpan = depth / (D - 1); int counter = 0; arcballBegin(); push(); rotate(getFrameCount()*.15f, 0, 1, 0); rotate(getFrameCount()*.165f, 0, 0, 1); rotate(getFrameCount()*.05f, 1, 0, 0); for (int i = 0; i < W; ++i){ for (int j = 0; j < H; ++j){ for (int k = 0; k < D; ++k){ push(); translate(colSpan*i - width / 2, rowSpan*j - height / 2, layerSpan*k - depth / 2); scale(.2); rotate(-getFrameCount()*.75, toroids[counter].getRotation().x, toroids[counter].getRotation().y, toroids[counter].getRotation().z); toroids[counter].display(); pop(); counter++; } } } pop(); arcballEnd(); }
void AnimationHandler::generateAnimations(std::vector<AnimationDescriptor*> animationList) { CCLOG("AnimationHandler::generateAnimations initialized"); CCLOG("=Generating animations objects."); int animCount = animationList.size(); Vector<SpriteFrame*>* vectorBuffer = new Vector<SpriteFrame*>[animCount]; for(int c = 0; c < animCount;c++) { auto elem = animationList.at(c); std::string pattern = elem->getPattern(); int frameCount = elem->getFrameCount(); float speed = elem->getAnimationSpeed() == 0? DEFAULT_SPEED : elem->getAnimationSpeed(); std::string status = elem->getStatus(); this->loadFrameBuffer(vectorBuffer[c], frameCount, pattern); _animations.push_back(Animation::createWithSpriteFrames(vectorBuffer[c], speed)); _actions[status] = generateAction(elem, _animations.at(c)); _actions[status]->retain(); } delete[] vectorBuffer; CCLOG("AnimationHandler::generateAnimations done."); }
ffmpegFileInfo Ffmpeg::getInfo() { QString ffmpegCachePath = getFfmpegCache().getQString(); QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols() + ".txt"; if (QFile::exists(tempPath)) { QFile infoText(tempPath); infoText.open(QIODevice::ReadOnly); QByteArray ba = infoText.readAll(); infoText.close(); QString text = QString::fromStdString(ba.toStdString()); m_lx = text.split(" ")[0].toInt(); m_ly = text.split(" ")[1].toInt(); m_frameRate = text.split(" ")[2].toDouble(); m_frameCount = text.split(" ")[3].toInt(); } else { QFile infoText(tempPath); getSize(); getFrameRate(); getFrameCount(); infoText.open(QIODevice::WriteOnly); std::string infoToWrite = std::to_string(m_lx) + " " + std::to_string(m_ly) + " " + std::to_string(m_frameRate) + " " + std::to_string(m_frameCount); int infoLength = infoToWrite.length(); infoText.write(infoToWrite.c_str(), infoLength); infoText.close(); } ffmpegFileInfo info; info.m_lx = m_lx; info.m_ly = m_ly; info.m_frameRate = m_frameRate; info.m_frameCount = m_frameCount; return info; }
Passibility TileDef::getPassiblity(int frameNumber) { if (frameNumber < 0 || frameNumber >= getFrameCount()) { throw out_of_range("The specified frame number is out of range: " + to_string(frameNumber)); } return _passibilities[frameNumber]; }
Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getDuration() const { // Since Audio::Timestamp doesn't support a fractional frame rate, we're currently // just converting to milliseconds. Common::Rational time = getFrameCount() * 1000; time /= getFrameRate(); return time.toInt(); }
FrameInfo EmulatorCallStack::getFrameInfo(unsigned int frame) const { FrameInfo info; // Rewind to the specified frame unsigned int framesToRewind = getFrameCount() - 1 - frame; unsigned int currentFrame = _stackPointer; auto size = _stackFrameSizes.rbegin(); auto localSize = _localMemorySizes.rbegin(); auto registerFileSize = _registerFileSizes.rbegin(); auto sharedMemorySize = _sharedMemorySizes.rbegin(); for(unsigned int i = 0; i < framesToRewind; ++i) { assert( size != _stackFrameSizes.rend()); assert( localSize != _localMemorySizes.rend()); assert(registerFileSize != _registerFileSizes.rend()); assert(sharedMemorySize != _sharedMemorySizes.rend()); unsigned int totalPreviousSize = (*size + *registerFileSize * sizeof(RegisterType) + *localSize) * _threadCount + align(3 * sizeof(unsigned int)); currentFrame -= totalPreviousSize; } // Fill in the info info.pc = *(unsigned int*)_stackBase(currentFrame); return info; }
bool Sprite::load(const char *filename) { SDL_RWops *frameStream; SDL_RWops *rotatedStream; unsigned i = 0; while (true) { std::ostringstream frameName; frameName << filename << i << ".png"; frameStream = Toolkit::getFileManager()->open(frameName.str().c_str(), "rb"); std::ostringstream frameNameRot; frameNameRot << filename << i << "r.png"; rotatedStream = Toolkit::getFileManager()->open(frameNameRot.str().c_str(), "rb"); if (!((frameStream) || (rotatedStream))) break; loadFrame(frameStream, rotatedStream); if (frameStream) SDL_RWclose(frameStream); if (rotatedStream) SDL_RWclose(rotatedStream); i++; } return getFrameCount() > 0; }
Entity *addGasPlant(int x, int y, char *name) { int frameCount; Entity *e = getFreeEntity(); if (e == NULL) { showErrorAndExit("No free slots to add a Gas Plant"); } loadProperties(name, e); e->x = x; e->y = y; e->action = &init; e->draw = &drawLoopingAnimationToMap; e->die = &entityDie; e->touch = &entityTouch; e->takeDamage = &takeDamage; e->type = ENEMY; setEntityAnimation(e, "STAND"); frameCount = getFrameCount(e); e->currentFrame = prand() % frameCount; return e; }
void VMotiveFrame::setStopIdx(long nIdx) { if ((nIdx >= 0) && (nIdx < getFrameCount())) { m_StopIdx = nIdx; } }
bool CvFrameSource::hasNext() { if (getFramePosition()<(getFrameCount()-1)) return true; else return false; }
int DummyCodec::encode(char *dest, char *src) { int size = getFrameCount()*getFrameSize(); memcpy(dest, src, size); return size; }
void ProtoController::display() { //setLight(0, Vec3(sin(radians(getFrameCount()*.25f)) * 390, 0, 200), { 1, 1, 1 }); translate(0, 0, 0); arcBallBegin(); push(); translate(0, 0, -200); scale(2.5); rotate(getFrameCount()*.6*PI / 180, { .75f, 1, .25f }); tube.display(WIREFRAME, 6.0f); pop(); push(); rotate(getFrameCount()*.6*PI / 180, { .75f, -0.5f, .25f }); //t.display(); pop(); push(); translate(-300, 50, 50); scale(0.75f); rotate(getFrameCount()*.6*PI / 180, { -.75f, 0.5f, -.25f }); //t.display(); pop(); push(); translate(-300, 50, 300); scale(1.75f); rotate(getFrameCount()*.6*PI / 180, { -.75f, 0.5f, -.25f }); //t.display(); pop(); push(); translate(0, -50, 600); scale(2.25f); rotate(getFrameCount()*.9*PI / 180, { -.75f, 0.5f, -.25f }); //t.display(); pop(); push(); translate(0, 0, -500); scale({ 1024*2, 768*2, 1 }); plane.display(); pop(); arcBallEnd(); }
void TileDef::setPassiblity(int frameNumber, Passibility passability) { if (frameNumber < 0 || frameNumber >= getFrameCount()) { throw out_of_range("The specified frame number is out of range." + to_string(frameNumber)); } _passibilities[frameNumber] = passability; _passabilityMap[passability.getInternalValue()] = frameNumber; }
uint Animation::nextFrameNum() const { if (_paused) return _currentFrame; if ((_currentFrame == getFrameCount() - 1) && _looping) return 0; else return _currentFrame + 1; }
//---------------------------------------------------------------------------- ActionObject011::ActionObject011(int screenWidth, int screenHeight, QPoint startPos) :ActionObject("action010_*.png",6,screenWidth,screenHeight, startPos) { //---------------------------------------------------------------------------- setXSpeed(-50); setYSpeed(+2); m_liveCounter= getFrameCount(); }
void Animation::nextFrame(bool force) { // If there are no frames or if the animation is not playing, return if (getFrameCount() == 0 || !_playing) return; const Drawable *frame = getConstCurrentFrame(); Surface *surface = _vm->_screen->getSurface(); if (force || (_tick + frame->getDelay() <= _vm->_system->getMillis()) || (_canBeQuick && _vm->_game->getEnableQuickHero() && _vm->_game->getWantQuickHero())) { // If we are at the last frame and not looping, stop the animation // The animation is also restarted to frame zero if ((_currentFrame == getFrameCount() - 1) && !_looping) { // When the animation reaches its end, call the preset callback (this->*_callback)(); } else { // Mark old frame dirty so it gets deleted markDirtyRect(surface); _shift.x += _relativeShifts[_currentFrame].x; _shift.y += _relativeShifts[_currentFrame].y; _currentFrame = nextFrameNum(); _tick = _vm->_system->getMillis(); // Fetch new frame and mark it dirty markDirtyRect(surface); // If the animation is paused, then nextFrameNum() // returns the same frame number even though the time // has elapsed to switch to another frame. We must not // flip _hasChangedFrame to true, otherwise the sample // assigned to this frame will be re-started over and // over until all sound handles are exhausted (happens, // e.g., when switching to the inventory which pauses // all animations). _hasChangedFrame = !_paused; } } debugC(6, kDraciAnimationDebugLevel, "anim=%d tick=%d delay=%d tick+delay=%d currenttime=%d frame=%d framenum=%d x=%d y=%d z=%d", _id, _tick, frame->getDelay(), _tick + frame->getDelay(), _vm->_system->getMillis(), _currentFrame, _frames.size(), frame->getX() + getRelativeX(), frame->getY() + getRelativeY(), _z); }
void XAP_App::rebuildMenus(void) { UT_uint32 frameCount = getFrameCount(); for (UT_uint32 i = 0; i < frameCount; i++) if (XAP_Frame * pFrame = getFrame(i)) { pFrame->rebuildMenus(); } }
void Animation::markDirtyRect(Surface *surface) const { if (getFrameCount() == 0) return; // Fetch the current frame's rectangle const Drawable *frame = getConstCurrentFrame(); Common::Rect frameRect = frame->getRect(getCurrentFrameDisplacement()); // Mark the rectangle dirty on the surface surface->markDirtyRect(frameRect); }
void VMotiveFrame::setCurrentFrameIndex(long idx) { if ((idx >= 0) && (idx < getFrameCount())) { this->setIsVisible(true); if ((m_PlayType == ptNone) && (m_CurrentFrameIdx != idx)) { m_CurrentFrameIdx = idx; doDrawFrame(m_CurrentFrameIdx); } } }
// Loads the animation using data from a JSON structure void Animation::deserialize(Json::Value &configData) { std::string frame = DataManager::getString(configData, "frame", getFrameName()); std::string extension = DataManager::getString(configData, "ext", getFrameExtension()); int count = DataManager::getInt (configData, "frames", getFrameCount()); float delay = DataManager::getFloat (configData, "delay", getFrameDelay()); init(frame, extension, count, delay); setName (DataManager::getString (configData, "name", getName())); setLooping (DataManager::getBool (configData, "loop", isLooping())); allowEventGeneration(DataManager::getBool (configData, "alert", isGeneratingEvents())); }
SINT SoundSourceModPlug::readSampleFrames( SINT numberOfFrames, CSAMPLE* sampleBuffer) { DEBUG_ASSERT(0 <= numberOfFrames); DEBUG_ASSERT(isValidFrameIndex(m_seekPos)); const SINT readFrames = math_min(getFrameCount() - m_seekPos, numberOfFrames); const SINT readSamples = frames2samples(readFrames); const SINT readOffset = frames2samples(m_seekPos); SampleUtil::convertS16ToFloat32(sampleBuffer, &m_sampleBuf[readOffset], readSamples); m_seekPos += readFrames; return readFrames; }
IplImage* CvFrameSource::setFramePosition(int pos) { if (getFramePosition() != pos && pos<(getFrameCount()-1)) { cvSetCaptureProperty(sourceCapture, CV_CAP_PROP_POS_FRAMES, pos-1); nextIplImage=cvQueryFrame(sourceCapture); emit { updated(nextIplImage); frameChanged(getFramePosition()); } }