66
Learning Objectives Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier Spline, Bezier Blobby Blobby Constructive Solid Geometry Constructive Solid Geometry

Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Embed Size (px)

Citation preview

Page 1: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Learning ObjectivesLearning Objectives 3D Object Representations3D Object Representations PolyhedronPolyhedron Quadrics, SuperQuadricsQuadrics, SuperQuadrics Spline, BezierSpline, Bezier BlobbyBlobby Constructive Solid GeometryConstructive Solid Geometry

Page 2: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

3D Object 3D Object RepresentationsRepresentations

Graphics scenes melibatkan berbagai jenis Graphics scenes melibatkan berbagai jenis objek dan material surfacesobjek dan material surfaces Trees, flowers, clouds, rocks, water, bricks, wood paneling, Trees, flowers, clouds, rocks, water, bricks, wood paneling,

rubber, paper, marble, steel, glass, plastic, etc.rubber, paper, marble, steel, glass, plastic, etc.

Bagaimana merepresentasikan objek 3D Bagaimana merepresentasikan objek 3D pada openGL?pada openGL?

Page 3: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

3D Object 3D Object RepresentationsRepresentations Untuk merepresentasikan objek 3D, ada Untuk merepresentasikan objek 3D, ada

beberapa teknikbeberapa teknik Menggunakan Menggunakan polygonpolygon dan dan quadric quadric untuk membuat untuk membuat

objek seperti polyhedrons ataupun ellipsoidsobjek seperti polyhedrons ataupun ellipsoids Untuk membuat permukaan berkurva seperti pada Untuk membuat permukaan berkurva seperti pada

sayap pesawat, gears, bodi mesin, etc, digunakan sayap pesawat, gears, bodi mesin, etc, digunakan Spline surfaces Spline surfaces

Constructive solid geometry Constructive solid geometry untuk menyusun untuk menyusun bentuk geometri dasar menjadi objek komplekbentuk geometri dasar menjadi objek komplek

Untuk memodelkan pegunungan, awan, tumbuhan, Untuk memodelkan pegunungan, awan, tumbuhan, atau air terjun digunakan procedural methods atau air terjun digunakan procedural methods seperti seperti fractalsfractals dan dan particle systemparticle system

Page 4: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Predefined ObjectsPredefined Objects

OpenGL sudah menyediakan fungsi OpenGL sudah menyediakan fungsi menggambar beberapa objek dasar yang menggambar beberapa objek dasar yang tinggal dipakai. Tak perlu membuat dari awal.tinggal dipakai. Tak perlu membuat dari awal.

Objek-objek dari OpenGL ini dapat disusun Objek-objek dari OpenGL ini dapat disusun untuk membuat bentuk yang kita inginkanuntuk membuat bentuk yang kita inginkan

Beberapa yang sudah disediakan OpenGL Beberapa yang sudah disediakan OpenGL antara lain:antara lain: PolyhedraPolyhedra Polyhedron functionsPolyhedron functions Quadric SurfacesQuadric Surfaces SuperquadricsSuperquadrics

Page 5: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

5

Object with Object with SuperquadricsSuperquadrics

Page 6: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

6

A. PolyhedronA. Polyhedron A polyhedron is a connected mesh of simple A polyhedron is a connected mesh of simple

planar polygons that encloses a finite amount planar polygons that encloses a finite amount of space. of space.

Polyhedron adalah rangkaian jala polygon Polyhedron adalah rangkaian jala polygon (polygon mesh) dengan kriteria sbb(polygon mesh) dengan kriteria sbb

Setiap edge dipakai oleh 2 facesSetiap edge dipakai oleh 2 faces

Sedikitnya 3 edge bertemu pada setiap Sedikitnya 3 edge bertemu pada setiap vertex.vertex.

Faces tidak saling menembus, tetapi Faces tidak saling menembus, tetapi berhenti pada suatu edge.berhenti pada suatu edge.

Euler’s formulaEuler’s formula : If : If FF, , EE, , VV represent the represent the number of faces, vertices and edges of a number of faces, vertices and edges of a polyhedron, then polyhedron, then

VV + + FF EE = 2. = 2.

Page 7: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

7

3D Object 3D Object RepresentationRepresentation

The data for polygonal meshes can be The data for polygonal meshes can be represented in two ways.represented in two ways. Method 1:Method 1:

