Exemplo n.º 1
0
void RenderF()
{
    g_Render.clear({ 0.1f, 0.1f, 0.0f });

    // glLoadIdentity();

    UpdateEyePositionFromMouse();

    g_Render.updateCamera(g_Camera);

    g_Render.usePreComputedEnvLight(g_prtEnable);

    g_Render.renderScene(&g_Scene);

    TwDraw();

    g_Render.swapBuffers();
}
Exemplo n.º 2
0
void KeyEvent(uint8_t key, int x, int y)
{
    if (TwEventKeyboardGLUT(key, x, y))
        return;

    switch (key)
    {
    case 'o': case 'O':
    {
        char fileName[1024] = { 0 };
        if (osOpenDlg(fileName, 1024))
        {
            try {
                g_Scene.loadFromFile(fileName);
                std::cout << "[INFO] Model loaded" << std::endl;
                osDisplaySceneInfo(&g_Scene);
                g_Scene.buildBVH();
                std::cout << "[INFO] BVH loaded" << std::endl;
                g_PRT.preComputeGeomCoeff(&g_Scene);
                g_Render.usePreComputedEnvLight(true);
                std::cout << "[INFO] Transport coefficients computed" << std::endl;
            }
            catch (std::exception &e)
            {
                std::cout << e.what() << std::endl;
            }
        }

    }
    break;
    case 'w': case 'W':
        g_Camera->ChangeVelocity(camSpeed);
        break;
    case 's': case 'S':
        g_Camera->ChangeVelocity(camSpeed*-1.0f);
        break;
    case 'a': case 'A':
    {
        float Heading = (float)((g_Camera->m_HeadingDegrees - 90.0f) / 180.0f * M_PI);
        float x = sin(Heading);
        float z = cos(Heading);

        g_Camera->m_Position.x += x*camSpeed;
        g_Camera->m_Position.z += z*camSpeed;
    }
    break;

    case 'd': case 'D':
    {
        float Heading = (float)((g_Camera->m_HeadingDegrees + 90.0f) / 180.0f * M_PI);
        float x = sin(Heading);
        float z = cos(Heading);

        g_Camera->m_Position.x += x*camSpeed;
        g_Camera->m_Position.z += z*camSpeed;
    }
    break;

    case 'r': case 'R':
    {
        g_Camera->m_Position.x += g_Camera->m_Up.x * camSpeed;
        g_Camera->m_Position.y += g_Camera->m_Up.y * camSpeed;
        g_Camera->m_Position.z += g_Camera->m_Up.z * camSpeed;
    }
    break;

    case 'f': case 'F':
    {
        g_Camera->m_Position.x -= g_Camera->m_Up.x * camSpeed;
        g_Camera->m_Position.y -= g_Camera->m_Up.y * camSpeed;
        g_Camera->m_Position.z -= g_Camera->m_Up.z * camSpeed;
    }
    break;
    }
}