SlideShare a Scribd company logo
1 of 21
Curves and Surfaces in
OpenGL
1
Objectives
• Introduce OpenGL evaluators
• Learn to render polynomial curves and surfaces
• Discuss quadrics in OpenGL
• GLUT Quadrics
• GLU Quadrics
2
What Does OpenGL Support?
•Evaluators: a general mechanism for working with the
Bernstein polynomials
• Can use any degree polynomials
• Can use in 1-4 dimensions
• Automatic generation of normals and texture coordinates
• NURBS supported in GLU
•Quadrics
• GLU and GLUT contain polynomial approximations of quadrics
3
One-Dimensional Evaluators
• Evaluate a Bernstein polynomial of any degree at a set of specified
values
• Can evaluate a variety of variables
• Points along a 2, 3 or 4 dimensional curve
• Colors
• Normals
• Texture Coordinates
• We can set up multiple evaluators that are all evaluated for the same
value
4
Setting Up an Evaluator
5
glMap1f(type,u_min,u_max,stride,
order, pointer_to_array)
what we want to evaluate
max and min of u
1+degree of polynomial
pointer to control data
separation between
data points
Each type must be enabled by glEnable(type)
Example
6
Consider an evaluator for a cubic Bezier curve over (0,1)
point data[ ]={…………..}; * /3d data /*
glMap1f(GL_MAP_VERTEX_3,0.0,1.0,3,4,data);
data are 3D vertices cubic
data are arranged as x,y,z,x,y,z……
three floats between data points in array
glEnable(GL_MAP_VERTEX_3);
Evaluating
• The function glEvalCoord1f(u) causes all enabled
evaluators to be evaluated for the specified u
• Can replace glVertex, glNormal, glTexCoord
• The values of u need not be equally spaced
7
Example
8
• Consider the previous evaluator that was set up
for a cubic Bezier over (0,1)
• Suppose that we want to approximate the curve
with a 100 point polyline
glBegin(GL_LINE_STRIP)
for(i=0; i<100; i++)
glEvalCoord1f( (float) i/100.0);
glEnd();
Equally Spaced Points
Rather than use a loop, we can set up an equally
spaced mesh (grid) and then evaluate it with one
function call
9
glMapGrid(100, 0.0, 1.0);
sets up 100 equally-spaced points on (0,1)
glEvalMesh1(GL_LINE, 0, 99);
renders lines between adjacent evaluated
points from point 0 to point 99
Bezier Surfaces
•Similar procedure to 1D but use 2D evaluators in u
and v
•Set up with
glMap2f(type, u_min, umax, u_stride,
u_order, v_min, v_max, v_stride,
v_order, pointer_to_data)
•Evaluate with glEvalCoord2f(u,v)
10
Example
11
bicubic over (0,1) x (0,1)
point data[4][4]={………};
glMap2f(GL_MAP_VERTEX_3, 0.0, 1.0, 3, 4,
0.0, 1.0, 12, 4, data);
Note that in v direction data points
are separated by 12 floats since array
data is stored by rows
Rendering with Lines
12
for(j=0;j<100;j++) {
glBegin(GL_LINE_STRIP);
for(i=0;i<100;i++)
glEvalCoord2f((float) i/100.0, (float) j/100.0);
glEnd();
glBegin(GL_LINE_STRIP);
for(i=0;i<100;i++)
glEvalCoord2f((float) j/100.0, (float) i/100.0);
glEnd();
}
must draw in both directions
Rendering with Quadrilaterals
13
for(j=0; j<99; j++) {
glBegin(GL_QUAD_STRIP);
for(i=0; i<100; i++) {
glEvalCoord2f ((float) i/100.0,
(float) j/100.0);
glEvalCoord2f ((float)(i+1)/100.0,
(float)j/100.0);
}
glEnd():
}
We can form a quad mesh and render with lines
Uniform Meshes
• We can form a 2D mesh (grid) in a similar manner to 1D for uniform
spacing
glMapGrid2(u_num, u_min, u_max, v_num, v_min, v_max)
• Can evaluate as before with lines or if want filled polygons
glEvalMesh2( GL_FILL, u_start, u_num, v_start, v_num)
14
Rendering with Lighting
• If we use filled polygons, we have to shade or we will see solid color
uniform rendering
• Can specify lights and materials but we need normals
• Let OpenGL find them
glEnable(GL_AUTO_NORMAL);
15
NURBS
• OpenGL supports NURBS surfaces through the GLU library
• Why GLU?
• Can use evaluators in 4D with standard OpenGL library
• However, there are many complexities with NURBS that need a lot of code
• There are five NURBS surface functions plus functions for trimming curves
that can remove pieces of a NURBS surface
16
Quadrics
• Quadrics are in both the GLU and GLUT libraries
• Both use polygonal approximations where the application specifies the
resolution
• Sphere: lines of longitude and lattitude
• GLU: disks, cylinders, spheres
• Can apply transformations to scale, orient, and position
• GLUT: Platonic solids, torus, Utah teapot, cone
17
GLUT Objects
18
glutWireCone()
glutWireTorus()
glutWireTeapot()
Each has a wire and a solid form
GLUT Platonic Solids
19
glutWireTetrahedron()
glutWireOctahedron()
glutWireDodecahedron()
glutWireIcosahedron()
Quadric Objects in GLU
•GLU can automatically generate normals and texture
coordinates
•Quadrics are objects that include properties such as
how we would like the object to be rendered
20
disk
partial disk
sphere
Defining a Cylinder
GLUquadricOBJ *p;
P = gluNewQuadric(); /*set up object */
gluQuadricDrawStyle(GLU_LINE);/*render
style*/
gluCylinder(p, BASE_RADIUS, TOP_RADIUS,
BASE_HEIGHT, sections, slices);
21

