## Collision Detection

creater16
Unregistered

Post: #1
Hello everyone,

I am trying to do collision detection, I am thinking to do bounding box collision, however, I am not sure how to set bounding volume for my camera? Do I just Draw a box around it, for example? How do i do that?

THanks alot
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
If you make a box around the camera position and test is for collision with other bounding boxes that will tell you if the camera is nearish a bounding box.

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Member
Posts: 157
Joined: 2002.12
Post: #3
For the camera using a sphere may give you smoother results and is easier to implement.
Sage
Posts: 1,403
Joined: 2005.07
Post: #4
Unless you wanted to detect collision with it and a box, which would be harder to implement.

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Member
Posts: 157
Joined: 2002.12
Post: #5
In that case you will need quite a bit of math.
the basics would be point plane intersection, and point face intersection.

this site has lots of articles about the subject
Gamasutra

A chapter from the book "Graphics Gems II" Ray Triangle Intersection Using Binary Recursive Subdivision help me a lot when I was trying to do CD and .

Advanced Character Physics even though the title may sound intimidating the core of all this stuff (Verlet integration scheme) is one of the easiest ways to handle stable collision detection.

Sage
Posts: 1,403
Joined: 2005.07
Post: #6
There is, use box-box collision.

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Member
Posts: 153
Joined: 2004.12
Post: #7
The type of collision detection to use depends on a whole lot of factors:

how accurate you want it to be, how much math you can handle, how you intend to respond to the detection...etc...

What type of game are you making? is this only for the camera?

There was a long silence...
'I claim them all,' said the Savage at last.
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
How much math do you want to do? I just got done getting planes of arbitrary boundaries to collide, and here's a walkthrough of what I did. If you're interested, I can also post more specific info:

I figure that in order for 2 planes to collide, at least one boundary line of one plane must collide with the other plane. What I do is I take each bounding line of each plane and break it into a parametric equation. I plug that into the plane equation of the other plane and check the point of where it collides. A collision occurred if point is within the line's boundary (with the way I implemented it, basically if the value of t is between 0 and 1) and the point is within boundary of the other plane (basically you check the rays between the vertices and the points, add the angles between each of the consecutive rays, and if it reaches 2*pi radians (or 360Â°) it's inside the boundaries) With this method it is necessary to check first the one plane against the second, then the second against the first one. It's possible to speed things up by doing things such as seeing if the point is within the boundaries of the line, then only plug it into the plane equation if it is.

If you have no idea about how to do any of these things (such as create a plane equation or a parametric line equation), I suggest you either find a library that does this or just use spherical collisions. If this is only for the camera, I'd suggest just using spherical collision, but if this is for other things as well, it would probably be worth your time to work it out.