Exemple #1
0
void Scene::keyPressEvent(int key, int scancode, int action, int modes)
{
        switch(action)
        {
                case GLFW_PRESS:
                        switch(key)
                        {
                                case GLFW_KEY_SPACE:
                                        mPaused = !mPaused;
                                        mCloth.setPause(mPaused);
                                        break;
                                case GLFW_KEY_F:
                                        mCloth.toggleFan();
                                        break;
                                case GLFW_KEY_S:
                                        stepScene();
                                        break;
                                case GLFW_KEY_C:
                                        if (_viewing >= SPLINE_VIEW) _viewing = USER_VIEW;
                                        else
                                        {
                                                int viewerInt = _viewing;
                                                viewerInt++;
                                                _viewing = static_cast<ViewType>(viewerInt);
                                        }
#ifdef PROG_DEBUG
                                        USING_ATLAS_CORE_NS;
                                        Log::log(Log::SeverityLevel::DEBUG, "Camera: " + std::to_string(_viewing));
#endif
                        };
                        break;
                default:
                        break;
        };
}
Exemple #2
0
void mainLoop()
{
    try
    {
        while (running)
        {
            setupWindow(width, height, "raycar");
            Asset::init(GLContext::context());
            SceneGraph::init(GLContext::context());
            loadScene("content/raycar.scn");
            resetTimer();
            double now = 0;
            while (sceneRunning && running)
            {
                pollInput();
                double next = timer();
                if (active)
                {
                    if (next > now + maxStepTime)
                    {   //  falling behind
                        now = next - maxStepTime;
                    }
                    while (now < next)
                    {
                        stepScene();
                        now += stepTime;
                    }
                }
                else
                {
                    now = next;
                }
                renderWindow();
            }
        }
    }
    catch (std::exception const &x)
    {
        error(x.what());
    }
}