• 沒有找到結果。

OpenGL and Parametric Curves-advanced multimedia technology: computer graphics

N/A
N/A
Protected

Academic year: 2021

Share "OpenGL and Parametric Curves-advanced multimedia technology: computer graphics"

Copied!
80
0
0

加載中.... (立即查看全文)

全文

(1)

OpenGL and Parametric

Curves

Advanced Multimedia Technology: Computer Graphics

Yung-Yu Chuang

2005/12/21

with slides by Brian Curless, Zoran Popovic, Robin Chen and Doug J ames

(2)

Review of graphics pipeline

(3)

Review of graphics pipeline

(4)

Review of graphics pipeline

• Rasterization • Visibility

(5)

Review of graphics pipeline

(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)

OpenGL

• A low-level OS-independent graphics API for 2D and 3D interactive graphics.

• Initiated by SGI (called GL at early time) • Implementation, for Windows, hardware

vendors provide suitable drivers for their own products; for Linux, we have Mesa.

(16)

Helper libraries

• OpenGL does not provide OS-dependent functions such as windowing and input

– GL: core graphics functions

– GLU: graphics utilities in top of GL – GLUT: input and windowing functions

(17)

How does it work?

• From the programmer’s view

– Specify geometric properties of the objects – Describe material properties

– Define viewing

– Define camera and object transformations

• OpenGL is a state machine

– States: color, material properties, line width, current viewing

– States are applied to subsequent drawing commands – Input: description of geometric objects

(18)

How does it work

• From the implementer’s perspective • Graphics pipeline Primitives + material properties Rotate Translate Scale Is it Visible? 3D to 2D Scan conversion Visibility determination Display

(19)

Primitives: drawing a polygon

// put GL into polygon drawing mode glBegin(GL_POLYGON); // define vertices glVertex2f(x0, y0); glVertex2f(x1, y1); glVertex2f(x2, y2); glEnd();

(20)

Primitives

(21)

Polygon restrictions

• In OpenGL, polygons must be simple and convex

(22)

Attributes

• Part of the state of the graphics pipeline • Set before primitives are drawn.

• Remain in effect! • Example:

– Color, including transparency – Reflection properties

(23)

Primitives: material properties

• glColor3f(r,g,b);

All subsequent primitives will use this color. Colors are not attached to objects. The above command only changes the system states.

• OpenGL uses red, green and blue color model. Each components are ranged within 0 and 1.

(24)
(25)

Simple transformations

• Rotate by a given angle (in degrees) about ray f rom origin through (x,y,z)

glRotate{fd}(angle, x, y, z);

• Translate by a given x, y, z values

glTranslate{fd}(x, y, z);

• Scale with a factor in the x, y, and z directions

glScale{fd}(x, y, z);

(26)

Orthographic projection

(27)

Camera transformations

• gluLookAt(eyex, eyey, eyez, cx, cy, cz, upx, up y, upz);

(28)
(29)
(30)
(31)

Callback functions

• Handle “events”, Idle, Keyboard, Mouse, Menu, Motion, Reshape

• The display callback is installed by glutDisplayF unc()

(32)
(33)

Results

(34)

Depth buffer in OpenGL

• glutInitDisplayMode(GLUT_DEPTH); • glEnable(GL_DEPTH_TEST);

(35)

Double buffering

• Flicker if drawing overlaps screen refresh • Solution: use two frame buffers

– Draw into one buffer

– Swap and display, while drawing other buffer

• glutInitDisplayMode(GLUT_SINGLE) • glutInitDisplayMode(GLUT_DOUBLE) • glutSwapBuffers()

(36)

Example: rotate a color cube

(37)

Example: rotate a color cube

• Step 2: enable depth testing and double buffering

(38)

Example: rotate a color cube

(39)

Example: rotate a color cube

• Step 4: reshape callback, enclose cube, preserve aspect ratio

(40)

Example: rotate a color cube

• Step 5: display callback, clear, rotate, draw, flush, swap

(41)

Example: rotate a color cube

• Step 6: draw cube by drawing faces, orientation consistency

(42)

Example: rotate a color cube

(43)

Example: rotate a color cube

• Step 8: animation, set idle callback spinCube

(44)

Example: rotate a color cube

• Step 9: change axis of rotation using mouse callback

(45)

Example: rotate a color cube

• Step 10: toggle rotation or exit using keyboard callback

(46)
(47)
(48)

Cubic curves

N too small less flexibility in controlling the shape of → the curve

(49)
(50)

Constrain the cubics

Hermite: defined by two endpoints and two endpoint tangent vectors

Bezier: defined by two endpoints and two other points that control the endpoint tangent vectors

(51)
(52)
(53)
(54)
(55)
(56)
(57)
(58)
(59)
(60)
(61)
(62)

Bezier curve

•each is between 0 and 1

(63)
(64)
(65)

What do we want for a curve?

• Local control • Interpolation • Continuity

(66)

Local control

• One problem with Bezier curve is that every control points affect every point on the curve (except for endpoints). Moving a single control point affects the whole curve.

• We’d like to have local control, that is, have each control point

affect some

well-defined neighborhood around that point.

(67)

Interpolation

• Bezier curves are approximating. The curve

does not necessarily pass through all the control points. We’d like to have a curve that is

interpolating, that is, that always passes through every control points.

(68)

Continuity

• We want our curve to have continuity: there shouldn’t be any abrupt changes as we move along the curve.

(69)

Splines

• We will splice together a curve from individual Bezier segments. We call these curves splines. When splicing Bezier together, we need to worr y about continuity.

(70)
(71)
(72)
(73)
(74)
(75)

Catmull-Rom basis matrix

                                       3 2 1 0 61 6 1 6 1 61 3 2 1 0 0 1 0 0 1 0 0 1 0 0 1 0 P P P P V V V V                                           3 2 1 0 3 2 1 0 0 0 0 1 0 0 3 3 0 3 6 3 1 3 3 1 ) ( ) ( V V V V T V V V V t B t Q b

(76)
(77)
(78)
(79)
(80)

參考文獻

相關文件

 Promote project learning, mathematical modeling, and problem-based learning to strengthen the ability to integrate and apply knowledge and skills, and make. calculated

Like the governments of many advanced economies which have formulated strategies to promote the use of information technology (IT) in learning and teaching,

S1 Singlet-triplet energy gap (in kcal/mol) of n-cyclacene as a function of the number of benzene rings, calculated using TAO-LDA and KS-LDA.. For com- parison, the CASPT2, KS-M06L,

(A) AGP ( advanced graphics port ) (B) IDE ( integrated drive electronics ) (C) SATA ( serial at attachment ). (D) SCSI ( small computer system interface

Overview of a variety of business software, graphics and multimedia software, and home/personal/educational software Web applications and application software for

To assist with graphics and multimedia projects To assist with graphics and multimedia projects To support home, personal, and educational tasks To support home, personal,

• It is a plus if you have background knowledge on computer vision, image processing and computer graphics.. • It is a plus if you have access to digital cameras

• Detlef Ruprecht, Heinrich Muller, Image Warping with Scattered Data Interpolation, IEEE Computer Graphics and Applications, March 1995, pp37-43. • Seung-Yong Lee, Kyung-Yong