コード例 #1
0
ファイル: anomaly_test.cpp プロジェクト: gwtnb/jubatus_core
  void SetUp() {
    core::anomaly::light_lof::config lof_config;
    lof_config.nearest_neighbor_num = 3;
    lof_config.reverse_nearest_neighbor_num = 3;

    shared_ptr<table::column_table> lsh_table(
        new table::column_table);
    core::nearest_neighbor::euclid_lsh::config lsh_config;
    shared_ptr<core::nearest_neighbor::nearest_neighbor_base> lsh(
        new core::nearest_neighbor::euclid_lsh(lsh_config, lsh_table, "id"));

    unlearner::lru_unlearner::config unlearner_config;
    unlearner_config.max_size = 5;
    jubatus::util::lang::shared_ptr<unlearner::unlearner_base> unlearner(
        new unlearner::lru_unlearner(unlearner_config));

    anomaly_.reset(new anomaly(
                       shared_ptr<anomaly_base>(
                           new core::anomaly::light_lof(
                               lof_config, "id", lsh, unlearner)),
                           make_fv_converter()));
  }
コード例 #2
0
void CameraAnimator::initCameraMoveToLight( const dp::sg::core::LightSourceWeakPtr & targetLight )   // should be a dp::sg::core::LightSourceWeakPtr
{
    DP_ASSERT( m_viewState->getCamera().isPtrTo<dp::sg::core::FrustumCamera>() );
    m_cameraMoveStart = m_viewState->getCamera().clone().staticCast<dp::sg::core::FrustumCamera>();

    m_cameraMoveTarget = m_cameraMoveStart.clone();

    dp::sg::core::LightSourceSharedPtr lsh( targetLight->getSharedPtr<dp::sg::core::LightSource>() );
    {
        DP_ASSERT( lsh->getLightEffect() );
        dp::sg::core::EffectDataSharedPtr const& le = lsh->getLightEffect();
        const dp::fx::SmartEffectSpec & es = le->getEffectSpec();
        for ( dp::fx::EffectSpec::iterator it = es->beginParameterGroupSpecs() ; it != es->endParameterGroupSpecs() ; ++it )
        {
            const dp::sg::core::ParameterGroupDataSharedPtr & parameterGroupData = le->getParameterGroupData( it );
            if ( parameterGroupData )
            {
                std::string name = (*it)->getName();
                if ( ( name == "standardDirectedLightParameters" )
                        || ( name == "standardPointLightParameters" )
                        || ( name == "standardSpotLightParameters" ) )
                {
                    const dp::fx::SmartParameterGroupSpec & pgs = parameterGroupData->getParameterGroupSpec();
                    if ( name == "standardDirectedLightParameters" )
                    {
                        m_cameraMoveTarget->setDirection( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "direction" ) ) );
                    }
                    else if ( name == "standardPointLightParameters" )
                    {
                        dp::math::Vec3f position = parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "position" ) );
                        m_cameraMoveTarget->setPosition( position );

                        // point us in the direction of the scene center..
                        if ( m_viewState->getScene()->getRootNode() )
                        {
                            dp::math::Vec3f forward = m_viewState->getScene()->getRootNode()->getBoundingSphere().getCenter() - position;
                            dp::math::Vec3f worldup( 0.f, 1.f, 0.f ); //pc->getUpVector();

                            dp::math::Vec3f right = forward ^ worldup;
                            dp::math::Vec3f up = right ^ forward;

                            normalize( forward );
                            normalize( right );
                            normalize( up );

                            // X east, Y up, -Z north
                            dp::math::Mat33f lookat( dp::util::makeArray(   right[0],    right[1],    right[2],
                                                     up[0],       up[1],       up[2],
                                                     -forward[0], -forward[1], -forward[2] ) );

                            dp::math::Quatf ori( lookat );
                            m_cameraMoveTarget->setOrientation( ori );
                        }
                    }
                    else
                    {
                        m_cameraMoveTarget->setPosition( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "position" ) ) );
                        m_cameraMoveTarget->setDirection( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "direction" ) ) );
                    }
                    break;
                }
            }
        }
    }

    cameraMoveDurationFactor( determineDurationFactor() );
}