Vertex ListVertex List Normal ListNormal List Face List (Polygon List)Face List (Polygon List)

Method 2:Method 2: Vertex ListVertex List Edge ListEdge List Face List (Polygon List)Face List (Polygon List)

Page 8: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Surface NormalSurface Normal

n

Page 9: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

9

01

2 3

45

6 7

Vertices and Faces - E.g. CubeVertices and Faces - E.g. Cube

0

1

23

4

5

Face Index

Vertex Index

01

2 3

5

6 7

Page 10: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

10

Data representation using vertex, face and normal lists:xyz axis

Vertex List Normal List Polygon List

30 30 30 0.0 0.0 1.0 0 1 2 3-30 30 30 0.0 0.0 -1.0 4 7 6 5-30 -30 30 0.0 1.0 0.0 0 4 5 1 30 -30 30 -1.0 0.0 0.0 1 5 6 2 30 30 -30 0.0 -1.0 0.0 2 6 7 3-30 30 -30 1.0 0.0 0.0 3 7 4 0-30 -30 -30 30 -30 -30

Page 11: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

11

Vertex List Edge List Polygon Listx[i] y[i] z[i] L[j] M[j] P[k] Q[k] R[k] S[k]

30 30 30 0 1 0 1 2 3-30 30 30 1 2 4 7 6 5-30 -30 30 2 3 0 4 5 1 30 -30 30 3 0 1 5 6 2 30 30 -30 4 5 2 6 7 3-30 30 -30 5 6 3 7 4 0-30 -30 -30 6 7 30 -30 -30 7 4

0 41 52 63 7

Data representation using vertex, face and edge lists:

Page 12: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

12

Normal Vectors Normal Vectors (OpenGL)(OpenGL)

Assigning a normal vector to a polygon:

glBegin(GL_POLYGON); glNormal3f(xn,yn,zn);

glVertex3f(x1,y1,z1);glVertex3f(x2,y2,z2);glVertex3f(x3,y3,z3);glVertex3f(x4,y4,z4);

glEnd();

Enabling automatic conversion of normal vectors to unit vectors:

glEnable(GL_NORMALIZE);

Page 13: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

13

Regular Polyhedra Regular Polyhedra ((Platonic Solids)Platonic Solids)

Jika semua face pada polyhedron adalah identik Jika semua face pada polyhedron adalah identik dan berupa regular polygon, maka polyhedron dan berupa regular polygon, maka polyhedron tsb disebut tsb disebut platonic solidplatonic solid. .

Hanya ada 5 jenis platonic solidHanya ada 5 jenis platonic solid

Page 14: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

The Platonic SolidsThe Platonic Solids Regular tetrahedron (or triangular Regular tetrahedron (or triangular

pyramid) has 4 facespyramid) has 4 faces Regular hexahedron (or cube) with 6 Regular hexahedron (or cube) with 6

facesfaces Regular octahedron with 8 facesRegular octahedron with 8 faces Regular dodecahedron with 12 facesRegular dodecahedron with 12 faces Regular icosahedron with 20 facesRegular icosahedron with 20 faces

Page 15: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Menggambar polyhedronMenggambar polyhedron

Ada 2 caraAda 2 cara Method1 : Fitting the surface with a Method1 : Fitting the surface with a

polygon mesh. polygon mesh. Membungkus Membungkus permukaan objek polyhedron dengan permukaan objek polyhedron dengan susunan jala polygonsusunan jala polygon. . Proses ini disebut Proses ini disebut juga dengan juga dengan surface tesselationsurface tesselation

Method 2 : Memakai fungsi yang Method 2 : Memakai fungsi yang disediakan library GLUTdisediakan library GLUT

Page 16: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Method-1 Polygon Method-1 Polygon MeshMesh

In fitting polygons to a surface, we In fitting polygons to a surface, we are not limited to using are not limited to using GL_POLYGONGL_POLYGON

We can also useWe can also use GL_TRIANGLESGL_TRIANGLES GL_TRIANGLE_STRIPGL_TRIANGLE_STRIP GL_TRIANGLE_FANGL_TRIANGLE_FAN GL_QUADSGL_QUADS GL_QUAD_STRIPGL_QUAD_STRIP

Page 17: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

17

Polygon MeshPolygon Mesh Polygon meshPolygon mesh ini juga bisa dipakai ini juga bisa dipakai

