Advertisement

Collision detection with triangles as the basis of all computer graphics…?

Started by March 26, 2015 07:37 PM
10 comments, last by jacmoe 9 years, 9 months ago

I understand that any shape can be created (or approximated) by smaller triangles. Any rectangle can be created by 2 smaller triangles. Any circle can be created by many thin "pizza slice" triangles. What are other examples?

Next, how does this translate to collision detection? I understand how to calculate rectangle overlap using the veritices. I understand how to calculate circle overlap using the center, radii, and distance.

But, how does one do collision detection on shapes made of small triangles? Not specifics, but just the general concept....

You can create a normal from 3 vertices and then a plane from the normal and a point on the plane (1 of the 3 vertices).

Then it's just a matter of performing collision against a plane.

Too many projects; too much time

Advertisement


Then it's just a matter of performing collision against a plane.

Followed by: if there is a collision with that plane, test if the collision point is within the associated triangle.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Then you start getting numeric problems, falling out of the world, rays poking through meshes, tunneling, etc. These problems make representing the world as triangles very difficult.

Graphics and physics are different.

Usually what you see on the screen only has a very rough correlation to what is happening in the physics processing.

You see a graphics of an articulated character with arms and legs and body parts. The physics system uses either a capsule or a snowman of 2-3 spheres.

You see a terrain with trees and grass and rocks and complex terrain. The physics system usually sees a very simple mesh defining what areas can be traveled and what is blocked.

Edit: some images found via Google:

3.jpg

soderNavmesh.png


Then it's just a matter of performing collision against a plane.

Followed by: if there is a collision with that plane, test if the collision point is within the associated triangle.

Indeed, since a plane is infinite. :)

Then you start getting numeric problems, falling out of the world, rays poking through meshes, tunneling, etc. These problems make representing the world as triangles very difficult.

You're right. I've been there, and felt the pain myself. :)

That really depends on whether or not you actually need to perform collision detection on the polygon/triangle level.

Pretty soon you'll want to look into broad-phase, sweep and prune, gjk, oob trees, everything o_o

And then you'll probably want to use a collision detection library. ;)

However, for learning purposes, it is a really useful exercise.

Too many projects; too much time

Advertisement

You can create a normal from 3 vertices and then a plane from the normal and a point on the plane (1 of the 3 vertices).

Then it's just a matter of performing collision against a plane.

I'm not sure what a "normal" is.

Is it possible to illustrate a very simple example of this concept?

I recommend that you buy a book:

3D Math Primer For Graphics And Game Development

There's a 2nd edition out now - unfortunately there is no new link from gamedev.net.

That's an excellent book!

Here's a series for game developers that teaches math:

<edit>

Here's Wikipedia on normals: http://en.wikipedia.org/wiki/Normal_%28geometry%29

Too many projects; too much time

Here's a good overview of vector math: http://www.gamedev.net/page/resources/_/technical/math-and-physics/practical-use-of-vector-math-in-games-r2968

Too many projects; too much time

I'm not sure what a "normal" is.

Is it possible to illustrate a very simple example of this concept?

A normal is a vector which is orthogonal (at a right angle) to another vector or plane. In a 2D space you can get a right-side normal as follows:

vector = {x, y}

normal = {-y, x}

Normals are used in a variety of calculations, especially collision and lighting. The reasons become clear when you study dot products and cross products, which can be found within the materials linked by jacmoe.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement