DCRC

Class 20 - 22

2015.11.22 23:48

likidas Views:1647

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 783
30 기말고사 기출문제 file likidas 2016.06.14 890
29 2016년 5월 30일 강의 likidas 2016.05.30 811
28 New PA3 file likidas 2016.05.25 852
27 Class 17 - Pixel Operations (Updated) file likidas 2016.05.15 795
26 PA2 제출 방법 및 검사 시간 likidas 2016.05.15 915
25 실습 참고 자료 likidas 2016.04.25 961
24 2016 봄학기 중간고사 성적 likidas 2016.04.25 972
23 PA #1 제출 방법 likidas 2016.04.10 981
22 PA#1 공지 file likidas 2016.03.28 930
21 Computer Graphics 기말고사 기출문제 file likidas 2015.12.07 1543
20 Class 25-26 file likidas 2015.12.05 1169
19 Gouraud Shading Source Sample file likidas 2015.11.29 1473
18 Class 23 - 24 file likidas 2015.11.28 1218
» Class 20 - 22 [1] file likidas 2015.11.22 1647
16 Class 19 and PA#3 file likidas 2015.11.15 1236
15 Class 18 file likidas 2015.11.07 1303
14 Class 15-16 file likidas 2015.11.01 1226
13 Class 13 - 14 [2] file likidas 2015.10.25 1852
12 Class 12 file likidas 2015.10.19 1491