untuk memodelkan permukaan untuk memodelkan permukaan objek lainnyaobjek lainnya

Page 18: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Method 2- OpenGL Method 2- OpenGL Polyhedron FunctionsPolyhedron Functions

5 functions produce 5 functions produce wire frameswire frames which can which can be be easily useeasily usedd

Ex: glutWireX(), where X is one of the names Ex: glutWireX(), where X is one of the names Cube, Tetrahedron, Octahedron, Cube, Tetrahedron, Octahedron, Dodecahedron, or Icosahedron (with the first Dodecahedron, or Icosahedron (with the first letter capitalized).letter capitalized).

5 functions produce polyhedra facets as 5 functions produce polyhedra facets as shaded fill areasshaded fill areas - the characteristics of these - the characteristics of these are determined by material and lighting are determined by material and lighting properties.properties.

Ex: glutSolidX(), where X is as above.Ex: glutSolidX(), where X is as above.

Page 19: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLUT Library of Polyhedron GLUT Library of Polyhedron FunctionsFunctions

Example: prog8OGLGLUTPolyhedra.cppExample: prog8OGLGLUTPolyhedra.cpp

Page 20: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

glutWireTetrahedron() glutWireTetrahedron() and glutWireCube(1.0) and glutWireCube(1.0)

4 faces 6 faces

Page 21: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

glutWireOctahedron() andglutWireOctahedron() andglutWireDodecahedron()glutWireDodecahedron()

8 faces 12 faces

Page 22: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

And, And, glutWireIcosahedron()glutWireIcosahedron()

20 faces

Page 23: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

B.Quadrics

• Sphere

• Ellipsoid

• Torus

• General form

23

x 2 y 2 z2 r2

x

rx

2

y

ry

2

z

rz

2

1

r x

rx

2

y

ry

2

2

z

rz

2

1

ax 2 by 2 c z2 2 f yz 2gxz 2hxy 2px 2qy 2rz d 0

Objek yang didefinisikan sebagai persamaan quadraticsObjek yang didefinisikan sebagai persamaan quadratics

Page 24: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Quadric surfaces

• Double cones

• Ellipsoids

• Hyperboloids of one sheet

• Hyperboloids of two sheets

Page 25: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Quadric surfaces

• Elliptic paraboloids

• Hyperbolic paraboloids

Page 26: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Superquadrics• the squaring operations are replaced by

arbitrary powers.

• Superellipses1

/2/2

SS

b

y

a

x

Page 27: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Superquadrics

• Superellipsoids

11

1221 /2//2/2

SSSSS

c

x

b

y

a

x

Page 28: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLUT Quadric Functions – GLUT Quadric Functions – for Solids, Substitute for Solids, Substitute

Solid for WireSolid for Wire glutWireSphere(radius, slices, glutWireSphere(radius, slices,

stacks);stacks); glutWireCone(base, height, slices, glutWireCone(base, height, slices,

stacks);stacks); glutWireTorus(innerRadius, glutWireTorus(innerRadius,

outerRadius, nsides, rings);outerRadius, nsides, rings);

and the following is provided also!and the following is provided also!

glutWireTeapot(size);glutWireTeapot(size);

Page 29: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLUT Quadric FunctionsGLUT Quadric Functions

QuadricSurfs.cpp

Page 30: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLU Quadric-Surface GLU Quadric-Surface FunctionsFunctions

void void gluSpheregluSphere (GLUquadricObj *qobj, (GLUquadricObj *qobj, GLdouble radius,GLint slices, GLint GLdouble radius,GLint slices, GLint stacks);stacks);

void void gluCylindergluCylinder (GLUquadricObj *qobj, (GLUquadricObj *qobj, GLdouble baseRadius,GLdouble GLdouble baseRadius,GLdouble topRadius, GLdouble height,GLint slices, topRadius, GLdouble height,GLint slices, GLint stacks);GLint stacks);

void void gluDiskgluDisk (GLUquadricObj *qobj, (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble GLdouble innerRadius,GLdouble outerRadius, GLint slices, GLint rings);outerRadius, GLint slices, GLint rings);

Page 31: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLU Quadric-Surface GLU Quadric-Surface FunctionsFunctions

void void gluPartialDiskgluPartialDisk (GLUquadricObj *qobj, GLdouble (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble outerRadius, innerRadius,GLdouble outerRadius, GLint slices, GLint rings,GLdouble GLint slices, GLint rings,GLdouble startAngle, GLdouble sweepAngle);startAngle, GLdouble sweepAngle);

