Esempio n. 1
0
void DynamicsWorld::Initialize(Stage& stage, Integration::DynamicsFactory& dynamicsFactory, DynamicsWorldConfigPtr config)
{
    // Create shader for debug drawing
    const std::string debugDrawVertexShader(
        "attribute lowp vec4 aColor;\n"
        "varying mediump vec4 vColor;\n"
        "void main()\n"
        "{\n"
        "  vColor = aColor;\n"
        "  gl_Position = uMvpMatrix * vec4(aPosition, 1.0);\n"
        "}\n" );

    const std::string debugDrawFragmentShader(
        "varying mediump vec4 vColor;\n"
        "void main()\n"
        "{\n"
        "  gl_FragColor = vColor;\n"
        "}\n" );

    mDebugShader = ShaderEffect::New(debugDrawVertexShader, debugDrawFragmentShader, GEOMETRY_TYPE_IMAGE, Dali::ShaderEffect::HINT_NONE);

    mDynamicsWorld = new SceneGraph::DynamicsWorld( stage.GetDynamicsNotifier(),
            stage.GetNotificationManager(),
            dynamicsFactory );

    Integration::DynamicsWorldSettings* worldSettings( new Integration::DynamicsWorldSettings(*config->GetSettings()) );
    const SceneGraph::Shader* shader( static_cast< const SceneGraph::Shader* >(mDebugShader->GetSceneObject()) );
    InitializeDynamicsWorldMessage( stage.GetUpdateManager(), mDynamicsWorld, worldSettings, shader );

    mGravity = config->GetGravity();
}
Esempio n. 2
0
void DynamicsWorld::Terminate(Stage& stage)
{
    DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);

    if( stage.IsInstalled() )
    {
        while( !mBodies.empty() )
        {
            ActorPtr actor( mBodies.begin()->second );
            if( actor )
            {
                actor->DisableDynamics();
            }
        }

        TerminateDynamicsWorldMessage( stage.GetUpdateManager() );
    }
}