Example #1
0
void Sprite::onGeometryChange(const Scene::Geometry &geo)
{
	/* Offset at which the sprite will be drawn
	 * relative to screen origin */
	p->trans.setGlobalOffset(geo.offset());

	p->sceneRect.setSize(geo.rect.size());
	p->sceneOrig = geo.orig;
}
Example #2
0
void WindowVX::onGeometryChange(const Scene::Geometry &geo)
{
	p->sceneOffset = geo.offset();
}
Example #3
0
    void
    ViewerApp::setup( )
    {
        // Read files
        Scene::Collada::Importer builder( m_db );
        for(auto it=m_source_files.begin(); it!=m_source_files.end(); ++it) {
            std::cerr << "Parsing '" << (*it) << '\'' << std::endl;
            if( !builder.parse( *it ) ) {
                std::cerr << "Error parsing '" << (*it) << "'" << std::endl;
            }
        }

        if( m_auto_shader ) {
            Scene::Tools::generateShadersFromCommon( m_db,
                                                     Scene::PROFILE_GLSL | 
                                                     Scene::PROFILE_GLES2 );
            
/*
            for( size_t i=0; i<m_db.library<Scene::Effect>().size(); i++ ) {
                Scene::Effect* e = m_db.library<Scene::Effect>().get( i );
                std::cerr << "Generating GLSL and GLES2 profiles for '" << e->id() << '\'' << std::endl;
                e->generate( Scene::PROFILE_GLSL );
                e->generate( Scene::PROFILE_GLES2 );
            }
*/
        }
        if( m_auto_flatten ) {
            for( size_t i=0; i<m_db.library<Scene::Geometry>().size(); i++ ) {
                Scene::Geometry* g = m_db.library<Scene::Geometry>().get( i );
                if( g->hasSharedInputs() ) {
                    std::cerr << "Flattening '" << g->id() << '\'' << std::endl;
                    g->flatten();
                }
            }
        }
        Scene::Tools::updateBoundingBoxes( m_db );

        std::cerr << "Import done." << std::endl;

        updateCameraInstances();

        // Create application camera
        m_app_camera = m_db.library<Scene::Camera>().add( "app_camera" );
        if( m_app_camera == NULL ) {
            std::cerr << "Failed to create application camera.\n";
        }
        else {
            m_app_camera_node = m_db.library<Scene::Node>().add( "app_camera_node" );
            if( m_app_camera_node == NULL ) {
                std::cerr << "Failed to create application camera node.\n";
            }
            else {
                m_app_camera_node->addInstanceCamera( "", "app_camera" );
                m_app_camera_node->addInstanceCamera( "", "app_camera" );
#ifdef USE_MATRIX
                m_app_camera_node->transformAdd( "matrix" );
#else
                m_app_camera_node->transformAdd( "lookat" );
#endif
                if( m_stereo ) {
                    m_app_camera_node->transformAdd( "translate" );
                }
            }
        }


        m_slave_camera = m_db.library<Scene::Camera>().add( "slave_camera" );
        m_slave_camera_node = m_db.library<Scene::Node>().add( "slave_camera_node" );
        m_slave_camera_node->addInstanceCamera( "", "slave_camera" );
        m_slave_camera_node->transformAdd( "lookat" );

        // Browse through visual scenes. All visual scenes with a 'setup'-prefix
        // is rendered, and all visual scenes with a 'onscreen'-prefix is added
        // to the 'render mode' list.

        m_onscreen_visual_scenes.clear();
        for(size_t i=0; i<m_db.library<Scene::VisualScene>().size(); i++ ) {
            Scene::VisualScene* vs = m_db.library<Scene::VisualScene>().get( i );
            std::cerr << vs->id() << "\n";
            if( vs->evaluateScenes() == 0 ) {
                std::cerr << "Visual scene '" << vs->id() << "' doesn't have an evaluate block, adding a default.\n";

                Scene::Node* root = m_db.library<Scene::Node>().get( vs->nodesId() );
                root->addInstanceNode( "", "", "app_camera_node", "" );
                root->addInstanceLight( "my_light", "" );

                Scene::EvaluateScene* es = vs->addEvaluateScene();
                es->setEnabled( true );
                Scene::Render* ri = es->addRenderItem();
                ri->setCameraNodeId( "app_camera_node" );
            }


            std::string scene_id = m_db.library<Scene::VisualScene>().get(i)->id();
            if( scene_id.substr( 0, 5 ) == "setup" ) {
                m_renderlist.build( scene_id );
                m_renderlist.render( );
            }
            else /*if( scene_id.substr( 0, 8 ) == "onscreen" )*/ {
                m_onscreen_visual_scenes.push_back( scene_id );
            }
        }
        if( !m_onscreen_visual_scenes.empty() ) {
            m_onscreen_scene = m_onscreen_scene % m_onscreen_visual_scenes.size();
            m_renderlist.build( m_onscreen_visual_scenes[ m_onscreen_scene ] );
        }
        else {
            m_onscreen_scene = 0;
        }
        updateBoundingBox();
       
    }