Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier."— Presentation transcript:

1 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

2 3D Object Representations Graphics scenes melibatkan berbagai jenis objek dan material surfaces Graphics scenes melibatkan berbagai jenis objek dan material surfaces Trees, flowers, clouds, rocks, water, bricks, wood paneling, rubber, paper, marble, steel, glass, plastic, etc. Trees, flowers, clouds, rocks, water, bricks, wood paneling, rubber, paper, marble, steel, glass, plastic, etc. Bagaimana merepresentasikan objek 3D pada openGL? Bagaimana merepresentasikan objek 3D pada openGL?

3 3D Object Representations Untuk merepresentasikan objek 3D, ada beberapa teknik Untuk merepresentasikan objek 3D, ada beberapa teknik Menggunakan polygon dan quadric untuk membuat objek seperti polyhedrons ataupun ellipsoids Menggunakan polygon dan quadric untuk membuat objek seperti polyhedrons ataupun ellipsoids Untuk membuat permukaan berkurva seperti pada sayap pesawat, gears, bodi mesin, etc, digunakan Spline surfaces Untuk membuat permukaan berkurva seperti pada sayap pesawat, gears, bodi mesin, etc, digunakan Spline surfaces Constructive solid geometry untuk menyusun bentuk geometri dasar menjadi objek komplek Constructive solid geometry untuk menyusun bentuk geometri dasar menjadi objek komplek Untuk memodelkan pegunungan, awan, tumbuhan, atau air terjun digunakan procedural methods seperti fractals dan particle system Untuk memodelkan pegunungan, awan, tumbuhan, atau air terjun digunakan procedural methods seperti fractals dan particle system

4 Predefined Objects OpenGL sudah menyediakan fungsi menggambar beberapa objek dasar yang tinggal dipakai. Tak perlu membuat dari awal. OpenGL sudah menyediakan fungsi menggambar beberapa objek dasar yang tinggal dipakai. Tak perlu membuat dari awal. Objek-objek dari OpenGL ini dapat disusun untuk membuat bentuk yang kita inginkan Objek-objek dari OpenGL ini dapat disusun untuk membuat bentuk yang kita inginkan Beberapa yang sudah disediakan OpenGL antara lain: Beberapa yang sudah disediakan OpenGL antara lain: Polyhedra Polyhedra Polyhedron functions Polyhedron functions Quadric Surfaces Quadric Surfaces Superquadrics Superquadrics

5 5 Object with Superquadrics

6 6 A. Polyhedron A polyhedron is a connected mesh of simple planar polygons that encloses a finite amount of space. A polyhedron is a connected mesh of simple planar polygons that encloses a finite amount of space. Polyhedron adalah rangkaian jala polygon (polygon mesh) dengan kriteria sbb Polyhedron adalah rangkaian jala polygon (polygon mesh) dengan kriteria sbb Setiap edge dipakai oleh 2 faces Setiap edge dipakai oleh 2 faces Sedikitnya 3 edge bertemu pada setiap vertex. Sedikitnya 3 edge bertemu pada setiap vertex. Faces tidak saling menembus, tetapi berhenti pada suatu edge. Faces tidak saling menembus, tetapi berhenti pada suatu edge. Eulers formula : If F, E, V represent the number of faces, vertices and edges of a polyhedron, then Eulers formula : If F, E, V represent the number of faces, vertices and edges of a polyhedron, then V + F E = 2. V + F E = 2.

7 7 3D Object Representation The data for polygonal meshes can be represented in two ways. The data for polygonal meshes can be represented in two ways. Method 1: Method 1: Vertex List Vertex List Normal List Normal List Face List (Polygon List) Face List (Polygon List) Method 2: Method 2: Vertex List Vertex List Edge List Edge List Face List (Polygon List) Face List (Polygon List)

8 Surface Normal n

9 9 0 1 23 4 5 6 7 Vertices and Faces - E.g. Cube 0 1 2 3 4 5 Face Index Vertex Index 0 1 23 5 6 7

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

11 11 Data representation using vertex, face and edge lists:

12 12 Normal Vectors (OpenGL)

