BambooIsland: C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/LightManager.cpp Source File

BambooIsland Abgabe 2

- Main Page
- Related Pages
- Classes
- Files

- File List

# C:/Users/easterbunny/Desktop/Echtzeitgraphik-LU/trunk/src/LightManager.cpp

    00001 #include "LightManager.h"
    00002 #include "common_gl.h"
    00003
    00004 LightManager::LightManager()
    00005 {
    00006     m_v3LightPosition = glm::vec3(0.0f, 5.0f, 0.0f);
    00007 }
    00008
    00009 void LightManager::updateLightPosition()
    00010 {
    00011     double time = glfwGetTime() * 0.045;
    00012
    00013     double x = sin(time);
    00014     double y = sin(time);
    00015     double z = cos(time);
    00016
    00017     if (y < 0.05)
    00018         y = 0.05;
    00019
    00020     m_v3LightPosition.x = 12.5f + x * 60;
    00021     m_v3LightPosition.y = y * 30.0f;
    00022     m_v3LightPosition.z = 12.5f + z * 60;
    00023 }
    00024
    00025 LightManager *LightManager::instance()
    00026 {
    00027     static LightManager singelton_instance;
    00028
    00029     singelton_instance.updateLightPosition();
    00030
    00031     return &singelton_instance;
    00032 }
    00033
    00034 float *LightManager::getCurrentLightPosition() const
    00035 {
    00036     static float puffer[4];
    00037     puffer[0] = m_v3LightPosition.x;
    00038     puffer[1] = m_v3LightPosition.y;
    00039     puffer[2] = m_v3LightPosition.z;
    00040     puffer[3] = 1.0;
    00041
    00042     return &puffer[0];
    00043 }
    00044
    00045 glm::vec3 LightManager::getCurrentLightPositionAsVec3() const
    00046 {
    00047     return m_v3LightPosition;
    00048 }
    00049
    00050 glm::vec4 LightManager::getCurrentLightPositionAsVec4() const
    00051 {
    00052     return glm::vec4(m_v3LightPosition, 1.0);
    00053 }

All Classes Functions Variables Enumerations Enumerator