DCRC

Class 20 - 22

2015.11.22 23:48

likidas Views:3367

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 Class 13 - 14 [2] [15] file likidas 2015.10.25 5445
30 Class 10, Class 11 [2] [14] file likidas 2015.10.11 3904
29 Class 03 - OpenGL Primer [3] [8] file likidas 2015.09.13 3408
» Class 20 - 22 [1] [8] file likidas 2015.11.22 3367
27 Class 12 [10] file likidas 2015.10.19 3231
26 Computer Graphics 기말고사 기출문제 [9] file likidas 2015.12.07 3078
25 Class 05 - Vertex Buffers [1] [11] file likidas 2015.09.19 3075
24 Class 23 - 24 [9] file likidas 2015.11.28 2883
23 Gouraud Shading Source Sample [8] file likidas 2015.11.29 2870
22 Class 07 - OpenGL Interpolators [1] [9] file likidas 2015.09.28 2850
21 Class 18 [8] file likidas 2015.11.07 2844
20 Course Syllabus file likidas 2015.08.31 2744
19 중간고사 준비 Material [10] file likidas 2015.10.14 2729
18 C01 Introduction and Graphics Model [9] file likidas 2015.09.02 2645
17 Class 08 - Hidden Surface Removal, Class 09 - Transformation I [1] [8] file likidas 2015.10.01 2612
16 Class 02 - Geometric Objects [10] file likidas 2015.09.06 2541
15 Class 04 - UI [10] file likidas 2015.09.15 2490
14 Class 19 and PA#3 [7] file likidas 2015.11.15 2431
13 Class 25-26 [8] file likidas 2015.12.05 2328
12 Class 15-16 [9] file likidas 2015.11.01 2320