1 / 14

Collition Detection

Collition Detection. Agung Toto Wibowo http://gameprogramming.blog.ittelkom.ac.id. Pendahuluan. Collision detection komponen dasar dari game 3D/2D. Tanpa Collision detection, karakter mungkin saja menembus walls atau halangan lain. Aksi yang terjadi setelah collision detection :

latona
Download Presentation

Collition Detection

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. Collition Detection Agung Toto Wibowo http://gameprogramming.blog.ittelkom.ac.id

  2. Pendahuluan • Collision detection komponendasardari game 3D/2D. • Tanpa Collision detection, karaktermungkinsajamenembus walls atauhalangan lain. • Aksi yang terjadisetelah collision detection : • Rule • Collision response

  3. Basic Game Loop while(1){ process_input(); update_objects(); render_world(); } update_objects(){ for (each_object) save_old_position(); calc new_object_position {based on velocity accel. etc.} if (collide_with_other_objects()) new_object_position = old_position(); {or if destroyed object remove it etc.} }

  4. Rectangles collision detection • menggukan bound berbentukpersegi • Objekmemilikiruangkosong yang besardengan bound • Terkadangtidaktabrakandianggaptabrakan • boolIsSeparate( const CBox& box1, const CBox& box2 ) • { • if ( ( box1.xMin > box2.xMax ) || • ( box2.xMin > box1.xMax ) || • ( box1.yMin > box2.yMax ) || • ( box2.yMin > box1.yMax ) ) • { • return true; • } • else • { • return false; • } • }

  5. Reduced size bounding box • kotakbatasnyadiperkecil : mengurangiukuran sprite sebenarnya • ruangkosongdapatdikurangi

  6. Multi Bounding Box • menggunakanbeberapa bounding box secarabersamaanpada sprite atauobjek • ruangkosonglebihdapatdikurangilagi • Konsekuensiwaktulebih lama

  7. Circle collision detection • batasberbentuklingkaran • Membandingkanjarakkeduaobjekdenganjumlah radius masing-masing bound • (ax-bx)2+(ay-by)2 < (ar+br)2

  8. PerpotonganGaris • Note : Atw Issues • Objekakanbertabrakanjikaadagaris yang berpotongan. • Algortima ???

  9. Total Sudut • Perhatikansifatdari point yang adadidalamruangan • Total sudut = 360°

  10. 3D Collision Detection • HOW???? • Rectangles collision detection • Reduced size bounding box • Multi Bounding Box • Circle collision detection • PerpotonganGaris • Total Sudut

  11. Collision Response • Rule • Batalkanpergerakan • Object mati/menghilang • Momentum • Kekekalanenergikinetik (hukumnewton) • Elastisitas

  12. Momentum • Contohpadatabrakanmobil/motor/bola • Sumber : http://en.wikipedia.org/wiki/Elastic_collision

  13. Momentum • Untuk 2D/3D

  14. Diskusi • Pseudo code algorithm??? • Problem??? • Answer??? • Dimana collision detection pada game anda?

More Related