本文整理汇总了C++中osgviewer::Viewer::getCameras方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewer::getCameras方法的具体用法?C++ Viewer::getCameras怎么用?C++ Viewer::getCameras使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgviewer::Viewer
的用法示例。
在下文中一共展示了Viewer::getCameras方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool ExportHTML::write(osgPresentation::SlideEventHandler* seh, osgViewer::Viewer& viewer, const std::string& filename)
{
std::string image_basename;
std::string image_ext;
std::string html_basename;
std::string html_ext;
std::string ext = osgDB::getFileExtension(filename);
if (ext=="html" || ext=="htm")
{
image_basename = osgDB::getNameLessExtension(filename);
image_ext = ".jpg";
html_basename = osgDB::getNameLessExtension(filename);
html_ext = std::string(".")+ext;
}
else
{
image_basename = osgDB::getNameLessExtension(filename);
image_ext = ".jpg";
}
std::cout<<"Writing slides to "<<image_basename<<"_[slidenumber]"<<image_ext<<std::endl;
osg::ref_ptr<SnapImageDrawCallback> sidc = new SnapImageDrawCallback;
osgViewer::Viewer::Cameras cameras;
viewer.getCameras(cameras);
for(osgViewer::Viewer::Cameras::iterator itr = cameras.begin();
itr != cameras.end();
++itr)
{
(*itr)->setPostDrawCallback(sidc.get());
}
std::string home_file = createFileName(html_basename, 0, html_ext);
unsigned int i;
for(i=0; i<seh->getNumSlides(); ++i)
{
std::ostringstream os;
os << image_basename <<"_"<<i<<image_ext;
sidc->setFileName(os.str());
sidc->setSnapImageOnNextFrame(true);
if (!html_basename.empty())
{
std::string htmlFileName = createFileName(html_basename, i, html_ext);
std::ofstream fout(htmlFileName.c_str());
if (fout)
{
std::string previous_file = i>0 ? createFileName(html_basename,i-1,html_ext) : "";
std::string next_file = i<seh->getNumSlides()-1 ? createFileName(html_basename,i+1,html_ext) : "";
std::cout<<"Writing html slides "<<htmlFileName<<std::endl;
fout<<"<html>"<<std::endl;
fout<<"<table width=\"100%\">"<<std::endl;
fout<<"<tr>"<<std::endl;
if (!previous_file.empty())
{
fout<<"<td align=\"left\" width=\"33%\"><a href=\""<<osgDB::getSimpleFileName(previous_file)<<"\"> Previous </a></td>"<<std::endl;
}
else
{
fout<<"<td align=\"left\" width=\"33%\"></td>"<<std::endl;
}
if (i != 0)
{
fout<<"<td align=\"center\" width=\"33%\"><a href=\""<<osgDB::getSimpleFileName(home_file)<<"\"> Home </a></td>"<<std::endl;
}
else
{
fout<<"<td align=\"center\" width=\"33%\"></td>"<<std::endl;
}
if (!next_file.empty())
{
fout<<"<td align=\"right\" width=\"33%\"><a href=\""<<osgDB::getSimpleFileName(next_file)<<"\"> Next </a></td>"<<std::endl;
}
else
{
fout<<"<td align=\"right\" width=\"33%\"></td>"<<std::endl;
}
fout<<"</tr>"<<std::endl;
fout<<"</table>"<<std::endl;
fout<<"<img src=\""<<osgDB::getSimpleFileName(os.str())<<"\">"<<std::endl;
fout<<"</html>"<<std::endl;
}
else
{
std::cout<<"Could not open '"<<filename<<"' for writing."<<std::endl;
}
}
// wait for all cull and draw threads to complete.
seh->selectSlide(i, osgPresentation::SlideEventHandler::LAST_POSITION);
// fire off the cull and draw traversals of the scene.
//.........这里部分代码省略.........