本文整理汇总了C++中ToonzScene::getCurrentCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ ToonzScene::getCurrentCamera方法的具体用法?C++ ToonzScene::getCurrentCamera怎么用?C++ ToonzScene::getCurrentCamera使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToonzScene
的用法示例。
在下文中一共展示了ToonzScene::getCurrentCamera方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showEvent
void FormatSettingsPopup::showEvent(QShowEvent *se)
{
#ifdef WIN32
if (m_format == "avi") {
assert(m_codecComboBox);
m_codecComboBox->blockSignals(true);
m_codecComboBox->clear();
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TEnumProperty *eProps = dynamic_cast<TEnumProperty *>(m_props->getProperty(0));
assert(eProps);
TDimension res(0, 0);
if (m_levelPath.isEmpty())
res = scene->getCurrentCamera()->getRes();
else {
TLevelReaderP lr(m_levelPath);
TLevelP level = lr->loadInfo();
const TImageInfo *info = lr->getImageInfo(level->begin()->first);
res.lx = info->m_lx;
res.ly = info->m_ly;
}
TEnumProperty::Range range = eProps->getRange();
int currIndex = -1;
wstring defaultVal = eProps->getValue();
QMap<wstring, bool> usableCodecs = AviCodecRestrictions::getUsableCodecs(res);
for (int i = 0; i < (int)range.size(); i++) {
wstring nameProp = range[i];
if (nameProp == L"Uncompressed" || (usableCodecs.contains(nameProp) && usableCodecs[nameProp])) {
if (nameProp == defaultVal)
currIndex = m_codecComboBox->count();
m_codecComboBox->addItem(QString::fromStdWString(nameProp));
}
}
m_codecComboBox->blockSignals(false);
if (currIndex >= 0)
m_codecComboBox->setCurrentIndex(currIndex);
}
#endif
Dialog::showEvent(se);
}
示例2: multimediaRender
//!Specialized render invocation for multimedia rendering. Flash rendering
//!is currently not supported in this mode.
void RenderCommand::multimediaRender()
{
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
string ext = m_fp.getType();
#ifdef WIN32
if (ext == "avi") {
TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext);
string codecName = props->getProperty(0)->getValueAsString();
TDimension res = scene->getCurrentCamera()->getRes();
if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) {
QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format."));
MsgBox(WARNING, msg);
return;
}
}
#endif;
TOutputProperties *prop = scene->getProperties()->getOutputProperties();
//Build thread count
int index = prop->getThreadIndex();
const int procCount = TSystem::getProcessorCount();
const int threadCounts[3] = {1, procCount / 2, procCount};
int threadCount = threadCounts[index];
//Build raster granularity size
index = prop->getMaxTileSizeIndex();
const int maxTileSizes[4] = {
(std::numeric_limits<int>::max)(),
TOutputProperties::LargeVal,
TOutputProperties::MediumVal,
TOutputProperties::SmallVal};
TRenderSettings rs = prop->getRenderSettings();
rs.m_maxTileSize = maxTileSizes[index];
MultimediaRenderer multimediaRenderer(scene, m_fp, prop->getMultimediaRendering(), threadCount);
multimediaRenderer.setRenderSettings(rs);
#ifdef BRAVODEMO
rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes());
#endif
TPointD cameraDpi = scene->getCurrentCamera()->getDpi();
multimediaRenderer.setDpi(cameraDpi.x, cameraDpi.y);
multimediaRenderer.enablePrecomputing(true);
for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd)
multimediaRenderer.addFrame(m_r);
MultimediaProgressBar *listener =
new MultimediaProgressBar(&multimediaRenderer);
QObject::connect(listener, SIGNAL(canceled()), &multimediaRenderer, SLOT(onCanceled()));
multimediaRenderer.addListener(listener);
multimediaRenderer.start();
}
示例3: rasterRender
void RenderCommand::rasterRender(bool isPreview)
{
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
if (isPreview) {
//Let the PreviewFxManager own the rest. Just pass him the current output node.
PreviewFxManager::instance()->showNewPreview((TFx *)scene->getXsheet()->getFxDag()->getCurrentOutputFx());
return;
}
string ext = m_fp.getType();
#ifdef WIN32
if (ext == "avi" && !isPreview) {
TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext);
string codecName = props->getProperty(0)->getValueAsString();
TDimension res = scene->getCurrentCamera()->getRes();
if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) {
QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format."));
MsgBox(WARNING, msg);
return;
}
}
#endif;
//Extract output properties
TOutputProperties *prop = isPreview ? scene->getProperties()->getPreviewProperties() : scene->getProperties()->getOutputProperties();
//Build thread count
/*-- Dedicated CPUs のコンボボックス (Single, Half, All) --*/
int index = prop->getThreadIndex();
const int procCount = TSystem::getProcessorCount();
const int threadCounts[3] = {1, procCount / 2, procCount};
int threadCount = threadCounts[index];
/*-- MovieRendererを作る。Previewの場合はファイルパスは空 --*/
MovieRenderer movieRenderer(scene, isPreview ? TFilePath() : m_fp, threadCount, isPreview);
TRenderSettings rs = prop->getRenderSettings();
//Build raster granularity size
index = prop->getMaxTileSizeIndex();
const int maxTileSizes[4] = {
(std::numeric_limits<int>::max)(),
TOutputProperties::LargeVal,
TOutputProperties::MediumVal,
TOutputProperties::SmallVal};
rs.m_maxTileSize = maxTileSizes[index];
//Build
#ifdef BRAVODEMO
rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes());
#endif
/*-- RenderSettingsをセット --*/
movieRenderer.setRenderSettings(rs);
/*-- カメラDPIの取得、セット --*/
TPointD cameraDpi = isPreview ? scene->getCurrentPreviewCamera()->getDpi() : scene->getCurrentCamera()->getDpi();
movieRenderer.setDpi(cameraDpi.x, cameraDpi.y);
movieRenderer.enablePrecomputing(true);
/*-- プログレス ダイアログの作成 --*/
RenderListener *listener =
new RenderListener(movieRenderer.getTRenderer(), m_fp, ((m_numFrames - 1) / m_step) + 1, isPreview);
QObject::connect(listener, SIGNAL(canceled()), &movieRenderer, SLOT(onCanceled()));
movieRenderer.addListener(listener);
bool fieldRendering = rs.m_fieldPrevalence != TRenderSettings::NoField;
/*-- buildSceneFxの進行状況を表示するプログレスバー --*/
QProgressBar *buildSceneProgressBar = new QProgressBar(TApp::instance()->getMainWindow());
buildSceneProgressBar->setAttribute(Qt::WA_DeleteOnClose);
buildSceneProgressBar->setWindowFlags(Qt::SubWindow | Qt::Dialog | Qt::WindowStaysOnTopHint);
buildSceneProgressBar->setMinimum(0);
buildSceneProgressBar->setMaximum(m_numFrames - 1);
buildSceneProgressBar->setValue(0);
buildSceneProgressBar->move(600, 500);
buildSceneProgressBar->setWindowTitle("Building Schematic...");
buildSceneProgressBar->show();
for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) {
buildSceneProgressBar->setValue(i);
if (rs.m_stereoscopic)
scene->shiftCameraX(-rs.m_stereoscopicShift / 2);
TFxPair fx;
fx.m_frameA = buildSceneFx(scene, m_r, rs.m_shrinkX, isPreview);
if (fieldRendering && !isPreview)
fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview);
else if (rs.m_stereoscopic) {
scene->shiftCameraX(rs.m_stereoscopicShift);
fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview);
scene->shiftCameraX(-rs.m_stereoscopicShift / 2);
} else
fx.m_frameB = TRasterFxP();
/*-- movieRendererにフレーム毎のFxを登録 --*/
//.........这里部分代码省略.........
示例4: flashRender
void RenderCommand::flashRender()
{
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TSceneProperties *sprop = scene->getProperties();
FILE *fileP = fopen(m_fp, "wb");
if (!fileP)
return;
ProgressDialog pb("rendering " + toQString(m_fp), "Cancel", 0, m_numFrames);
pb.show();
TDimension cameraSize = scene->getCurrentCamera()->getRes();
double frameRate = sprop->getOutputProperties()->getFrameRate();
TFlash flash(
cameraSize.lx,
cameraSize.ly,
m_numFrames,
frameRate,
sprop->getOutputProperties()->getFileFormatProperties("swf"));
flash.setBackgroundColor(sprop->getBgColor());
std::vector<TXshSoundColumn *> columns;
scene->getSoundColumns(columns);
if (!columns.empty()) {
TXsheet::SoundProperties *prop = new TXsheet::SoundProperties();
prop->m_frameRate = frameRate;
TSoundTrack *st = scene->getXsheet()->makeSound(prop);
if (st)
flash.putSound(st, 0);
}
int i = 0;
for (i = 0; i < m_numFrames; ++i, m_r += m_stepd) {
flash.beginFrame(m_step * i + 1);
TRasterFxP rfx = buildSceneFx(scene, m_r, 0, false);
assert(rfx);
rfx->compute(flash, tround(m_r)); // WARNING: This should accept a DOUBLE...
#ifdef BRAVODEMO
TRasterImageP ri(loadBravo(scene->getCurrentCamera()->getRes()));
int lx = ri->getRaster()->getLx();
int ly = ri->getRaster()->getLx();
flash.pushMatrix();
int dx = tround(0.1 * (cameraSize.lx - lx));
int dy = tround(0.1 * (cameraSize.ly - ly));
flash.multMatrix(TTranslation((cameraSize.lx - lx) / 2 - (dx > 0 ? dx : 0), -(cameraSize.ly - ly) / 2 + (dy > 0 ? dy : 0)));
flash.draw(ri, 0);
flash.popMatrix();
#endif
flash.endFrame(i == m_numFrames - 1, 0, true);
if (pb.wasCanceled())
break;
pb.setValue(i + 1);
}
flash.writeMovie(fileP);
fclose(fileP);
TSystem::showDocument(m_fp);
//QDesktopServices::openUrl(QUrl(toQString(m_fp)));
TImageCache::instance()->remove(toString(m_fp.getWideString() + L".0"));
TNotifier::instance()->notify(TSceneNameChange());
}
示例5: init
bool RenderCommand::init(bool isPreview)
{
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
TSceneProperties *sprop = scene->getProperties();
/*-- Preview/Renderに応じてそれぞれのSettingを取得 --*/
TOutputProperties &outputSettings = isPreview ? *sprop->getPreviewProperties() : *sprop->getOutputProperties();
outputSettings.getRange(m_r0, m_r1, m_step);
/*-- シーン全体のレンダリングの場合、m_r1をScene長に設定 --*/
if (m_r0 == 0 && m_r1 == -1) {
m_r0 = 0;
m_r1 = scene->getFrameCount() - 1;
}
if (m_r0 < 0)
m_r0 = 0;
if (m_r1 >= scene->getFrameCount())
m_r1 = scene->getFrameCount() - 1;
if (m_r1 < m_r0) {
MsgBox(WARNING, QObject::tr("The command cannot be executed because the scene is empty."));
return false;
// throw TException("empty scene");
// non so perche', ma termina il programma
// nonostante il try all'inizio
}
// Initialize the preview case
/*TRenderSettings rs = sprop->getPreviewProperties()->getRenderSettings();
TRenderSettings rso = sprop->getOutputProperties()->getRenderSettings();
rs.m_stereoscopic=true;
rs.m_stereoscopicShift=0.05;
rso.m_stereoscopic=true;
rso.m_stereoscopicShift=0.05;
sprop->getPreviewProperties()->setRenderSettings(rs);
sprop->getOutputProperties()->setRenderSettings(rso);*/
if (isPreview) {
/*-- PreviewではTimeStretchを考慮しないので、そのままフレーム値を格納してゆく --*/
m_numFrames = (int)(m_r1 - m_r0 + 1);
m_r = m_r0;
m_stepd = m_step;
m_multimediaRender = 0;
return true;
}
// Full render case
// Read the output filepath
TFilePath fp = outputSettings.getPath();
/*-- ファイル名が指定されていない場合は、シーン名を出力ファイル名にする --*/
if (fp.getWideName() == L"")
fp = fp.withName(scene->getScenePath().getName());
/*-- ラスタ画像の場合、ファイル名にフレーム番号を追加 --*/
if (TFileType::getInfo(fp) == TFileType::RASTER_IMAGE || fp.getType() == "pct" || fp.getType() == "pic" || fp.getType() == "pict") //pct e' un formato"livello" (ha i settings di quicktime) ma fatto di diversi frames
fp = fp.withFrame(TFrameId::EMPTY_FRAME);
fp = scene->decodeFilePath(fp);
if (!TFileStatus(fp.getParentDir()).doesExist()) {
try {
TFilePath parent = fp.getParentDir();
TSystem::mkDir(parent);
DvDirModel::instance()->refreshFolder(parent.getParentDir());
} catch (TException &e) {
MsgBox(WARNING, QObject::tr("It is not possible to create folder : %1").arg(QString::fromStdString(toString(e.getMessage()))));
return false;
} catch (...) {
MsgBox(WARNING, QObject::tr("It is not possible to create a folder."));
return false;
}
}
m_fp = fp;
// Retrieve camera infos
const TCamera *camera = isPreview ? scene->getCurrentPreviewCamera() : scene->getCurrentCamera();
TDimension cameraSize = camera->getRes();
TPointD cameraDpi = camera->getDpi();
// Retrieve render interval/step/times
double stretchTo = (double)outputSettings.getRenderSettings().m_timeStretchTo;
double stretchFrom = (double)outputSettings.getRenderSettings().m_timeStretchFrom;
m_timeStretchFactor = stretchTo / stretchFrom;
m_stepd = m_step / m_timeStretchFactor;
int stretchedR0 = tfloor(m_r0 * m_timeStretchFactor);
int stretchedR1 = tceil((m_r1 + 1) * m_timeStretchFactor) - 1;
m_r = stretchedR0 / m_timeStretchFactor;
m_numFrames = (stretchedR1 - stretchedR0) / m_step + 1;
// Update the multimedia render switch
m_multimediaRender = outputSettings.getMultimediaRendering();
return true;
}
示例6: addFrame
bool addFrame(ToonzScene &scene, int row, bool isLast) {
assert(m_status == 3);
if (!m_started) start(scene);
TDimension cameraRes = scene.getCurrentCamera()->getRes();
TDimensionD cameraSize = scene.getCurrentCamera()->getSize();
TPointD center(0.5 * cameraSize.lx, 0.5 * cameraSize.ly);
double sx = (double)m_offlineGlContext.getLx() / (double)cameraRes.lx;
double sy = (double)m_offlineGlContext.getLy() / (double)cameraRes.ly;
double sc = std::min(sx, sy);
// TAffine cameraAff =
// scene.getXsheet()->getPlacement(TStageObjectId::CameraId(0), row);
TAffine cameraAff = scene.getXsheet()->getCameraAff(row);
double dpiScale =
(1.0 / Stage::inch) * (double)cameraRes.lx / cameraSize.lx;
// TAffine viewAff = TScale(dpiScale*sc) * TTranslation(center)*
// cameraAff.inv();
TAffine viewAff = TTranslation(0.5 * cameraRes.lx, 0.5 * cameraRes.ly) *
TScale(dpiScale * sc) * cameraAff.inv();
TRect clipRect(m_offlineGlContext.getBounds());
TPixel32 bgColor = scene.getProperties()->getBgColor();
m_offlineGlContext.makeCurrent();
TPixel32 bgClearColor = m_bgColor;
if (m_alphaEnabled && m_alphaNeeded) {
const double maxValue = 255.0;
double alpha = (double)bgClearColor.m / maxValue;
bgClearColor.r *= alpha;
bgClearColor.g *= alpha;
bgClearColor.b *= alpha;
}
m_offlineGlContext.clear(bgClearColor);
Stage::VisitArgs args;
args.m_scene = &scene;
args.m_xsh = scene.getXsheet();
args.m_row = row;
args.m_col = m_columnIndex;
args.m_osm = &m_osMask;
ImagePainter::VisualSettings vs;
Stage::OpenGlPainter painter(viewAff, clipRect, vs, false, true);
Stage::visit(painter, args);
/*
painter,
&scene,
scene.getXsheet(), row,
m_columnIndex, m_osMask,
false,0);
*/
TImageWriterP writer = m_lw->getFrameWriter(m_frameIndex++);
if (!writer) return false;
#ifdef MACOSX
glFinish(); // per fissare il bieco baco su Mac/G3
#endif
TRaster32P raster = m_offlineGlContext.getRaster();
#ifdef MACOSX
if (m_alphaEnabled && m_alphaNeeded)
checkAndCorrectPremultipliedImage(raster);
#endif
if (Preferences::instance()->isSceneNumberingEnabled())
TRasterImageUtils::addSceneNumbering(TRasterImageP(raster),
m_frameIndex - 1,
scene.getSceneName(), row + 1);
TRasterImageP img(raster);
writer->save(img);
return true;
}