Page 32: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

GLU Quadric-Surface GLU Quadric-Surface FunctionsFunctions

Quadric.c

Page 33: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

WHY IS THE TEAPOT WHY IS THE TEAPOT POPULAR?POPULAR?

Pada zaman dahulu belum ada library packages untuk Pada zaman dahulu belum ada library packages untuk 3D modelling. Pemodelan objek 3D dilakukan dengan 3D modelling. Pemodelan objek 3D dilakukan dengan tangan, menggambar kurva dan titik2nya dicatat tangan, menggambar kurva dan titik2nya dicatat secara manual.secara manual.

Computer graphics researcher Computer graphics researcher Martin Newell, ketika , ketika hendak mencari barang untuk dibuat model hendak mencari barang untuk dibuat model matematika tak sengaja menemukan teapotmatematika tak sengaja menemukan teapot

Teapot adalah model yang ideal untuk eksperimen 3D Teapot adalah model yang ideal untuk eksperimen 3D modelling, karenamodelling, karena Mudah dikenalMudah dikenal Topologi yang komplekTopologi yang komplek Mempunyai proyeksi bayangan pada dirinya sendiriMempunyai proyeksi bayangan pada dirinya sendiri Melibatkan topik hidden surfaceMelibatkan topik hidden surface Memiliki permukaan cekung dan cembung, juga Memiliki permukaan cekung dan cembung, juga

saddle points (curved up and down)saddle points (curved up and down) Doesn't take much storage space Doesn't take much storage space

Page 34: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

The Utah TeapotThe Utah Teapot The real teapot---The real teapot---

The teapot was donated to the Boston Computer The teapot was donated to the Boston Computer Museum but now resides in the Ephemera collection Museum but now resides in the Ephemera collection of the of the Computer History Museum where it's where it's catalogued as "Teapot used for Computer Graphics catalogued as "Teapot used for Computer Graphics rendering" catalogue number X00398.1984. rendering" catalogue number X00398.1984.

Page 35: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Many Versions of Many Versions of TeapotsTeapots

From Steve Baker’s History of the Teapot site: http://www.sjbaker.org/teapot/index.html

Page 36: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

%^$@ Teapot!%^$@ Teapot!

From Steve Baker’s History of the Teapot site: http://www.sjbaker.org/teapot/index.html.

Page 37: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

wireframewireframe

Page 38: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Lighting & shadingLighting & shading

Page 39: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Texture mappedTexture mapped

Page 40: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Multiple Teapots of Various Multiple Teapots of Various MaterialsMaterialsteapots.c

Page 41: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

C. Spline RepresentationsC. Spline Representations Splines are used to design curves and Splines are used to design curves and

surfaces based on a set of user-defined surfaces based on a set of user-defined pointspoints

Control pointsControl points Himpunan titik koordinat yang mengontrol Himpunan titik koordinat yang mengontrol

bentuk kurvabentuk kurva InterpolationInterpolation

Semua control points tersambung satu sama lain Semua control points tersambung satu sama lain pada garis kurvapada garis kurva

ApproximateApproximate Semua atau beberapa control points terletak di Semua atau beberapa control points terletak di

luar garis kurvaluar garis kurva

Page 42: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Spline RepresentationsSpline Representations

Interpolated

Approximate

Page 43: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier Spline CurvesBezier Spline Curves

Developed by French engineer Developed by French engineer Pierre Bézier for use in the design of Pierre Bézier for use in the design of Renault automobile bodiesRenault automobile bodies

Easy to implementEasy to implement Widely used in CAD systems, graphics, Widely used in CAD systems, graphics,

drawing and painting packagesdrawing and painting packages

Page 44: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier Curve EquationsBezier Curve Equations Diketahui sejumlah n +1 control points,Diketahui sejumlah n +1 control points,

nilai k antara 0 sampai nnilai k antara 0 sampai n Persamaan garis Bezier akan membentuk Persamaan garis Bezier akan membentuk

