pengenalan pola transformation

20
04 |Transformation Eriq Muhammad Adams J | [email protected]

Upload: hisadi-honkasilo

Post on 04-Nov-2015

233 views

Category:

Documents


0 download

DESCRIPTION

Penjelasan Transformasi pada matakuliah pengenalan pola

TRANSCRIPT

  • 04 |TransformationEriq Muhammad Adams J | [email protected]

  • TransformationModeling transformation. Menggerakkan objek dari local coordinates ke world coordinates.Viewing transformation. Memposisikan dan mengarahkan camera, dan menggerakkan objek dari world coordinates ke eye or camera coordinates.Projection transformation. Mendefinisikan viewing volume and clipping planes dan memetakan objek dari eye coordinates ke clip coordinates.Viewport transformation. Memetakan clip coordinates ke 2D viewport, atau window, atau layar.

  • Vertex Transformation PipelineVertex Data(x, y, z, w)Model Transformation MatrixView Transformation MatrixProjection Transformation MatrixPerspective DivisionViewport TransformationModelView MatrixWorld CoordinatesEyeCoordinatesClipCoordinatesNormalizedDeviceCoordinatesWindowCoordinates(x,y)

  • Urutan penulisan transformasiUrutan penulisan transformasi dalam program (terbalik dari urutan vertex transformation pipeline) :Viewport TransformationViewing TransformationProjection TransformationModelling Transformation

  • Modelling TransformationTranslationRotationScalingglTranslate{fd}(TYPE x, TYPE y, TYPE z)glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z)glScale{fd}(TYPE x, TYPE y, TYPE z)

  • Modelling Transformation (cont.)Urutan transformasi mempengaruhi hasil.

  • Modelling Transformation (cont.)How to code :Aktifasi ModelView Matrix :glMatrixMode(GL_ModelView);Me-reset ModelView Matrix :glLoadIdentity()Melakukan TransformationMe-Render Objek

  • Matrix StackStack untuk menyimpan matrix utk modelling & projection transformation dan color.Ada 4 tipe matrix stack :Modelview matrix stackProjection matrix stackColor matrix stackTexture matrix stack

  • Matrix Stack (cont.)

  • Matrix Stack (cont.)Menyimpan current matrix dalam stack menggunakan glPushMatrix(), dan menghapus matrix teratas menggunakan glPopMatrix().

  • Viewing TransformationCamera secara default akan mengarah ke sumbu z negatif.

  • Viewing Transformation (cont.)Menggunakan gluLookAt() :void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz);

  • Projection Transformation2 tipe projection transformation : Perspective projection :Menampilkan 3D world secara perspektif (ada unsur depth), objek yang jauh ditampilkan lebih kecil daripada objek yang dekat.Orthographic projection :Menampilkan semua objek dalam ukuran yang sebenarnya (tidak ada unsur depth, biasa digunakan untuk CAD program, 2D games, dsb)

  • Projection Transformation (cont.)Orthographic projection menggunakan glOrtho() atau gluOrtho2D(). glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);

  • Projection Transformation (cont.)Perspective projection menggunakan glFustrum() dan gluPerspective(). void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);

  • Projection Transformation (cont.)void gluPerspective(GLdouble fov, GLdouble aspect, GLdouble near, GLdouble far);

  • Projection Transformation (cont.)How to code :Aktifasi Projection Matrix :glMatrixMode(GL_Projection);Mereset Projection Matrix :glLoadIdentity()Melakukan TransformationMe-render Objek

  • Viewport TransformationSetting viewport menggunakan glViewport(). void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);ViewportHeightWidth(x,y)

  • Hello Transformation!

  • Tugas ke-1Membuat model 3D bergerak yang tersusun dari kubus (seperti model LEGO misal helicopter, mobil, dsb). Dikumpulkan dan dibahas minggu depan (laporan + kode program + executable).Program menggunakan vertex arrays / VBO dan transformation.Format laporan harus berisi :JudulAnggota KelompokPembagian Tugas Kode ProgramFlow-chart ProgramPenjelasan kode programScreenshot Program