Slide 1

Slide 1 text

jgs SER 431 Advanced Graphics Lecture 21: Non-Uniform Rational Basis Splines III Javier Gonzalez-Sanchez [email protected] PERALTA 230U Office Hours: By appointment

Slide 2

Slide 2 text

jgs Quiz 06 NURBS Solution

Slide 3

Slide 3 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 2 jgs Problem A https://github.com/javiergs/SER431/blob/master/Lecture20/nurbs_surface_controlled.cpp

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 3 jgs Problem A // NURBS // How many curves? How many control points per curve? // How many knots per curve? How many knots per inter-curve connection? // Order for U and V? // Offset for U and V? GLfloat ctlpoints[4][4][3] = { { { 20, 0, 20 } ,{ 0, 0, 20 },{ 0, 0, 20 } ,{ -20, 0, 20 } }, { { 20, 0, 0 } ,{ 0, 20, 0 },{ 0, 20, 0 } ,{ -20, 0, 0 } }, { { 20, 0, 0 } ,{ 0, 20, 0 },{ 0, 20, 0 } ,{ -20, 0, 0 } }, { { 20, 0, -20 } ,{ 0, 0, -20 },{ 0, 0, -20 } ,{ -20, 0, -20 } } }; GLfloat uknots[8] = { 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 3.0, 3.0 }; GLfloat vknots[8] = { 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 3.0, 3.0 };

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 4 jgs Problem B https://github.com/javiergs/SER431/blob/master/Lecture20/nurbs_surface_controlled.cpp

Slide 6

Slide 6 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 5 jgs Problem B // NURBS // How many curves? How many control points per curve? // How many knots per curve? How many knots per inter-curve connection? // Order for U and V? // Offset for U and V? const int V_size = 9; const int U_size = 7; const int ORDER = 4; GLfloat ctlpoints[U_size][V_size][3] = { { { 0, -4, 0 }, { -4, -4, 0 } ,{ -4, 0, 0 }, { -4, 4, 0 }, { 0, 4, 0 }, { 4, 4, 0 }, { 4, 0, 0 }, { 4, -4, 0 }, { 0, -4, 0 } }, { { 0, -2, 4 }, { -2, -2, 4 } ,{ -2, 0, 4 }, { -2, 2, 4 }, { 0, 2, 4 }, { 2, 2, 4 }, { 2, 0, 4 }, { 2, -2, 4 }, { 0, -2, 4 } }, { { 0, -4, 8 }, { -4, -4, 8 } ,{ -4, 0, 8 }, { -4, 4, 8 }, { 0, 4, 8 }, { 4, 4, 8 }, { 4, 0, 8 }, { 4, -4, 8 }, { 0, -4, 8 } }, { { 0, 0, 10 }, { 0, 0, 10 } ,{ 0 , 0, 10 }, { 0, 0, 10 }, { 0, 0, 10 }, { 0, 0, 10 }, { 0, 0, 10 }, { 0, 0, 10 }, { 0, 0, 10 } }, { { 0, -1, 12 }, { -1, -1, 12 } ,{ -1, 0, 12 }, { -1, 1, 12 }, { 0, 1, 12 }, { 1, 1, 12 }, { 1, 0, 12 }, { 1, -1, 12 }, { 0, -1, 12 } }, { { 0, -2, 14 }, { -2, -2, 14 } ,{ -2, 0, 14 }, { -2, 2, 14 }, { 0, 2, 14 }, { 2, 2, 14 }, { 2, 0, 14 }, { 2, -2, 14 }, { 0, -2, 14 } }, { { 0, -4, 16 }, { -4, -4, 16 } ,{ -4, 0, 16 }, { -4, 4, 16 }, { 0, 4, 16 }, { 4, 4, 16 }, { 4, 0, 16 }, { 4, -4, 16 }, { 0, -4, 16 } } }; GLfloat vknots[V_size + ORDER]= {0.0, 0.0, 0.0, 0.0, 2.0, 4.0, 4.0, 4.0, 6.0, 8.0, 8.0, 8.0, 8.0 }; GLfloat uknots[U_size + ORDER]= { 0.0, 0.0, 0.0, 0.0, 1.0, 3.0, 5.0, 6.0, 6.0, 6.0, 6.0 };

Slide 7

Slide 7 text

jgs Surfaces using OpenGL Support Animation

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 7 jgs Screenshot https://github.com/javiergs/SER431/blob/master/Lecture19/nurbs_flag.cpp

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 8 jgs Code #define V_NUMPOINTS 4 #define U_NUMPOINTS 4 #define V_NUMKNOTS (V_NUMPOINTS + 4) #define U_NUMKNOTS (U_NUMPOINTS + 4) // Knots GLfloat sknots[V_NUMKNOTS] = { 0., 0., 0., 0., 1., 1., 1., 1. }; GLfloat tknots[U_NUMKNOTS] = { 0., 0., 0., 0., 1., 1., 1., 1. }; // Control points - the Z values will be modified to make it wave GLfloat ctlpoints[V_NUMPOINTS][U_NUMPOINTS][3] = { { { 0., 3., 0. },{ 1., 3., 0. },{ 2., 3., 0 },{ 3., 3., 0. } }, { { 0., 2., 0. },{ 1., 2., 0. },{ 2., 2., 0 },{ 3., 2., 0. } }, { { 0., 1., 0. },{ 1., 1., 0. },{ 2., 1., 0 },{ 3., 1., 0. } }, { { 0., 0., 0. },{ 1., 0., 0. },{ 2., 0., 0 },{ 3., 0., 0. } } };

Slide 10

Slide 10 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 9 jgs // wave the flag by rotating Z cords though a sine wave void display() { for (int i = 1; i< 4; i++) for (int j = 0; j< 4; j++) ctlpoints[i][j][2] = sin((GLfloat)i + angle); angle += 0.1; gluBeginSurface(nurbsflag); gluNurbsSurface(nurbsflag, V_NUMKNOTS, sknots, U_NUMKNOTS, tknots, 3 * U_NUMPOINTS, 3, &ctlpoints[0][0][0], 4, 4, GL_MAP2_VERTEX_3); gluEndSurface(nurbsflag); }

Slide 11

Slide 11 text

jgs Quiz 07

Slide 12

Slide 12 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 11 jgs Screenshot https://github.com/javiergs/SER431/blob/master/Lecture08/reflection.cpp

Slide 13

Slide 13 text

Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 12 jgs Instructions 1. Join the program for Shadows and Reflection (with the 3 boxes in a plain) 2. Add to the program one flag in a staff 3. Make the flag move (as shown before) 4. Show the shadow of the staff and the shadow of the flag 5. Show the reflection of the staff and the reflection of the flag

Slide 14

Slide 14 text

jgs SER431 Advanced Graphics Javier Gonzalez-Sanchez [email protected] Fall 2018 Disclaimer. These slides can only be used as study material for the class SER431 at ASU. They cannot be distributed or used for another purpose.