titik-titik garis kurva sesuai control point titik-titik garis kurva sesuai control point yang didefinisikanyang didefinisikan

),,( kkkk zyxp

Page 45: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier Curve EquationsBezier Curve Equations Degree 1 – Linear CurveDegree 1 – Linear Curve

Degree 2Degree 2

Degree 3Degree 3

Degree nDegree n

Page 46: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier Spline CurvesBezier Spline Curves

A common use for Bezier curves is in A common use for Bezier curves is in font definitionfont definition

Page 47: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier Spline CurvesBezier Spline Curves

If we specify the first and the last If we specify the first and the last control point as the same point, we control point as the same point, we can generate a closed Bezier curvecan generate a closed Bezier curve

Page 48: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier SurfacesBezier Surfaces

Two sets of Bezier curves can be Two sets of Bezier curves can be used to design an object surfaceused to design an object surface

with pwith pj,kj,k specifying the location of specifying the location of (m+1) by (n+1) control points(m+1) by (n+1) control points

)()(),( ,,0 0

, uBEZvBEZpvuP nkmj

m

j

n

kkj

Page 49: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier SurfacesBezier Surfaces

u and v parametersu and v parameters

Page 50: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Bezier SurfacesBezier Surfaces

An example Bezier surfaceAn example Bezier surface

Page 51: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

OpenGL Approximation OpenGL Approximation Spline FunctionsSpline Functions

Bezier splines and B-splines can be Bezier splines and B-splines can be displayed using OpenGL functionsdisplayed using OpenGL functions

The core library contains Bezier The core library contains Bezier functions, and GLU has B-spline functions, and GLU has B-spline functionsfunctions

Bezier functions are often hardware Bezier functions are often hardware implementedimplemented

Page 52: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

OpenGL Bezier-Spline OpenGL Bezier-Spline Curve FunctionsCurve Functions

We specify parameters and activate We specify parameters and activate the routines for Bezier-curve display the routines for Bezier-curve display withwith

glMap1*(GL_MAP1_VERTEX_3, uMin, uMax, glMap1*(GL_MAP1_VERTEX_3, uMin, uMax, stride, nPts, *ctrlPts);stride, nPts, *ctrlPts);

glEnable(GL_MAP1_VERTEX_3);glEnable(GL_MAP1_VERTEX_3); and deactivate withand deactivate with

glDisable(GL_MAP1_VERTEX_3);glDisable(GL_MAP1_VERTEX_3); uMin and uMax are typically 0 and 1.0uMin and uMax are typically 0 and 1.0 stride=3 for 3Dstride=3 for 3D nPts is the number of control pointsnPts is the number of control points ctrlPts is the array of control pointsctrlPts is the array of control points

Page 53: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

OpenGL Bezier-Spline OpenGL Bezier-Spline Curve FunctionsCurve Functions

After setting parameters, we need to After setting parameters, we need to evaluate positions along the spline evaluate positions along the spline path and display the resulting curve. path and display the resulting curve. To calculate coordinate positions we To calculate coordinate positions we useuse

glEvalCoord1*(uValue);glEvalCoord1*(uValue);

where uValue is assigned some where uValue is assigned some value in the interval from uMin to value in the interval from uMin to uMaxuMax

Page 54: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Example OpenGL CodeExample OpenGL Code GLfloat ctrlPts [4][3] = { {-40.0, 40.0, 0.0}, {-10.0, 200.0, 0.0},GLfloat ctrlPts [4][3] = { {-40.0, 40.0, 0.0}, {-10.0, 200.0, 0.0}, {10.0, -200.0, 0.0}, {40.0, 40.0, 0.0} };{10.0, -200.0, 0.0}, {40.0, 40.0, 0.0} };

glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, *ctrlPts);glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, *ctrlPts); glEnable (GL_MAP1_VERTEX_3);glEnable (GL_MAP1_VERTEX_3);

GLint k;GLint k;

glColor3f (0.0, 0.0, 1.0); // Set line color to blue.glColor3f (0.0, 0.0, 1.0); // Set line color to blue. glBegin (GL_LINE_STRIP); // Generate Bezier "curve".glBegin (GL_LINE_STRIP); // Generate Bezier "curve". for (k = 0; k <= 50; k++)for (k = 0; k <= 50; k++) glEvalCoord1f (GLfloat (k) / 50.0);glEvalCoord1f (GLfloat (k) / 50.0); glEnd ( );glEnd ( );