More Related Content

What's hot

Airline reservation system project report (1)
Airline reservation system project report (1)Airline reservation system project report (1)
Airline reservation system project report (1)MostafaMorsyMohamed
 
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEKhushboo Pal
 
Bus tracking application project report
Bus tracking application project reportBus tracking application project report
Bus tracking application project reportAbhishek Singh
 
Applications of IOT (internet of things)
Applications of IOT (internet of things)Applications of IOT (internet of things)
Applications of IOT (internet of things)Vinesh Gowda
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AIManjeet Kamboj
 
Model Based Software Architectures
Model Based Software ArchitecturesModel Based Software Architectures
Model Based Software ArchitecturesMunazza-Mah-Jabeen
 
Multi dimensional turing machine
Multi dimensional turing machineMulti dimensional turing machine
Multi dimensional turing machineNiteshSingh405
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rulesswapnac12
 
SRS for Library Management System
SRS for Library Management SystemSRS for Library Management System
SRS for Library Management SystemToseef Hasan
 
Automated traffic control system
Automated traffic control systemAutomated traffic control system
Automated traffic control systemLikithe
 
Fuzzy Logic ppt
Fuzzy Logic pptFuzzy Logic ppt
Fuzzy Logic pptRitu Bafna
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representationSravanthi Emani
 
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1Introduction Artificial Intelligence a modern approach by Russel and Norvig 1
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1Garry D. Lasaga
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMvikas dhakane
 
IoT in Transportation Sector
IoT in Transportation SectorIoT in Transportation Sector
IoT in Transportation SectorMd. Sohag Miah
 

What's hot (20)

Intelligent agent
Intelligent agentIntelligent agent
Intelligent agent
 
Airline reservation system project report (1)
Airline reservation system project report (1)Airline reservation system project report (1)
Airline reservation system project report (1)
 
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCEIntelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
Intelligent Agent PPT ON SLIDESHARE IN ARTIFICIAL INTELLIGENCE
 
Bus tracking application project report
Bus tracking application project reportBus tracking application project report
Bus tracking application project report
 
College Bus Tracking Application
College Bus Tracking ApplicationCollege Bus Tracking Application
College Bus Tracking Application
 
Ch 6 final
Ch 6 finalCh 6 final
Ch 6 final
 
Applications of IOT (internet of things)
Applications of IOT (internet of things)Applications of IOT (internet of things)
Applications of IOT (internet of things)
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AI
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Model Based Software Architectures
Model Based Software ArchitecturesModel Based Software Architectures
Model Based Software Architectures
 
Multi dimensional turing machine
Multi dimensional turing machineMulti dimensional turing machine
Multi dimensional turing machine
 
Learning set of rules
Learning set of rulesLearning set of rules
Learning set of rules
 
Domain specific IoT
Domain specific IoTDomain specific IoT
Domain specific IoT
 
SRS for Library Management System
SRS for Library Management SystemSRS for Library Management System
SRS for Library Management System
 
Automated traffic control system
Automated traffic control systemAutomated traffic control system
Automated traffic control system
 
Fuzzy Logic ppt
Fuzzy Logic pptFuzzy Logic ppt
Fuzzy Logic ppt
 
Issues in knowledge representation
Issues in knowledge representationIssues in knowledge representation
Issues in knowledge representation
 
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1Introduction Artificial Intelligence a modern approach by Russel and Norvig 1
Introduction Artificial Intelligence a modern approach by Russel and Norvig 1
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
IoT in Transportation Sector
IoT in Transportation SectorIoT in Transportation Sector
IoT in Transportation Sector
 

Similar to Curves and surfaces in OpenGL

Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene GraphsSyed Zaid Irshad
 
