Collision detection tutorial

Christopoulos Dimitrios

The source code upon which this tutorial is based, is from an older contest entry of mine (at OGLchallenge.dhs.org). The theme was Collision Crazy and my entry (which by the way took the 1st place :)) was called Magic Room. It features collision detection, physically based modeling and effects.

Ad Content

Collision Detection

A quite difficult subject and to be honest as far as I have seen until now, there is no easy general solution for it. For every application a slightly different way of finding and testing for collisions can be employed. Of course there are brute force algorithms which are very general but expensive and would work for every kind of objects.

We are going to investigate algorithms which are very fast, easy to understand and to some extend quite flexible. Furthermore importance must be given on what to do once a collision is detected and how to move the objects, in accordance to the laws of physics. So we have a lot stuff to cover. Lets review first what we are going to learn (click on headers to continue).

1) Collision Detection

 Moving Sphere – Plane

 Moving Sphere – Cylinder

 Moving Sphere – Moving Sphere

2) Physically Based Modeling

 Collision response

 Moving under Gravity using Euler equations

3) Special Effects

 Explosion Modeling using a Fin-Tree billboard method.

 Sounds using the windows multimedia library (windows only ;()

4) Explaining the code

The code is divided into 5 files.

image.cpp, image.h: code from tutorial 6 to load bitmaps

MagicRoom.cpp: main code of the demo

Tmatrix33.cpp, TMatrix33.h: Classes to handle rotations

TRay.cpp, TRay.h: Classes to handle ray operations

TVector.cpp, TVector.h: Classes to handle vector operations

A lots of handy code. The Vector, Ray and Matrix classes are very useful, a nice library to have. I used them until now for personal projects.



(Ctrl + Down Arrow)
(Ctrl + Up Arrow)

Реклама


Партнёры