13 13 Regular Polyhedra (Platonic Solids) Jika semua face pada polyhedron adalah identik dan berupa regular polygon, maka polyhedron tsb disebut platonic solid. Jika semua face pada polyhedron adalah identik dan berupa regular polygon, maka polyhedron tsb disebut platonic solid. Hanya ada 5 jenis platonic solid Hanya ada 5 jenis platonic solid

14 The Platonic Solids Regular tetrahedron (or triangular pyramid) has 4 faces Regular tetrahedron (or triangular pyramid) has 4 faces Regular hexahedron (or cube) with 6 faces Regular hexahedron (or cube) with 6 faces Regular octahedron with 8 faces Regular octahedron with 8 faces Regular dodecahedron with 12 faces Regular dodecahedron with 12 faces Regular icosahedron with 20 faces Regular icosahedron with 20 faces

15 Menggambar polyhedron Ada 2 cara Ada 2 cara Method1 : Fitting the surface with a polygon mesh. Membungkus permukaan objek polyhedron dengan susunan jala polygon. Proses ini disebut juga dengan surface tesselation Method1 : Fitting the surface with a polygon mesh. Membungkus permukaan objek polyhedron dengan susunan jala polygon. Proses ini disebut juga dengan surface tesselation Method 2 : Memakai fungsi yang disediakan library GLUT Method 2 : Memakai fungsi yang disediakan library GLUT

16 Method-1 Polygon Mesh In fitting polygons to a surface, we are not limited to using GL_POLYGON In fitting polygons to a surface, we are not limited to using GL_POLYGON We can also use We can also use GL_TRIANGLES GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLE_FAN GL_QUADS GL_QUADS GL_QUAD_STRIP GL_QUAD_STRIP

17 17 Polygon Mesh Polygon mesh ini juga bisa dipakai untuk memodelkan permukaan objek lainnya Polygon mesh ini juga bisa dipakai untuk memodelkan permukaan objek lainnya

18 Method 2- OpenGL Polyhedron Functions 5 functions produce wire frames which can be easily used 5 functions produce wire frames which can be easily used Ex: glutWireX(), where X is one of the names Cube, Tetrahedron, Octahedron, Dodecahedron, or Icosahedron (with the first letter capitalized). 5 functions produce polyhedra facets as shaded fill areas - the characteristics of these are determined by material and lighting properties. 5 functions produce polyhedra facets as shaded fill areas - the characteristics of these are determined by material and lighting properties. Ex: glutSolidX(), where X is as above.

19 GLUT Library of Polyhedron Functions Example: prog8OGLGLUTPolyhedra.cpp Example: prog8OGLGLUTPolyhedra.cpp

20 glutWireTetrahedron() and glutWireCube(1.0) 4 faces6 faces

21 glutWireOctahedron() and glutWireDodecahedron() 8 faces12 faces

22 And, glutWireIcosahedron() 20 faces

23 B.Quadrics Sphere Ellipsoid Torus General form 23 Objek yang didefinisikan sebagai persamaan quadratics Objek yang didefinisikan sebagai persamaan quadratics

24 Quadric surfaces Double cones Ellipsoids Hyperboloids of one sheet Hyperboloids of two sheets

25 Quadric surfaces Elliptic paraboloids Hyperbolic paraboloids

26 Superquadrics the squaring operations are replaced by arbitrary powers.squaring Superellipses

27 Superquadrics Superellipsoids

28 GLUT Quadric Functions – for Solids, Substitute Solid for Wire glutWireSphere(radius, slices, stacks); glutWireSphere(radius, slices, stacks); glutWireCone(base, height, slices, stacks); glutWireCone(base, height, slices, stacks); glutWireTorus(innerRadius, outerRadius, nsides, rings); glutWireTorus(innerRadius, outerRadius, nsides, rings); and the following is provided also! glutWireTeapot(size);

29 GLUT Quadric Functions QuadricSurfs.cpp

