示例#1
0
    ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
    {
        std::string ext( osgDB::getLowerCaseFileExtension(fileName) );
        if( !acceptsExtension(ext) )
            return ReadResult::FILE_NOT_HANDLED;

        osg::notify(osg::INFO) << "ReaderWriterOSGVIEWER( \"" << fileName << "\" )" << std::endl;

        // strip the pseudo-loader extension, which must leave a sub-filename.
        std::string subFileName( osgDB::getNameLessExtension( fileName ) );
        if( subFileName == fileName )
        {
            osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        // recursively load the subfile.
        // first try to load as osg::Node
        osg::Node* node( osgDB::readNodeFile( subFileName, options ) );
        if( node )
        {
            return node;
        }

        // else try to load as osg::Image, which will be applied to a quad.
        osg::Image* image( readImageFile(subFileName.c_str(), options) );
        if( image )
        {
            return osg::createGeodeForImage(image);
        }

        // propagate the read failure upwards
        osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl;
        return ReadResult::FILE_NOT_HANDLED;
    }
示例#2
0
    ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* rw_options) const
    {
        std::string ext( osgDB::getLowerCaseFileExtension(fileName) );
        if( !acceptsExtension(ext) )  return ReadResult::FILE_NOT_HANDLED;

        osgToy::GlslLint::Options lint_options( osgToy::GlslLint::NONE );
        if( rw_options )
        {
            std::istringstream iss( rw_options->getOptionString() );
            std::string opt;

            while( getline( iss, opt, ',' ) )
            {
                if( opt == "verbose")  lint_options = osgToy::GlslLint::VERBOSE;
                else
                {
                    osg::notify(osg::WARN)
                        << "\n" EXTENSION_NAME " plugin: unrecognized option \"" << opt << "\"\n"
                        << "comma-delimited options:\n"
                        << "\tverbose = enable verbose output\n"
                        << "example: osgviewer -O verbose foo.osg.glsllint" "\n"
                        << std::endl;
                }
            }
        }

        osg::notify(osg::INFO) << "ReaderWriterGLSLLINT( \"" << fileName << "\" )" << std::endl;

        // strip the pseudo-loader extension
        std::string subFileName( osgDB::getNameLessExtension(fileName) );
        if( subFileName == fileName )
        {
            osg::notify(osg::WARN) << "Missing subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        // recursively load the subfile.
        osg::Node *node( osgDB::readNodeFile(subFileName) );
        if( !node )
        {
            // propagate the read failure upwards
            osg::notify(osg::WARN) << "Subfile \"" << subFileName << "\" could not be loaded" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }


        // This is where the pseudoloader does its thing...

std::cout << "\n\n\n==========================================" << std::endl;
std::cout << "[ BEGIN GLSLLINT...\n" << std::endl;

        osgToy::GlslLintVisitor lv( lint_options );
        node->accept( lv );

std::cout << "\n] ...END GLSLLINT" << std::endl;
std::cout << "==========================================\n\n\n" << std::endl;

        return node;
    }
示例#3
0
void CSubtitleDlDlg::OnOK()
{
	SetStatus(ResStr(IDS_SUBDL_DLG_DOWNLOADING));

	for (int i = 0; i < m_list.GetItemCount(); ++i) {
		if (m_list.GetCheck(i)) {
			m_selsubs.AddTail(*reinterpret_cast<isdb_subtitle*>(m_list.GetItemData(i)));
		}
	}

	m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;

	CMainFrame* pMF = static_cast<CMainFrame*>(GetParentFrame());

	if (m_fReplaceSubs) {
		pMF->m_pSubStreams.RemoveAll();
	}

	CComPtr<ISubStream> pSubStreamToSet;

	POSITION pos = m_selsubs.GetHeadPosition();

	while (pos) {
		const isdb_subtitle& sub = m_selsubs.GetNext(pos);
		AppSettings& s = AfxGetAppSettings();
		CInternetSession is;
		CStringA url = "http://" + s.strISDb + "/dl.php?";
		CStringA args, ticket, str;
		args.Format("id=%d&ticket=%s", sub.id, UrlEncode(ticket));
		url.Append(args);

		if (OpenUrl(is, CString(url), str)) {

			if (pMF->b_UseVSFilter) {
				if (CComQIPtr<IDirectVobSub> pDVS = pMF->GetVSFilter()) {
					TCHAR lpszTempPath[_MAX_PATH] = { 0 };
					if (::GetTempPath(_MAX_PATH, lpszTempPath)) {
						CString subFileName(lpszTempPath);
						subFileName.Append(CString(sub.name));
						if (::PathFileExists(subFileName)) {
							::DeleteFile(subFileName);
						}

						CFile cf;
						if (cf.Open(subFileName, CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone)) {
							cf.Write(str.GetString(), str.GetLength());
							cf.Close();

							if (SUCCEEDED(pDVS->put_FileName((LPWSTR)(LPCWSTR)subFileName))) {
								pDVS->put_SelectedLanguage(0);
								pDVS->put_HideSubtitles(true);
								pDVS->put_HideSubtitles(false);
							}

							::DeleteFile(subFileName);
						}
					}

					__super::OnOK();
					return;
				}
			}

			CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&pMF->m_csSubLock, &s.subdefstyle, s.fUseDefaultSubtitlesStyle));
			if (pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0) {
				CComPtr<ISubStream> pSubStream = pRTS.Detach();
				pMF->m_pSubStreams.AddTail(pSubStream);

				if (!pSubStreamToSet) {
					pSubStreamToSet = pSubStream;
				}
			}
		}
	}

	if (pSubStreamToSet) {
		pMF->SetSubtitle(pSubStreamToSet);

		AfxGetAppSettings().fEnableSubtitles = true;
	}

	__super::OnOK();
}
示例#4
0
    ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* /*options*/) const
    {
        std::string ext( osgDB::getLowerCaseFileExtension(fileName) );
        if( !acceptsExtension(ext) )
            return ReadResult::FILE_NOT_HANDLED;

        osg::notify(osg::INFO) << "ReaderWriterGLOBE( \"" << fileName << "\" )" << std::endl;

        // strip the ".globe" pseudo-loader extension
        std::string tmpName( osgDB::getNameLessExtension(fileName) );

        // get the next "extension", which actually contains the globe radius parameter
        std::string params( osgDB::getFileExtension(tmpName) );
        if( params.empty() )
        {
            osg::notify(osg::WARN) << "Missing parameters for " EXTENSION_NAME " pseudo-loader" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        // strip the "params extension", which must leave an image subfilename.
        std::string subFileName( osgDB::getNameLessExtension(tmpName) );
        if( subFileName.empty() || subFileName == tmpName )
        {
            osg::notify(osg::WARN) << "Missing image subfilename for " EXTENSION_NAME " pseudo-loader" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        osg::notify(osg::INFO) << EXTENSION_NAME " params = \"" << params << "\"" << std::endl;

        int radius;
        int count( sscanf( params.c_str(), "%d", &radius ) );
        if( count != 1 )
        {
            osg::notify(osg::WARN) << "Bad parameters for " EXTENSION_NAME " pseudo-loader: \"" << params << "\"" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        // recursively load the image subfile.
        osg::Image *image( osgDB::readImageFile(subFileName) );
        if( !image )
        {
            // propagate the read failure upwards
            osg::notify(osg::WARN) << "Image file \"" << subFileName << "\" could not be loaded" << std::endl;
            return ReadResult::FILE_NOT_HANDLED;
        }

        // create an osg::Sphere for the globe geometry
        osg::Geode* geode( new osg::Geode() );
        geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0,0,0), radius)));

        // apply the image as a texture to the globe
        osg::Texture2D* tex2d( new osg::Texture2D );
        tex2d->setImage( image );
        tex2d->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
        tex2d->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );

        osg::StateSet* stateset( geode->getOrCreateStateSet() );
        stateset->setTextureAttributeAndModes( 0, tex2d, osg::StateAttribute::ON );

        return geode;
    }