DCRC

Class 20 - 22

2015.11.22 23:48

likidas Views:1746

20. Lighting Exercise


- Sample code for creating sphere : http://stackoverflow.com/questions/26116923/modern-opengl-draw-a-sphere-and-cylinder


// Calc The Vertices
for (int i = 0; i <= Stacks; ++i){

    float V   = i / (float) Stacks;
    float phi = V * glm::pi <float> ();

    // Loop Through Slices
    for (int j = 0; j <= Slices; ++j){

        float U = j / (float) Slices;
        float theta = U * (glm::pi <float> () * 2);

        // Calc The Vertex Positions
        float x = cosf (theta) * sinf (phi);
        float y = cosf (phi);
        float z = sinf (theta) * sinf (phi);

        // Push Back Vertex Data
        vertices.push_back (glm::vec3 (x, y, z) * Radius);
    }
}

// Calc The Index Positions
for (int i = 0; i < Slices * Stacks + Slices; ++i){

    indices.push_back (i);
    indices.push_back (i + Slices + 1);
    indices.push_back (i + Slices);

    indices.push_back (i + Slices + 1);
    indices.push_back (i);
    indices.push_back (i + 1);
}
No. Subject Author Date Views
31 PA3 제출 방법 및 시간 likidas 2016.06.20 820
30 기말고사 기출문제 file likidas 2016.06.14 957
29 2016년 5월 30일 강의 likidas 2016.05.30 974
28 New PA3 file likidas 2016.05.25 886
27 Class 17 - Pixel Operations (Updated) file likidas 2016.05.15 865
26 PA2 제출 방법 및 검사 시간 likidas 2016.05.15 957
25 실습 참고 자료 likidas 2016.04.25 1008
24 2016 봄학기 중간고사 성적 likidas 2016.04.25 1060
23 PA #1 제출 방법 likidas 2016.04.10 1026
22 PA#1 공지 file likidas 2016.03.28 974
21 Computer Graphics 기말고사 기출문제 file likidas 2015.12.07 1799
20 Class 25-26 file likidas 2015.12.05 1210
19 Gouraud Shading Source Sample file likidas 2015.11.29 1551
18 Class 23 - 24 file likidas 2015.11.28 1532
» Class 20 - 22 [1] file likidas 2015.11.22 1746
16 Class 19 and PA#3 file likidas 2015.11.15 1288
15 Class 18 file likidas 2015.11.07 1627
14 Class 15-16 file likidas 2015.11.01 1260
13 Class 13 - 14 [2] file likidas 2015.10.25 2256
12 Class 12 file likidas 2015.10.19 1542