visitors:
3 guests

  

Triangle-Triangle Collision Demo

 -- CGameProgrammer @ 1075898580
 
 

watch
 
link
 
edit
 
referrers
 
[edited 6 times; latest by CGameProgrammer on 1076216400 -- highlight modified text]

I've been working on triangle-triangle collision detection / collision handling for several months but finally have it working, as far as I can tell (let's hope). I'll probably write an article later explaining in detail the algorithm, but for now I'm just releasing the demo and its source code.

Feel free to modify it, like by creating a better level to test the algorithm, or loading models and colliding them with each other. Also rewriting it with SDL wouldn't be a bad idea either.

Source code (Visual C++ project) and executable for Release #2

This contains full source code, but if you use it or anything derived from it, please e-mail me!

Instructions are in Main.cpp. Requirements are Windows and a 3D card. A good CPU is strongly recommended since this demo contains no optimizations at all.

Please leave feedback here, especially if you find a bug.

(post edited for clarification of some stuff -- at the moment I'm the first Google result for "triangle-triangle collision", yay)

Add a comment to Triangle-Triangle Collision Demo
Or use this simplified quick-reply form. You do not need to register to post comments. Just make up any name. You should also enter something in the password field so you can edit your comment later.
Name:   Password (optional)
  Comment: 
 

 View DrPetter's Profile

Registered: 1043891160
Comments: 508
Posts: 13
Timezone: GMT (Sweden)
Gateway: skrivare.liu.se
DrPetter
4 February 2004 3:51 pm
#1
Seems pretty solid... but urgh - the horrid flashbacks I get by looking through the code, I remember tearing my hair out over sphere/triangle collisions a few years ago... these things can be really hard if something goes wrong.
Please write that article, it would be an interesting read (even though I'll probably not try to implement it, I'm happy with vertex<->triangle collisions for now
).
 
 View CGameProgrammer's Profile

Registered: 1044255000
Comments: 1044
Posts: 8
Timezone: GMT
Gateway: 134.197.XXX.XXX
CGameProgrammer
4 February 2004 4:14 pm
#2
Hehe, the original collision my engine used was sphere-triangle and it kept failing in certain circumstances so I eventually gave up on it. I don't get nervous when looking through the code for this stuff, but I do definitely get nervous when actually running the demo or the engine because I keep feeling like I'm going to fall through the ground at any moment.


The article most likely won't explain every single bit of code since that will be too complicated and boring to make for good reading. I expect it'll be more high-level with lots of illustrations, because that's the type of article I can actually learn from. But we'll see... I may write it, then revise it based on feedback.

When I write the article, I'll probably edit this post to turn it into an article. I just need to allow <img> HTML tags, which I should've done a while ago but never got around to.
edited on 4 February 2004 4:20 pm 
 View DrPetter's Profile

Registered: 1043891160
Comments: 508
Posts: 13
Timezone: GMT (Sweden)
Gateway: skrivare.liu.se
DrPetter
4 February 2004 6:46 pm
#3
...and you should make a News/Announcements browser, and possibly rename the category as well... a name that also suggests articles/tutorials/tips would be cool, I could see myself writing small explanations of various game programming related techniques (like that comment about movement inertia) if there was a simple way of writing/uploading them (like the current post form) and a clear place to put them - and with commenting, they could be edited to reflect users' opinions/suggestions ("I don't understand, explain X better" / "please use an illustration for Y" / etc...)
It would add some content to the site and might bring more visitors

(it *would* be a slight diversion from the main theme of the site though... speaking of which, this comment might actually belong in the Site Discussion thread
)
edited on 4 February 2004 6:47 pm 
 View CGameProgrammer's Profile

Registered: 1044255000
Comments: 1044
Posts: 8
Timezone: GMT
Gateway: 134.197.XXX.XXX
CGameProgrammer
4 February 2004 7:27 pm
#4
My posts always get into site discussion, it's fine. It did occur to me to maybe add an 'article' category but I worried it might be too off-topic. I use the site for non-image posts but that's mostly to help promote it


I agree that a browser of these posts is needed, and I meant to do something about it a long time ago but never did. "News/Announcements" is not a great category name but I couldn't think of anything better. Can you?

Where do you think the browser should be? Should it be one of the options in the menu? (Where?) Or should non-image posts just have a link "View more news/announcements" somewhere that brings up the browser?

Programming this site is very easy but it's the design that I always have trouble with.
 
 View CGameProgrammer's Profile

Registered: 1044255000
Comments: 1044
Posts: 8
Timezone: GMT
Gateway: 134.197.XXX.XXX
CGameProgrammer
7 February 2004 2:40 am
#5
I've added a new release. There are two changes -- in gravity mode, by default, your movement is mapped to the plane of the gravity vector and your original movement vector. What this means is you won't move sideways if walking over a sideways-facing slope. This mimicks the way we walk over the ground. The other change is when in path-prediction mode, moving the pyramid around moves it along its own directional vector instead of the camera's.
 
 Registered: 1076137300
Comments: 1
Posts: 0
Timezone: GMT
Gateway: az.npgco.com
shurcooL
7 February 2004 4:01 am
#6
Hey,

That's a nice demo. I can imagine how hard this can be, since I've done something similar in 2D.

Only bug I found was that when you try to 'walk' into a corner that is made out of more than 3 triangles connected (as far as I could tell), your triangle player starts jerking (sort of shaking a bit). I have the exact same problem in my 2D circle-to-line collision handle algo, and although I tried, I never got around to fixing it (it's possible, just takes a bit more effort than I could put in at the moment).

Other than that, it's a job well done. Congratulations.

Thanks,
shurcooL
 
 View CGameProgrammer's Profile

Registered: 1044255000
Comments: 1044
Posts: 8
Timezone: GMT
Gateway: 134.197.XXX.XXX
CGameProgrammer
7 February 2004 4:05 am
#7
reply to comment #6 by shurcooL:
I know what causes that; it's easy to see if you use the path-prediction mode. For each subcollision, the directional vector is mapped to the plane, but with more than one plane this can cause the vector to turn around 180 degrees, which is not right.

Anyway with two planes facing each other, what ends up happening is you move up one, then back down it and up the other, then the cycle repeats. It's like a skater on a half-pipe. Anyway the solution is just to manipulate the new directional vector somehow (like how I manipulate it for 'human' movement) but I'm not sure how to do it yet. Still, it's sort of a physics issue more than a collision issue.
 
 Timezone: GMT + 7
Gateway: 202.109.XXX.XX
Anonymous
4 May 2010 10:15 am
#8
link can not work
 
 Registered: 1273314805
Comments: 1
Posts: 0
Timezone: GMT - 8 (U.S. Pacific)
Gateway: nexlinx.net.pk
Kate
8 May 2010 10:33 am
#9
I have tried but the code has been removed from its location. I am getting an error message so please send me the correct link. I am a developer of CPP.
edited by CGameProgrammer on 11 May 2010 4:25 pm 



This page has been viewed 6755 times by 779 unique visitors.

SQL database query time: 0.65 - PHP code execution time: 1.05 - Client-side load time: - Total load time:

Website design, programming, and original graphics are copyright © 2003-2005 Edward Ballard Resnick.
Uploaded images are not the property of this website but of their owners.