NV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsNV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsMark Kilgard
 
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...vijayakrishna rowthu
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Texas Natural Resources Information System
 
lectureAll-OpenGL-complete-Guide-Tutorial.pdf
lectureAll-OpenGL-complete-Guide-Tutorial.pdflectureAll-OpenGL-complete-Guide-Tutorial.pdf
lectureAll-OpenGL-complete-Guide-Tutorial.pdfSanjeevSaharan5
 
Open Graphics Library
Open Graphics  Library Open Graphics  Library
Open Graphics Library Azmeen Gadit
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxmariuse18nolet
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformationssaad siddiqui
 
Multiple UGV SLAM Map Sharing
Multiple UGV SLAM Map SharingMultiple UGV SLAM Map Sharing
Multiple UGV SLAM Map SharingAkash Borate
 

Similar to Curves and surfaces in OpenGL (20)

Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
 
september11.ppt
september11.pptseptember11.ppt
september11.ppt
 
OpenGL Transformations
OpenGL TransformationsOpenGL Transformations
OpenGL Transformations
 
Graphical Objects and Scene Graphs
Graphical Objects and Scene GraphsGraphical Objects and Scene Graphs
Graphical Objects and Scene Graphs
 
NV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsNV_path rendering Functional Improvements
NV_path rendering Functional Improvements
 
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...
A Unified PDE model for image multi-phase segmentation and grey-scale inpaint...
 
OpenGL Texture Mapping
OpenGL Texture MappingOpenGL Texture Mapping
OpenGL Texture Mapping
 
Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...Covering the earth and the cloud the next generation of spatial in sql server...
Covering the earth and the cloud the next generation of spatial in sql server...
 
Computer Viewing
Computer ViewingComputer Viewing
Computer Viewing
 
Building Models
Building ModelsBuilding Models
Building Models
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
lectureAll-OpenGL-complete-Guide-Tutorial.pdf
lectureAll-OpenGL-complete-Guide-Tutorial.pdflectureAll-OpenGL-complete-Guide-Tutorial.pdf
lectureAll-OpenGL-complete-Guide-Tutorial.pdf
 
Open Graphics Library
Open Graphics  Library Open Graphics  Library
Open Graphics Library
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
06 image features
06 image features06 image features
06 image features
 
CGChapter 3.pptx
CGChapter 3.pptxCGChapter 3.pptx
CGChapter 3.pptx
 
IntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docxIntroductionTopological sorting is a common operation performed .docx
IntroductionTopological sorting is a common operation performed .docx
 
18csl67 vtu lab manual
18csl67 vtu lab manual18csl67 vtu lab manual
18csl67 vtu lab manual
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformations
 
Multiple UGV SLAM Map Sharing
Multiple UGV SLAM Map SharingMultiple UGV SLAM Map Sharing
Multiple UGV SLAM Map Sharing
 

More from Syed Zaid Irshad

More from Syed Zaid Irshad (20)

Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
DBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionDBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_Solution
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Professional Issues in Computing
Professional Issues in ComputingProfessional Issues in Computing
Professional Issues in Computing
 
Reduce course notes class xi
Reduce course notes class xiReduce course notes class xi
Reduce course notes class xi
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
C Language
C LanguageC Language
C Language
 
Flowchart
FlowchartFlowchart
Flowchart
 
Algorithm Pseudo
Algorithm PseudoAlgorithm Pseudo
Algorithm Pseudo
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
ICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionICS 2nd Year Book Introduction
ICS 2nd Year Book Introduction
 
Security, Copyright and the Law
Security, Copyright and the LawSecurity, Copyright and the Law
Security, Copyright and the Law
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Data Communication
Data CommunicationData Communication
Data Communication
 
Information Networks
Information NetworksInformation Networks
Information Networks
 
Basic Concept of Information Technology
Basic Concept of Information TechnologyBasic Concept of Information Technology
Basic Concept of Information Technology
 
Introduction to ICS 1st Year Book
Introduction to ICS 1st Year BookIntroduction to ICS 1st Year Book
Introduction to ICS 1st Year Book
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 

Recently uploaded

HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"mphochane1998
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 

Recently uploaded (20)

HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 

Curves and surfaces in OpenGL

  • 1. Curves and Surfaces in OpenGL 1
  • 2. Objectives • Introduce OpenGL evaluators • Learn to render polynomial curves and surfaces • Discuss quadrics in OpenGL • GLUT Quadrics • GLU Quadrics 2
  • 3. What Does OpenGL Support? •Evaluators: a general mechanism for working with the Bernstein polynomials • Can use any degree polynomials • Can use in 1-4 dimensions • Automatic generation of normals and texture coordinates • NURBS supported in GLU •Quadrics • GLU and GLUT contain polynomial approximations of quadrics 3
  • 4. One-Dimensional Evaluators • Evaluate a Bernstein polynomial of any degree at a set of specified values • Can evaluate a variety of variables • Points along a 2, 3 or 4 dimensional curve • Colors • Normals • Texture Coordinates • We can set up multiple evaluators that are all evaluated for the same value 4
  • 5. Setting Up an Evaluator 5 glMap1f(type,u_min,u_max,stride, order, pointer_to_array) what we want to evaluate max and min of u 1+degree of polynomial pointer to control data separation between data points Each type must be enabled by glEnable(type)
  • 6. Example 6 Consider an evaluator for a cubic Bezier curve over (0,1) point data[ ]={…………..}; * /3d data /* glMap1f(GL_MAP_VERTEX_3,0.0,1.0,3,4,data); data are 3D vertices cubic data are arranged as x,y,z,x,y,z…… three floats between data points in array glEnable(GL_MAP_VERTEX_3);
  • 7. Evaluating • The function glEvalCoord1f(u) causes all enabled evaluators to be evaluated for the specified u • Can replace glVertex, glNormal, glTexCoord • The values of u need not be equally spaced 7
  • 8. Example 8 • Consider the previous evaluator that was set up for a cubic Bezier over (0,1) • Suppose that we want to approximate the curve with a 100 point polyline glBegin(GL_LINE_STRIP) for(i=0; i<100; i++) glEvalCoord1f( (float) i/100.0); glEnd();
  • 9. Equally Spaced Points Rather than use a loop, we can set up an equally spaced mesh (grid) and then evaluate it with one function call 9 glMapGrid(100, 0.0, 1.0); sets up 100 equally-spaced points on (0,1) glEvalMesh1(GL_LINE, 0, 99); renders lines between adjacent evaluated points from point 0 to point 99
  • 10. Bezier Surfaces •Similar procedure to 1D but use 2D evaluators in u and v •Set up with glMap2f(type, u_min, umax, u_stride, u_order, v_min, v_max, v_stride, v_order, pointer_to_data) •Evaluate with glEvalCoord2f(u,v) 10
  • 11. Example 11 bicubic over (0,1) x (0,1) point data[4][4]={………}; glMap2f(GL_MAP_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, data); Note that in v direction data points are separated by 12 floats since array data is stored by rows
  • 12. Rendering with Lines 12 for(j=0;j<100;j++) { glBegin(GL_LINE_STRIP); for(i=0;i<100;i++) glEvalCoord2f((float) i/100.0, (float) j/100.0); glEnd(); glBegin(GL_LINE_STRIP); for(i=0;i<100;i++) glEvalCoord2f((float) j/100.0, (float) i/100.0); glEnd(); } must draw in both directions
  • 13. Rendering with Quadrilaterals 13 for(j=0; j<99; j++) { glBegin(GL_QUAD_STRIP); for(i=0; i<100; i++) { glEvalCoord2f ((float) i/100.0, (float) j/100.0); glEvalCoord2f ((float)(i+1)/100.0, (float)j/100.0); } glEnd(): } We can form a quad mesh and render with lines
  • 14. Uniform Meshes • We can form a 2D mesh (grid) in a similar manner to 1D for uniform spacing glMapGrid2(u_num, u_min, u_max, v_num, v_min, v_max) • Can evaluate as before with lines or if want filled polygons glEvalMesh2( GL_FILL, u_start, u_num, v_start, v_num) 14
  • 15. Rendering with Lighting • If we use filled polygons, we have to shade or we will see solid color uniform rendering • Can specify lights and materials but we need normals • Let OpenGL find them glEnable(GL_AUTO_NORMAL); 15
  • 16. NURBS • OpenGL supports NURBS surfaces through the GLU library • Why GLU? • Can use evaluators in 4D with standard OpenGL library • However, there are many complexities with NURBS that need a lot of code • There are five NURBS surface functions plus functions for trimming curves that can remove pieces of a NURBS surface 16
  • 17. Quadrics • Quadrics are in both the GLU and GLUT libraries • Both use polygonal approximations where the application specifies the resolution • Sphere: lines of longitude and lattitude • GLU: disks, cylinders, spheres • Can apply transformations to scale, orient, and position • GLUT: Platonic solids, torus, Utah teapot, cone 17
  • 20. Quadric Objects in GLU •GLU can automatically generate normals and texture coordinates •Quadrics are objects that include properties such as how we would like the object to be rendered 20 disk partial disk sphere
  • 21. Defining a Cylinder GLUquadricOBJ *p; P = gluNewQuadric(); /*set up object */ gluQuadricDrawStyle(GLU_LINE);/*render style*/ gluCylinder(p, BASE_RADIUS, TOP_RADIUS, BASE_HEIGHT, sections, slices); 21