30 GLU Quadric-Surface Functions void gluSphere (GLUquadricObj *qobj, GLdouble radius,GLint slices, GLint stacks); void gluSphere (GLUquadricObj *qobj, GLdouble radius,GLint slices, GLint stacks); void gluCylinder (GLUquadricObj *qobj, GLdouble baseRadius,GLdouble topRadius, GLdouble height,GLint slices, GLint stacks); void gluCylinder (GLUquadricObj *qobj, GLdouble baseRadius,GLdouble topRadius, GLdouble height,GLint slices, GLint stacks); void gluDisk (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble outerRadius, GLint slices, GLint rings); void gluDisk (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble outerRadius, GLint slices, GLint rings);

31 GLU Quadric-Surface Functions void gluPartialDisk (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble outerRadius, GLint slices, GLint rings,GLdouble startAngle, GLdouble sweepAngle); void gluPartialDisk (GLUquadricObj *qobj, GLdouble innerRadius,GLdouble outerRadius, GLint slices, GLint rings,GLdouble startAngle, GLdouble sweepAngle);

32 GLU Quadric-Surface Functions Quadric.c

33 WHY IS THE TEAPOT POPULAR? Pada zaman dahulu belum ada library packages untuk 3D modelling. Pemodelan objek 3D dilakukan dengan tangan, menggambar kurva dan titik2nya dicatat secara manual. Pada zaman dahulu belum ada library packages untuk 3D modelling. Pemodelan objek 3D dilakukan dengan tangan, menggambar kurva dan titik2nya dicatat secara manual. Computer graphics researcher Martin Newell, ketika hendak mencari barang untuk dibuat model matematika tak sengaja menemukan teapot Computer graphics researcher Martin Newell, ketika hendak mencari barang untuk dibuat model matematika tak sengaja menemukan teapotMartin NewellMartin Newell Teapot adalah model yang ideal untuk eksperimen 3D modelling, karena Teapot adalah model yang ideal untuk eksperimen 3D modelling, karena Mudah dikenal Mudah dikenal Topologi yang komplek Topologi yang komplek Mempunyai proyeksi bayangan pada dirinya sendiri Mempunyai proyeksi bayangan pada dirinya sendiri Melibatkan topik hidden surface Melibatkan topik hidden surface Memiliki permukaan cekung dan cembung, juga saddle points (curved up and down) Memiliki permukaan cekung dan cembung, juga saddle points (curved up and down) Doesn't take much storage space Doesn't take much storage space

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

35 Many Versions of Teapots From Steve Bakers History of the Teapot site: http://www.sjbaker.org/teapot/index.htmlhttp://www.sjbaker.org/teapot/index.html

36 %^$@ Teapot! From Steve Bakers History of the Teapot site: http://www.sjbaker.org/teapot/index.html.http://www.sjbaker.org/teapot/index.html

37 wireframe

38 Lighting & shading

39 Texture mapped

40 Multiple Teapots of Various Materials teapots.c

41 C. Spline Representations Splines are used to design curves and surfaces based on a set of user-defined points Splines are used to design curves and surfaces based on a set of user-defined points Control points Control points Himpunan titik koordinat yang mengontrol bentuk kurva Himpunan titik koordinat yang mengontrol bentuk kurva Interpolation Interpolation Semua control points tersambung satu sama lain pada garis kurva Semua control points tersambung satu sama lain pada garis kurva Approximate Approximate Semua atau beberapa control points terletak di luar garis kurva Semua atau beberapa control points terletak di luar garis kurva

42 Spline Representations Interpolated Approximate

43 Bezier Spline Curves Developed by French engineer Pierre Bézier for use in the design of Renault automobile bodies Developed by French engineer Pierre Bézier for use in the design of Renault automobile bodies Easy to implement Easy to implement Widely used in CAD systems, graphics, drawing and painting packages Widely used in CAD systems, graphics, drawing and painting packages

44 Bezier Curve Equations Diketahui sejumlah n +1 control points, Diketahui sejumlah n +1 control points, nilai k antara 0 sampai n Persamaan garis Bezier akan membentuk titik-titik garis kurva sesuai control point yang didefinisikan Persamaan garis Bezier akan membentuk titik-titik garis kurva sesuai control point yang didefinisikan

45 Bezier Curve Equations Degree 1 – Linear Curve Degree 1 – Linear Curve Degree 2 Degree 2 Degree 3 Degree 3 Degree n Degree n

