DCRC

Class 20 - 22

2015.11.22 23:48

likidas Views:2686

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 제출 방법 및 시간 [10] likidas 2016.06.20 1479
30 기말고사 기출문제 [9] file likidas 2016.06.14 1721
29 2016년 5월 30일 강의 [8] likidas 2016.05.30 1600
28 New PA3 [8] file likidas 2016.05.25 1553
27 Class 17 - Pixel Operations (Updated) [8] file likidas 2016.05.15 1557
26 PA2 제출 방법 및 검사 시간 [7] likidas 2016.05.15 1582
25 실습 참고 자료 [8] likidas 2016.04.25 1639
24 2016 봄학기 중간고사 성적 [11] likidas 2016.04.25 1728
23 PA #1 제출 방법 [12] likidas 2016.04.10 1702
22 PA#1 공지 [9] file likidas 2016.03.28 1671
21 Computer Graphics 기말고사 기출문제 [8] file likidas 2015.12.07 2489
20 Class 25-26 [7] file likidas 2015.12.05 1815
19 Gouraud Shading Source Sample [7] file likidas 2015.11.29 2289
18 Class 23 - 24 [8] file likidas 2015.11.28 2301
» Class 20 - 22 [1] [7] file likidas 2015.11.22 2686
16 Class 19 and PA#3 [6] file likidas 2015.11.15 1973
15 Class 18 [7] file likidas 2015.11.07 2293
14 Class 15-16 [8] file likidas 2015.11.01 1866
13 Class 13 - 14 [2] [14] file likidas 2015.10.25 4365
12 Class 12 [9] file likidas 2015.10.19 2226