Javier Gonzalez-Sanchez
November 08, 2018
200

# SER431 Lecture 21

NURBS III
(201811)

## Javier Gonzalez-SanchezPRO

November 08, 2018

## Transcript

1. ### jgs SER 431 Advanced Graphics Lecture 21: Non-Uniform Rational Basis

Splines III Javier Gonzalez-Sanchez [email protected] PERALTA 230U Office Hours: By appointment

3. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 2 jgs

Problem A https://github.com/javiergs/SER431/blob/master/Lecture20/nurbs_surface_controlled.cpp
4. ### 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 };
5. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 4 jgs

Problem B https://github.com/javiergs/SER431/blob/master/Lecture20/nurbs_surface_controlled.cpp
6. ### 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 };

8. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 7 jgs

Screenshot https://github.com/javiergs/SER431/blob/master/Lecture19/nurbs_flag.cpp
9. ### 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. } } };
10. ### 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); }

12. ### Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 11 jgs

Screenshot https://github.com/javiergs/SER431/blob/master/Lecture08/reflection.cpp
13. ### 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
14. ### 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.