46 Bezier Spline Curves A common use for Bezier curves is in font definition A common use for Bezier curves is in font definition

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

48 Bezier Surfaces Two sets of Bezier curves can be used to design an object surface Two sets of Bezier curves can be used to design an object surface with p j,k specifying the location of (m+1) by (n+1) control points

49 Bezier Surfaces u and v parameters u and v parameters

50 Bezier Surfaces An example Bezier surface An example Bezier surface

51 OpenGL Approximation Spline Functions Bezier splines and B-splines can be displayed using OpenGL functions Bezier splines and B-splines can be displayed using OpenGL functions The core library contains Bezier functions, and GLU has B-spline functions The core library contains Bezier functions, and GLU has B-spline functions Bezier functions are often hardware implemented Bezier functions are often hardware implemented

52 OpenGL Bezier-Spline Curve Functions We specify parameters and activate the routines for Bezier-curve display with We specify parameters and activate the routines for Bezier-curve display with glMap1*(GL_MAP1_VERTEX_3, uMin, uMax, stride, nPts, *ctrlPts); glMap1*(GL_MAP1_VERTEX_3, uMin, uMax, stride, nPts, *ctrlPts); glEnable(GL_MAP1_VERTEX_3); glEnable(GL_MAP1_VERTEX_3); and deactivate with and deactivate with glDisable(GL_MAP1_VERTEX_3); glDisable(GL_MAP1_VERTEX_3); uMin and uMax are typically 0 and 1.0 uMin and uMax are typically 0 and 1.0 stride=3 for 3D stride=3 for 3D nPts is the number of control points nPts is the number of control points ctrlPts is the array of control points ctrlPts is the array of control points

53 OpenGL Bezier-Spline Curve Functions After setting parameters, we need to evaluate positions along the spline path and display the resulting curve. To calculate coordinate positions we use After setting parameters, we need to evaluate positions along the spline path and display the resulting curve. To calculate coordinate positions we useglEvalCoord1*(uValue); where uValue is assigned some value in the interval from uMin to uMax

54 Example 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

55 Example OpenGL Code prog8OGLBezierCurve.cpp

56 OpenGL Bezier-Spline Surface Functions We specify parameters and activate the routines for Bezier surface display with We specify parameters and activate the routines for Bezier surface display with glMap2*(GL_MAP2_VERTEX_3, uMin, uMax, uStride, nuPts, vMin, vMax, vStride, nvPts, *ctrlPts); glMap2*(GL_MAP2_VERTEX_3, uMin, uMax, uStride, nuPts, vMin, vMax, vStride, nvPts, *ctrlPts); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_MAP2_VERTEX_3); and deactivate with and deactivate with glDisable(GL_MAP2_VERTEX_3); glDisable(GL_MAP2_VERTEX_3); uMin, uMax, vMin and vMax are typically 0 and 1.0 uMin, uMax, vMin and vMax are typically 0 and 1.0 stride=3 for 3D stride=3 for 3D nuPts and nvPts are the size of the array nuPts and nvPts are the size of the array ctrlPts is the double subscripted array of control points ctrlPts is the double subscripted array of control points

57 Example OpenGL Code 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

58 Example OpenGL Code bezsurf.c

59 59 Bézier Surfaces: Example Utah Teapot modeled by 32 Bézier Patches Utah Teapot modeled by 32 Bézier Patches

60 60 D. Blobby Objects Memodelkan objek yang dapat berubah bentuk tapi volumenya tetap Memodelkan objek yang dapat berubah bentuk tapi volumenya tetap Contoh Contoh Water drops Water drops Molecules Molecules Force fields Force fields

61 Blobby Objects A collection of density functions A collection of density functions Equi-density surfaces Equi-density surfaces

62 62 Metaballs (Blinn Blobbies)

63 E.Constructive Solid Geometry Primitives TransformedCombined Bermula dari objek geometri primitive, ditransformasikan dan dikombinasikan membentuk objek yang kompleks

64

65

66


Download ppt "Learning Objectives 3D Object Representations 3D Object Representations Polyhedron Polyhedron Quadrics, SuperQuadrics Quadrics, SuperQuadrics Spline, Bezier."

Similar presentations


Ads by Google