Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Objectives 3D Object Representations Polyhedron

Similar presentations


Presentation on theme: "Learning Objectives 3D Object Representations Polyhedron"— Presentation transcript:

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

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

3 3D Object Representations
Untuk merepresentasikan objek 3D, ada beberapa teknik 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 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

4 Predefined Objects 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 Beberapa yang sudah disediakan OpenGL antara lain: Polyhedra Polyhedron functions Quadric Surfaces Superquadrics

5 Object with Superquadrics

6 A. Polyhedron 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 Setiap edge dipakai oleh 2 faces Sedikitnya 3 edge bertemu pada setiap vertex. Faces tidak saling menembus, tetapi berhenti pada suatu edge. Euler’s formula : If F, E, V represent the number of faces, vertices and edges of a polyhedron, then V + F  E = 2.

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

8 Surface Normal n

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

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

11 Data representation using vertex, face and edge lists:

12 Normal Vectors (OpenGL)

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

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

15 Menggambar polyhedron
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 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 We can also use GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP

17 Polygon Mesh 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 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. Ex: glutSolidX(), where X is as above.

19 GLUT Library of Polyhedron Functions
Example: prog8OGLGLUTPolyhedra.cpp

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

21 glutWireOctahedron() and glutWireDodecahedron()
8 faces 12 faces

22 And, glutWireIcosahedron()
20 faces

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

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. Superellipses

27 Superquadrics Superellipsoids

28 GLUT Quadric Functions – for Solids, Substitute Solid for Wire
glutWireSphere(radius, slices, stacks); glutWireCone(base, height, slices, stacks); 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 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);

31 GLU Quadric-Surface Functions
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. Computer graphics researcher Martin Newell, ketika hendak mencari barang untuk dibuat model matematika tak sengaja menemukan teapot Teapot adalah model yang ideal untuk eksperimen 3D modelling, karena Mudah dikenal Topologi yang komplek Mempunyai proyeksi bayangan pada dirinya sendiri Melibatkan topik hidden surface Memiliki permukaan cekung dan cembung, juga saddle points (curved up and down) Doesn't take much storage space

34 The Utah 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 X

35 Many Versions of Teapots
From Steve Baker’s History of the Teapot site:

36 Teapot! From Steve Baker’s History of the Teapot site:

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 Control points Himpunan titik koordinat yang mengontrol bentuk kurva Interpolation Semua control points tersambung satu sama lain pada garis kurva Approximate 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 Easy to implement Widely used in CAD systems, graphics, drawing and painting packages

44 Bezier Curve Equations
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

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

46 Bezier Spline Curves 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

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

49 Bezier Surfaces u and v parameters

50 Bezier Surfaces An example Bezier surface

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

52 OpenGL Bezier-Spline Curve Functions
We specify parameters and activate the routines for Bezier-curve display with glMap1*(GL_MAP1_VERTEX_3, uMin, uMax, stride, nPts, *ctrlPts); glEnable(GL_MAP1_VERTEX_3); and deactivate with glDisable(GL_MAP1_VERTEX_3); uMin and uMax are typically 0 and 1.0 stride=3 for 3D nPts is the number 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 glEvalCoord1*(uValue); where uValue is assigned some value in the interval from uMin to uMax

54 Example OpenGL Code prog8OGLBezierCurve.cpp
GLfloat ctrlPts [4][3] = { {-40.0, 40.0, 0.0}, {-10.0, 200.0, 0.0}, {10.0, , 0.0}, {40.0, 40.0, 0.0} }; glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, *ctrlPts); glEnable (GL_MAP1_VERTEX_3); GLint k; glColor3f (0.0, 0.0, 1.0); // Set line color to blue. glBegin (GL_LINE_STRIP); // Generate Bezier "curve". for (k = 0; k <= 50; k++) glEvalCoord1f (GLfloat (k) / 50.0); glEnd ( ); glColor3f (1.0, 0.0, 0.0); // Set point color to red. glPointSize (5.0); // Set point size to 5.0. glBegin (GL_POINTS); // Plot control points. for (k = 0; k < 4; k++) glVertex3fv (&ctrlPts [k][0]); 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 glMap2*(GL_MAP2_VERTEX_3, uMin, uMax, uStride, nuPts, vMin, vMax, vStride, nvPts, *ctrlPts); glEnable(GL_MAP2_VERTEX_3); and deactivate with glDisable(GL_MAP2_VERTEX_3); uMin, uMax, vMin and vMax are typically 0 and 1.0 stride=3 for 3D nuPts and nvPts are the size of the array ctrlPts is the double subscripted array of control points

57 Example OpenGL Code bezsurf.c GLfloat ctrlpoints[4][4][3] = {
{{-1.5, -1.5, 4.0}, {-0.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}, {0.5, -0.5, 0.0}, {1.5, -0.5, -1.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}}, {{-1.5, 1.5, -2.0}, {-0.5, 1.5, -2.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]); glEnable(GL_MAP2_VERTEX_3); for (j = 0; j <= 8; j++) { glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord2f((GLfloat)i/30.0, (GLfloat)j/8.0); glEnd(); glEvalCoord2f((GLfloat)j/8.0, (GLfloat)i/30.0); } bezsurf.c

58 Example OpenGL Code bezsurf.c

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

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

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

62 Metaballs (Blinn Blobbies)

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

64

65

66


Download ppt "Learning Objectives 3D Object Representations Polyhedron"

Similar presentations


Ads by Google