DCRC

Class 20 - 22

2015.11.22 23:48

likidas Views:2990

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 제출 방법 및 시간 [11] likidas 2016.06.20 1760
30 기말고사 기출문제 [10] file likidas 2016.06.14 1996
29 2016년 5월 30일 강의 [9] likidas 2016.05.30 1887
28 New PA3 [9] file likidas 2016.05.25 1830
27 Class 17 - Pixel Operations (Updated) [9] file likidas 2016.05.15 1835
26 PA2 제출 방법 및 검사 시간 [8] likidas 2016.05.15 1838
25 실습 참고 자료 [9] likidas 2016.04.25 1922
24 2016 봄학기 중간고사 성적 [12] likidas 2016.04.25 2000
23 PA #1 제출 방법 [13] likidas 2016.04.10 1981
22 PA#1 공지 [10] file likidas 2016.03.28 1934
21 Computer Graphics 기말고사 기출문제 [9] file likidas 2015.12.07 2767
20 Class 25-26 [8] file likidas 2015.12.05 2074
19 Gouraud Shading Source Sample [8] file likidas 2015.11.29 2584
18 Class 23 - 24 [9] file likidas 2015.11.28 2581
» Class 20 - 22 [1] [8] file likidas 2015.11.22 2990
16 Class 19 and PA#3 [7] file likidas 2015.11.15 2204
15 Class 18 [8] file likidas 2015.11.07 2560
14 Class 15-16 [9] file likidas 2015.11.01 2103
13 Class 13 - 14 [2] [15] file likidas 2015.10.25 4833
12 Class 12 [10] file likidas 2015.10.19 2621