当前位置: 首页>>代码示例>>C++>>正文


C++ VideoEntryPtr::getRate方法代码示例

本文整理汇总了C++中VideoEntryPtr::getRate方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoEntryPtr::getRate方法的具体用法?C++ VideoEntryPtr::getRate怎么用?C++ VideoEntryPtr::getRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VideoEntryPtr的用法示例。


在下文中一共展示了VideoEntryPtr::getRate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fortressSimulation_run

void Mechanical::fortressSimulation_run() {
	if (_fortressSimulationInit) {
		// Init sequence
		_vm->_sound->playBackground(_fortressSimulationStartSound1, 65535);
		_vm->wait(5000, true);

		VideoEntryPtr startup = _fortressSimulationStartup->playMovie();
		_vm->playSoundBlocking(_fortressSimulationStartSound2);
		_vm->_sound->playBackground(_fortressSimulationStartSound1, 65535);
		_vm->waitUntilMovieEnds(startup);
		_vm->_sound->stopBackground();
		_vm->_sound->playEffect(_fortressSimulationStartSound2);


		Common::Rect src = Common::Rect(0, 0, 176, 176);
		Common::Rect dst = Common::Rect(187, 3, 363, 179);
		_vm->_gfx->copyImageSectionToBackBuffer(6046, src, dst);
		_vm->_gfx->copyBackBufferToScreen(dst);

		_fortressSimulationStartup->pauseMovie(true);
		VideoEntryPtr holo = _fortressSimulationHolo->playMovie();
		holo->setLooping(true);
		holo->setRate(0);

		// HACK: Support negative rates with edit lists
		_fortressSimulationHoloRate = 0;
		// END HACK

		_vm->_cursor->showCursor();

		_fortressSimulationInit = false;
	} else {
		VideoEntryPtr holo = _fortressSimulationHolo->getVideo();

		double oldRate = holo->getRate().toDouble();

		// HACK: Support negative rates with edit lists
		oldRate = _fortressSimulationHoloRate;
		// END HACK

		uint32 moviePosition = Audio::Timestamp(holo->getTime(), 600).totalNumberOfFrames();

		int32 positionInQuarter = 900 - (moviePosition + 900) % 1800;

		// Are the gears moving?
		if (oldRate >= 0.1 || ABS<int32>(positionInQuarter) >= 30 || _fortressSimulationBrake) {

			double newRate = oldRate;
			if (_fortressSimulationBrake && (double)_fortressSimulationBrake * 0.2 > oldRate) {
				newRate += 0.1;
			}

			// Don't let the gears get stuck between two fortress positions
			if (ABS<double>(oldRate) <= 0.05) {
				if (oldRate <= 0.0) {
					newRate += oldRate;
				} else {
					newRate -= oldRate;
				}
			} else {
				if (oldRate <= 0.0) {
					newRate += 0.05;
				} else {
					newRate -= 0.05;
				}
			}

			// Adjust speed accordingly to acceleration lever
			newRate +=  (double) (positionInQuarter / 1500.0)
					* (double) (9 - _fortressSimulationSpeed) / 9.0;

			newRate = CLIP<double>(newRate, -2.5, 2.5);

			// HACK: Support negative rates with edit lists

			// Our current QuickTime implementation does not support negative
			// playback rates for movies using edit lists.
			// The fortress rotation simulator movie this code handles is the
			// only movie in the game requiring that feature.

			// This hack approximates the next frame to display when the rate
			// is negative, and seeks to it. It's not intended to be precise.

			_fortressSimulationHoloRate = newRate;

			if (_fortressSimulationHoloRate < 0) {
				double newMoviePosition = moviePosition + _fortressSimulationHoloRate * 10;
				holo->setRate(0);
				holo->seek(Audio::Timestamp(0, (uint)newMoviePosition, 600));
			} else {
				holo->setRate(Common::Rational((int)(newRate * 1000.0), 1000));
			}
			// END HACK

			_gearsWereRunning = true;
		} else if (_gearsWereRunning) {
			// The fortress has stopped. Set its new position
			uint16 simulationPosition = (moviePosition + 900) / 1800 % 4;

			holo->setRate(0);
//.........这里部分代码省略.........
开发者ID:AReim1982,项目名称:scummvm,代码行数:101,代码来源:mechanical.cpp

示例2: fortressRotation_run

void Mechanical::fortressRotation_run() {
	VideoEntryPtr gears = _fortressRotationGears->getVideo();

	double oldRate = gears->getRate().toDouble();
	uint32 moviePosition = Audio::Timestamp(gears->getTime(), 600).totalNumberOfFrames();

	// Myst ME short movie workaround, explained in o_fortressRotation_init
	if (_fortressRotationShortMovieWorkaround) {
		// Detect if we just looped
		if (ABS<int32>(_fortressRotationShortMovieLast - 3680) < 50
				&& ABS<int32>(moviePosition) < 50) {
			_fortressRotationShortMovieCount++;
		}

		_fortressRotationShortMovieLast = moviePosition;

		// Simulate longer movie
		moviePosition += 3600 * _fortressRotationShortMovieCount;
	}

	int32 positionInQuarter = 900 - (moviePosition + 900) % 1800;

	// Are the gears moving?
	if (oldRate >= 0.1 || ABS<int32>(positionInQuarter) >= 30 || _fortressRotationBrake) {

		double newRate = oldRate;
		if (_fortressRotationBrake && (double)_fortressRotationBrake * 0.2 > oldRate) {
			newRate += 0.1;
		}

		// Don't let the gears get stuck between two fortress positions
		if (ABS<double>(oldRate) <= 0.05) {
			if (oldRate <= 0.0) {
				newRate += oldRate;
			} else {
				newRate -= oldRate;
			}
		} else {
			if (oldRate <= 0.0) {
				newRate += 0.05;
			} else {
				newRate -= 0.05;
			}
		}

		// Adjust speed accordingly to acceleration lever
		newRate +=  (double) (positionInQuarter / 1500.0)
				* (double) (9 - _fortressRotationSpeed) / 9.0;

		newRate = CLIP<double>(newRate, -2.5, 2.5);

		gears->setRate(Common::Rational((int)(newRate * 1000.0), 1000));

		_gearsWereRunning = true;
	} else if (_gearsWereRunning) {
		// The fortress has stopped. Set its new position
		_fortressPosition = (moviePosition + 900) / 1800 % 4;

		gears->setRate(0);

		if (!_fortressRotationShortMovieWorkaround) {
			gears->seek(Audio::Timestamp(0, 1800 * _fortressPosition, 600));
		} else {
			gears->seek(Audio::Timestamp(0, 1800 * (_fortressPosition % 2), 600));
		}

		_vm->playSoundBlocking(_fortressRotationSounds[_fortressPosition]);

		_gearsWereRunning = false;
	}
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:71,代码来源:mechanical.cpp


注:本文中的VideoEntryPtr::getRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。