1 / 20

04 |Transformation

04 |Transformation. Eriq Muhammad Adams J | eriq.adams@ub.ac.id. Transformation. Modeling transformation. Menggerakkan objek dari local coordinates ke world coordinates.

roxy
Download Presentation

04 |Transformation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 04 |Transformation Eriq Muhammad Adams J | eriq.adams@ub.ac.id

  2. Transformation • Modeling 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.

  3. Vertex Transformation Pipeline ModelView Matrix Vertex Data (x, y, z, w) Model Transformation Matrix View Transformation Matrix World Coordinates Eye Coordinates Normalized Device Coordinates Window Coordinates (x,y) Clip Coordinates Viewport Transformation Perspective Division Projection Transformation Matrix

  4. Urutan penulisan transformasi • Urutan penulisan transformasi dalam program (terbalik dari urutan vertex transformation pipeline) : • Viewport Transformation • Viewing Transformation • Projection Transformation • Modelling Transformation

  5. Modelling Transformation Translation glTranslate{fd}(TYPE x, TYPE y, TYPE z) Rotation glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z) Scaling glScale{fd}(TYPE x, TYPE y, TYPE z)

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

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

  8. Matrix Stack • Stack untuk menyimpan matrix utk modelling & projection transformation dan color. • Ada 4 tipe matrix stack : • Modelview matrix stack • Projection matrix stack • Color matrix stack • Texture matrix stack

  9. Matrix Stack (cont.)

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

  11. Viewing Transformation • Camera secara default akan mengarah ke sumbu z negatif.

  12. 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);

  13. Projection Transformation • 2 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)

  14. 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);

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

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

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

  18. Viewport Transformation • Setting viewport menggunakan glViewport(). void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); Width Viewport Height (x,y)

  19. Hello Transformation!

  20. Tugas ke-1 • Membuat 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 : • Judul • Anggota Kelompok • Pembagian Tugas • Kode Program • Flow-chart Program • Penjelasan kode program • Screenshot Program

More Related