예제 #1
0
 FlashMovieGenerator(const TFilePath &fp, const TDimension cameraSize,
                     TOutputProperties &properties)
     : Imp(fp, cameraSize, properties.getFrameRate())
     , m_flash(cameraSize.lx, cameraSize.ly, 0, properties.getFrameRate(),
               properties.getFileFormatProperties("swf"))
     , m_frameIndex(0)
     , m_sceneIndex(0)
     , m_frameCountLoader(0)
     , m_screenSaverMode(false) {
   TPointD center(0.5 * cameraSize.lx, 0.5 * cameraSize.ly);
   m_viewAff         = TAffine();
   m_screenSaverMode = fp.getType() == "scr";
 }
예제 #2
0
 RasterMovieGenerator(const TFilePath &fp, const TDimension cameraSize,
                      TOutputProperties &properties)
     : Imp(fp, cameraSize, properties.getFrameRate())
     , m_frameIndex(1)
     , m_started(false)
     , m_offlineGlContext(*TOfflineGL::getStock(cameraSize))
     , m_st(0)
     , m_whiteSample(0)
     , m_fileOptions(0)
     , m_alphaEnabled(false)
     , m_alphaNeeded(false)
     , m_status(0) {
   m_bgColor = TPixel32(255, 255, 255, 0);
   TPointD center(0.5 * cameraSize.lx, 0.5 * cameraSize.ly);
   m_viewAff       = TTranslation(center);
   std::string ext = fp.getType();
   m_isFrames      = ext != "avi" && ext != "mov" && ext != "3gp";
   m_fileOptions   = properties.getFileFormatProperties(ext);
 }
예제 #3
0
void MovieRenderer::Imp::prepareForStart()
{
	struct locals {
		static void eraseUncompatibleExistingLevel(const TFilePath &fp, const TDimension &imageSize) // nothrow
		{
			assert(!fp.isEmpty());

			if (TSystem::doesExistFileOrLevel(fp)) {
				bool remove = false;

				// In case the raster specifics are different from those of a currently
				// existing movie, erase it
				try {
					TLevelReaderP lr(fp);
					lr->loadInfo();

					const TImageInfo *info = lr->getImageInfo();
					if (!info || info->m_lx != imageSize.lx || info->m_ly != imageSize.ly)
						TSystem::removeFileOrLevel(fp); // nothrow
				} catch (...) {
					// Same if the level could not be read/opened
					TSystem::removeFileOrLevel(fp); // nothrow
				}

				// NOTE: The level removal procedure could still fail.
				// In this case, no signaling takes place. The level readers will throw
				// when the time to write on the file comes, leading to a render failure.
			}
		}
	};

	TOutputProperties *oprop = m_scene->getProperties()->getOutputProperties();
	double frameRate = (double)oprop->getFrameRate();

	/*-- Frame rate の stretch --*/
	double stretchFactor = oprop->getRenderSettings().m_timeStretchTo / oprop->getRenderSettings().m_timeStretchFrom;
	frameRate *= stretchFactor;

	// Get the shrink
	int shrinkX = m_renderSettings.m_shrinkX, shrinkY = m_renderSettings.m_shrinkY;

	//Build the render area
	TPointD cameraPos(-0.5 * m_frameSize.lx, -0.5 * m_frameSize.ly);
	TDimensionD cameraRes(double(m_frameSize.lx) / shrinkX, double(m_frameSize.ly) / shrinkY);
	TDimension cameraResI(cameraRes.lx, cameraRes.ly);

	TRectD renderArea(cameraPos.x, cameraPos.y, cameraPos.x + cameraRes.lx, cameraPos.y + cameraRes.ly);
	setRenderArea(renderArea);

	if (!m_fp.isEmpty()) {
		try // Construction of a LevelUpdater may throw (well, almost ANY operation on a LevelUpdater
		{   // could throw). But due to backward compatibility this function is assumed to be non-throwing.
			if (!m_renderSettings.m_stereoscopic) {
				locals::eraseUncompatibleExistingLevel(m_fp, cameraResI);

				m_levelUpdaterA.reset(new LevelUpdater(m_fp, oprop->getFileFormatProperties(m_fp.getType())));
				m_levelUpdaterA->getLevelWriter()->setFrameRate(frameRate);
			} else {
				TFilePath leftFp = m_fp.withName(m_fp.getName() + "_l");
				TFilePath rightFp = m_fp.withName(m_fp.getName() + "_r");

				locals::eraseUncompatibleExistingLevel(leftFp, cameraResI);
				locals::eraseUncompatibleExistingLevel(rightFp, cameraResI);

				m_levelUpdaterA.reset(new LevelUpdater(leftFp, oprop->getFileFormatProperties(leftFp.getType())));
				m_levelUpdaterA->getLevelWriter()->setFrameRate(frameRate);

				m_levelUpdaterB.reset(new LevelUpdater(rightFp, oprop->getFileFormatProperties(rightFp.getType())));
				m_levelUpdaterB->getLevelWriter()->setFrameRate(frameRate);
			}
		} catch (...) {
			// If we get here, it's because one of the LevelUpdaters could not be created. So, let's say
			// that if one could not be created, then ALL OF THEM couldn't (ie saving is not possible at all).
			m_levelUpdaterA.reset();
			m_levelUpdaterB.reset();
		}
	}
}