glColor3f (1.0, 0.0, 0.0); // Set point color to red.glColor3f (1.0, 0.0, 0.0); // Set point color to red. glPointSize (5.0); // Set point size to 5.0.glPointSize (5.0); // Set point size to 5.0. glBegin (GL_POINTS); // Plot control points.glBegin (GL_POINTS); // Plot control points. for (k = 0; k < 4; k++)for (k = 0; k < 4; k++) glVertex3fv (&ctrlPts [k][0]);glVertex3fv (&ctrlPts [k][0]); glEnd ( );glEnd ( );

prog8OGLBezierCurve.cpp

Page 55: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Example OpenGL CodeExample OpenGL Code

prog8OGLBezierCurve.cpp

Page 56: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

OpenGL Bezier-Spline OpenGL Bezier-Spline SurfaceSurface Functions Functions

We specify parameters and activate the We specify parameters and activate the routines for Bezierroutines for Bezier surface surface display with display with

glMapglMap22*(GL_MAP*(GL_MAP22_VERTEX_3, uMin, uMax, _VERTEX_3, uMin, uMax, uSuStride, tride, nnuuPts, Pts, vMin, vMax, vStride, nvPts, vMin, vMax, vStride, nvPts, *ctrlPts);*ctrlPts);

glEnable(GL_MAPglEnable(GL_MAP22_VERTEX_3);_VERTEX_3);

and deactivate withand deactivate with glDisable(GL_MAPglDisable(GL_MAP22_VERTEX_3);_VERTEX_3);

uMinuMin,, uMax uMax, v, vMinMin and and vvMaxMax are typically 0 and are typically 0 and 1.01.0

stride=3 for 3Dstride=3 for 3D nnuuPts Pts and nvPts areand nvPts are the the size of the arraysize of the array ctrlPts is the ctrlPts is the double subscripted double subscripted array of control array of control

pointspoints

Page 57: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Example OpenGL CodeExample OpenGL CodeGLfloat ctrlpoints[4][4][3] = {GLfloat ctrlpoints[4][4][3] = { {{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0}, {{-1.5, -1.5, 4.0}, {-0.5, -1.5, 2.0}, {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}}, {0.5, -1.5, -1.0}, {1.5, -1.5, 2.0}},

{{-1.5, -0.5, 1.0}, {-0.5, -0.5, 3.0}, {{-1.5, -0.5, 1.0}, {-0.5, -0.5, 3.0}, {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}}, {0.5, -0.5, 0.0}, {1.5, -0.5, -1.0}},

{{-1.5, 0.5, 4.0}, {-0.5, 0.5, 0.0}, {{-1.5, 0.5, 4.0}, {-0.5, 0.5, 0.0}, {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}}, {0.5, 0.5, 3.0}, {1.5, 0.5, 4.0}},

{{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.0}, {{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.0}, {0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}}{0.5, 1.5, 0.0}, {1.5, 1.5, -1.0}}};};

glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]);glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]); glEnable(GL_MAP2_VERTEX_3);glEnable(GL_MAP2_VERTEX_3); for (j = 0; j <= 8; j++) {for (j = 0; j <= 8; j++) { glBegin(GL_LINE_STRIP);glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++)for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0);glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0); glEnd();glEnd(); glBegin(GL_LINE_STRIP);glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++)for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0);glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0); glEnd();glEnd(); }}

bezsurf.c

Page 58: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Example OpenGL CodeExample OpenGL Code

bezsurf.c

Page 59: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

59

Bézier Surfaces: Bézier Surfaces: ExampleExample

Utah Teapot Utah Teapot modeled by 32 modeled by 32 Bézier PatchesBézier Patches

Page 60: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

60

D. Blobby ObjectsD. Blobby Objects

Memodelkan Memodelkan objek yang dapat objek yang dapat berubah bentuk berubah bentuk tapi volumenya tapi volumenya tetaptetap

ContohContoh Water dropsWater drops Molecules Molecules Force fieldsForce fields

Page 61: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

Blobby ObjectsBlobby Objects A collection of density functionsA collection of density functions

Equi-density surfacesEqui-density surfaces

Page 62: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

62

Metaballs (Blinn Metaballs (Blinn Blobbies)Blobbies)

Page 63: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier

E.Constructive Solid E.Constructive Solid GeometryGeometry

Primitives Transformed Combined

Bermula dari objek geometri primitive, ditransformasikan dan dikombinasikan membentuk objek yang kompleks

Page 64: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier
Page 65: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier
Page 66: Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier