Curves: OpenGL Evaluators - Intro

Similar documents
OpenGL Programming Guide Chapter 12, Evaluators and NURBS 1

An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June

Splines Computer Graphics I Lecture 10

B-spline Curves. Smoother than other curve forms

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

Objectives. Texture Mapping and NURBS Week 7. The Limits of Geometric Modeling. Modeling an Orange. Three Types of Mapping. Modeling an Orange (2)

Lecture 2. Determinants. Ax = 0. a 11 x 1 + a 12 x a 1n x n = 0 a 21 x 1 + a 22 x a 2n x n = 0

Supplement to Lecture 11

Information Coding / Computer Graphics, ISY, LiTH. Splines

Computer Graphics Spline and Surfaces

Curves and Surfaces 1

Introduction to OpenGL

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Exercise 1 Introduction to OpenGL

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Curves. Computer Graphics CSE 167 Lecture 11

Computer Graphics CS 543 Lecture 13a Curves, Tesselation/Geometry Shaders & Level of Detail

Adaptive Tessellation for Trimmed NURBS Surface

3D Modeling Parametric Curves & Surfaces

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

Lecture 4 of 41. Lab 1a: OpenGL Basics

Computergrafik. Matthias Zwicker. Herbst 2010

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

CHAPTER 1 Graphics Systems and Models 3

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

Computer Graphics. Bing-Yu Chen National Taiwan University

Derivative. Bernstein polynomials: Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 313

Computer Graphics Course 2005

Real-Time Graphics Architecture

Curves and Surfaces Computer Graphics I Lecture 9

1 Preview. Dr. Scott Gordon Computer Science Dept. CSUS. Virtual Cameras, Viewing Transformations: CSc-155 Advanced Computer Graphics

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

OpenGL Transformations

Direct Rendering of Trimmed NURBS Surfaces

GL9: Engineering Communications. GL9: CAD techniques. Curves Surfaces Solids Techniques

CONTENTS... 1 OPENGL REFERENCE MANUAL...

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

Curves & Surfaces. Last Time? Progressive Meshes. Selective Refinement. Adjacency Data Structures. Mesh Simplification. Mesh Simplification

Computer Graphics I Lecture 11

Curves and Curved Surfaces. Adapted by FFL from CSE167: Computer Graphics Instructor: Ronen Barzel UCSD, Winter 2006

HE COMPLETE OPENGL PROGI FOR WINDOW WIND

To Do. Resources. Algorithm Outline. Simplifications. Advanced Computer Graphics (Spring 2013) Surface Simplification: Goals (Garland)

3D Modeling: Surfaces

Curves and Surfaces Computer Graphics I Lecture 10

Intro to Modeling Modeling in 3D

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

Lecture outline. COMP30019 Graphics and Interaction Rendering pipeline & object modelling. Introduction to modelling

CS-184: Computer Graphics

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

2D Spline Curves. CS 4620 Lecture 13

World Coordinate System

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

9. Three Dimensional Object Representations

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

For each question, indicate whether the statement is true or false by circling T or F, respectively.

6.837 Introduction to Computer Graphics Assignment 5: OpenGL and Solid Textures Due Wednesday October 22, 2003 at 11:59pm

Shading System Immediate-Mode API v2.2

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

CATIA V4/V5 Interoperability Project 2 : Migration of V4 surface : Influence of the transfer s settings Genta Yoshioka

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

C OMPUTER G RAPHICS Thursday

CS770/870 Spring 2017 Curve Generation

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1

Lectures OpenGL Introduction

VALLIAMMAI ENGINEERING COLLEGE

Graphics and Interaction Rendering pipeline & object modelling

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

15.10 Curve Interpolation using Uniform Cubic B-Spline Curves. CS Dept, UK

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

Lighting and Texturing

Readings on Bézier Curves and Surfaces. 1 Additional Reading. 2 Organization. 3 Introduction. 4 Representing Curves

skim it quickly and read any sections that appear both relevant and accessible.

Lecture 2 2D transformations Introduction to OpenGL

Outline. The de Casteljau Algorithm. Properties of Piecewise Linear Interpolations. Recall: Linear Interpolation

Beginning Direct3D Game Programming: 1. The History of Direct3D Graphics

Curves & Surfaces. MIT EECS 6.837, Durand and Cutler

2D Spline Curves. CS 4620 Lecture 18

OUTLINE. Tessellation in OpenGL Tessellation of Bezier Surfaces Tessellation for Terrain/Height Maps Level of Detail

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

GLSL: Creating GLSL Programs - Overview

Types of Curves. Lecture 7. Parametric Curves. Plane Curves. - Not flexible enough, e.g. Circle. - e.g: ax+by+c = 0, x2 +y 2 -c 2 = 0

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

CSE528 Computer Graphics: Theory, Algorithms, and Applications

VR-programming tools (procedural) More VRML later in this course! (declarative)

GLSL Overview: Creating a Program

Rendering Curves and Surfaces. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Need for Parametric Equations

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

CSE 167: Introduction to Computer Graphics Lecture #7: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

Building Models. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

The Free-form Surface Modelling System

The Application Stage. The Game Loop, Resource Management and Renderer Design

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Further Graphics. Bezier Curves and Surfaces. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Intro to Curves Week 4, Lecture 7

Transcription:

Curves: OpenGL Evaluators - Intro Evaluators are used to describe polynomials, splines, curved surfaces of any degree Based on Bézier curves If want to use another curve form, programmer must provide code to convert other form s basis to Bézier basis OpenGL provides evaluators for 1D and 2D Also provides high-level interface for NURBS (via GLU) Interface implemented in terms of evaluators Q(t) = T M B G B Programmer supplies G B and granularity of t Evaluator plots the curve Evaluator can also generate color info, normals, and texture coordinates for points on the curve/surface To use evaluators: 1. Define evaluator 2. Enable evaluator 3. Draw the curve 1

1D evaluators use a single parameter Specify curves Steps in using: 1. Defining: Curves: OpenGL Evaluators - 1D void glmap1{fd} (GLenum target, TYPE u1, TYPE u2, GLint stride, GLint order, const TYPE *points); target values and semantics: Value GL MAP1 VERTEX 3 GL MAP1 VERTEX 4 GL MAP1 INDEX GL MAP1 COLOR 4 GL MAP1 NORMAL GL MAP1 TEXTURE COORD 1 GL MAP1 TEXTURE COORD 2 GL MAP1 TEXTURE COORD 3 GL MAP1 TEXTURE COORD 4 Semantics (x, y, z) vertex (x, y, z, w) vertex color index R, G, B, A [ ] x y z s tex coord s, t tex coords s, t, r tex coords s, t, r, q tex coords points: Array holding values to be processed (CPs, colors, normals, etc. u1, u2: Initial and final values of curve parameter stride: Number of values separating successive data items in points - Can have several types of data intermingled in one data array order: Order of curve Order is degree + 1 Cubic order is 4 (number of CPs) Note: (a) Each call to glmap1* creates an evaluator for the given target type (b) Color, tex coords, etc. for curve must be defined in terms of evaluators 2. Enabling Evaluators enabled using glenable with one of the target values used in glmap1* Can only have 1 VERTEX and 1 TEX COORD evaluator enabled at any time 2

3. Drawing Curves: OpenGL Evaluators - 1D (2) (a) Method 1: Specifying values of u explicitly void glevalcoord1{fd}(type u); void glevalcoord1{fd}v(type *u); Causes evaluation of all currently-enabled 1D maps at value u glevalcoord* should be placed between glbegin/glend pair (b) Method 2: Automatic generation of regular grid Done in 2 steps: i. Specify the parameters to be used to draw the curve void glmapgrid1{fd}(glint n, TYPE u1, TYPE u2); Indicates curve is to be drawn from u1 to u2 in n evenly-spaced intervals ii. Draw the curve void glevalmesh1(glenum mode, GLint p1, GLint p2); Mode: GL POINT, GL LINE p1, p2: Delimiting values of u over which curve is to be drawn 0 p1, p2 n glevalmesh1 applies the defined grid to all enabled evaluators 3

Extension of 1D evaluators Steps in using: 1. Defining: Curves: OpenGL Evaluators - 2D void glmap2{fd} (GLenum target, TYPE u1, TYPE u2, GLint ustride, TYPE v1, TYPE v2, GLint vstride, GLint order, const TYPE *points); target values and semantics: Value GL MAP2 VERTEX 3 GL MAP2 VERTEX 4 GL MAP2 INDEX GL MAP2 COLOR 4 GL MAP2 NORMAL GL MAP2 TEXTURE COORD 1 GL MAP2 TEXTURE COORD 2 GL MAP2 TEXTURE COORD 3 GL MAP2 TEXTURE COORD 4 Semantics (x, y, z) vertex (x, y, z, w) vertex color index R, G, B, A [ ] x y z s tex coord s, t tex coords s, t, r tex coords s, t, r, q tex coords points: As in Map1 u1, u2: As in Map1 u direction left to right ustride: Number of values separating successive data items in u dimension in points uorder: Order of curve in u direction v1, v2, vorder: v direction versions of u1, u2, uorder v direction bottom to top Order in u and v can be different 2. Enabling As in 1D, using MAP2 types 4

3. Drawing Curves: OpenGL Evaluators - 2D (2) (a) Specifying values of u, v explicitly Use void glevalcoord2{fd}(type u, TYPE v); void glevalcoord2{fd}v(type *values); Analogous to 1D version When VERTEX evaluator enabled, normals automatically generated when GL AUTO NORMAL property in effect Otherwise, programmer must supply normals using Map2 evaluator If no normal map is provided, current normal is used (b) Automatic generation of regular grid i. Specify the parameters to be used to draw the curve void glmapgrid2{fd}(glint nu, TYPE u1, TYPE u2, GLint nv, TYPE v1, TYPE v2); Analogous to Map1 version Defines an nu nv grid ii. Draw the curve void glevalmesh2(glenum mode, GLint i1, GLint i2, GLint j1, GLint j2); Mode: GL POINT, GL LINE, GL FILL i1, i2: start and end steps along u j1, j2: start and end steps along v 5

Curves: OpenGL Evaluators - Textures To use texture mapping, need a separate 2D Bézier patch Patch is planar: Patch is defined by 4 CPs CPs defined in terms of x and y only 6

Curves: OpenGL NURBS Interface - Intro NURBS interface provide by the GLU Implemented in terms of evaluators Steps in using are similar to those used in tessellation Create a NURBS rendering object Register callback functions Set/enable properties Start the surface Generate the curve End the surface Deallocate the rendering object 7

Curves: OpenGL NURBS Interface - Creating and Destroying To create a NURBS object: void GLUnurbsObj* glunewnurbsrenderer (void); If creation is unsuccessful, 0 is returned To destroy a NURBS object: void gludeletenurbsrenderer (GLUnurbsObj *nobj); 8

Curves: OpenGL NURBS Interface - Properties Major difference between tessellation and NURBS programming is that In tessellation, callbacks are primary way in which characteristics of tessellators are controlled; setting properties is secondary and not required In NURBS, properties are primary way in which characteristics of NURBS are controlled; callbacks are secondary and not required To set NURBS properties: void glunurbsproperty (GLUnurbsObj *obj, GLenum property, GLfloat value); property and values: Property GLU DISPLAY MODE GLU NURBS MODE GLU CULLING GLU SAMPLING METHOD GLU SAMPLING TOLERANCE float (default 50.0) GLU PARAMETRIC TOLERANCE float (default 0.5) GLU U STEP int (default 100) GLU V STEP (default 100) GLU AUTO LOAD MATRIX Value GLU FILL (default) GLU OUTLINE POLYGON GLU OUTLINE PATCH GLU NURBS RENDERER (default) GLU NURBS TESSELLATOR GL FALSE (default) GLU TRUE GLU PATH LENGTH (default) GLU PARAMETRIC ERROR GLU DOMAIN DISTANCE GLU OBJECT PATH LENGTH GLU OBJECT PARAMETER ERROR GLU TRUE GLU FALSE 9

Curves: OpenGL NURBS Interface - Properties (2) DISPLAY MODE: Controls how surface displayed FILL renders surface as polygons OUTLINE POLYGON renders as outlines of polygons created by NURBS tessellation OUTLINE PATCH renders only outlines of patches and trimming curves NURBS MODE: Controls whether surface is drawn automatically NURBS RENDERER causes surface to be drawn NURBS TESSELLATOR returns results of tessellation to callback functions CULLING: Turns culling on and off SAMPLING METHOD: Controls how u, v are sampled PATH LENGTH: Limits number of pixels per edge to be value set by SAMPLING TOLERANCE PARAMETRIC ERROR: Limits distance in pixels between tessellated polygon and actual surface to be value set by PARAMETRIC TOLERANCE DOMAIN DISTANCE: Specifies number of sampling points per unit length in u, v as given by U STEP and V STEP OBJECT PATH LENGTH: As PATH LENGTH, but distance specified in terms of object space, not pixels OBJECT PARAMETER ERROR: As PARAMETRIC ERROR, but distance specified in terms of object space, not pixels GLU SAMPLING TOLERANCE: See SAMPLING METHOD GLU PARAMETRIC TOLERANCE: See SAMPLING METHOD GLU U STEP, GLU V STEP: Control number of sampling points per unit length GLU AUTO LOAD MATRIX: Specifies whether projection, model view, and view port mapping matrices are downloaded from the server (GL TRUE) or will be supplied by gluloadsamplingmatrices (See below) 10

Curves: OpenGL NURBS Interface - Properties (3) To manually control viewing aspects: gluloadsamplingmatrices (GLUnurbsObj *obj, const GLfloat modelmatrix[16], const GLfloat projmatrix[16], const GLint viewport[4]); To determine current values of properties: void glugetnurbsproperty (GLUnurbsObj *obj, GLenum property, GLfloat *value); 11

Curves: OpenGL NURBS Interface - Drawing Curves Drawing delimited by begin/end pair: void glubegincurve (GLUnurbsObj *obj); void gluendcurve (GLUnurbsObj *obj); These save and restore underlying evaluator state Drawing commands: void glunurbscurve (GLUnurbsObj *obj, GLint uknot count, GLfloat *uknot, GLint u stride, GLfloat *ctlarray, GLint uorder, GLenum type); type: Specifies what the data represents Uses same values as 1D evaluators (e.g., GL MAP1 VERTEX 3) uorder: Order of the curve *ctlarray: Array of CPs *uknot count: How many knots in the curve ustride: Number of values between successive CPs By default, NURBS evaluator automatically generates curves and surfaces and draws them without programmer needing to specify callbacks 12

To register callbacks: Curves: OpenGL NURBS Interface - Callbacks void glunurbscallback (GLUnurbsObj *obj, GLenum type, void (*fn)() foo); Valid types and corresponding function prototypes: Type GLU NURBS BEGIN GLU NURBS BEGIN DATA GLU NURBS END GLU NURBS END DATA GLU NURBS VERTEX GLU NURBS VERTEX DATA GLU NURBS COLOR GLU NURBS COLOR DATA GLU NURBS NORMAL GLU NURBS NORMAL DATA GLU NURBS TEXTURE COORD GLU NURBS TEXTURE COORD DATA GLU NURBS ERROR Prototype void begin (GLenum type); void begin (GLenum type, void *user data); void begin (void); void begin (void *user data); void begin (void *vertex data); void begin (void *vertex data, void *user data); void begin (GLfloat *color); void begin (GLfloat *color, void *user data); void begin (GLfloat *normals); void begin (GLfloat *normals, void *user data); void begin (void *tex coords); void begin (void *tex coords, void *user data); void begin (GLenum errno); glunurbscallback works the same way as glutesscallback Drawing mode controlled by NURBS MODE property NURBS RENDERER mode generates image automatically The only callback that will be active (if registered) is ERROR NURBS TESSELLATOR mode inhibits automatic image generation All registered callbacks are in effect Programmer needs to include appropriate calls in callbacks in order to generate the image This mode provided so programmer has access to values generated by NURBS tessellator 13

Curves: OpenGL NURBS Interface - Drawing Surfaces Drawing delimited by begin/end pair: 1. For curves: void glubegincurve (GLUnurbsObj *obj); void gluendcurve (GLUnurbsObj *obj); 2. For surfaces: void glubeginsurface (GLUnurbsObj *obj); void gluendsurface (GLUnurbsObj *obj); 3. These save and restore underlying evaluator state Drawing commands: 1. For curves: void glunurbscurve (GLUnurbsObj *obj, GLint uknot count, GLfloat *uknot, GLint u stride, GLfloat *ctlarray, GLint uorder, GLenum type); type: Specifies what the data represents Uses same values as 1D evaluators (e.g., GL MAP1 VERTEX 3) uorder: Order of the curve *ctlarray: Array of CPs *uknot count: How many knots in the curve ustride: Number of values between successive CPs 2. For surfaces: void glunurbssurface (GLUnurbsObj *obj, GLint uknot count, GLfloat *uknot, GLint vknot count, GLfloat *vknot, GLint u stride, GLint v stride, GLfloat *ctlarray, GLint uorder, GLint vorder, GLenum type); Parameters same as for curves in both u and v directions By default, NURBS tessellator automatically generates curves and surfaces and draws them without programmer needing to specify callbacks 14

Curves: OpenGL NURBS Interface - Trimming Trimming somewhat comparable to contours in tessellation Like contours, trimming allows creation of holes in NURBS surface Unlike contours, they are not required Trimming calls appear between begin/end delimiters of NURBS surface Trimming itself delimited by begin/end pair: void glubegintrim (GLUnurbsObj *obj); void gluendtrim (GLUnurbsObj *obj); Trimming specified in terms of closed curves Curves must be closed manually Trimming curve may be constructed piecewise from many individuallydefined curve segments Programmer must insure that end point of one segment is start point of next Orientation of curve determines how trim is effected As follow curve from start to end, points to the left are retained, points to the right are excluded (trimmed) If trimming curves are nested, programmer must insure that inconsistencies do not exist Trimming curves cannot intersect 15

Types of trimming curves 1. NURBS Curves: OpenGL NURBS Interface - Trimming (2) Created with glunurbscurve Must be contained within 0 u, v 1 Type must be GLU MAP1 TRIM 2 or GLU MAP1 TRIM 3 TRIM 2 is usual mode TRIM 3 includes homogeneous coordinate 2. Piecewise linear curve Creates a curve approximated by straight line segments Specified using void glupwlcurve (GLUnurbsObj *obj, GLint count, GLfloat *array, GLint stride, GLenum type); *array: Array of points on the curve count: Number of points on the curve type: GLU MAP1 TRIM 2 or GLU MAP1 TRIM 3 stride: Number of values between successive points in array (dependent on TRIM 2 or TRIM 3) 16