Skip to main content
gamedev.net
🔒 Locked

Line-triangle collisions?

Started by Lollyn00b Sep 9, 2006 at 10:03 PM 6 replies 1.4k views
Original Post
Lollyn00b
Lollyn00b
Hello, I was just wondering if anyone knew of an algorithm for line-triangle collisions? I've looked around on google, but to no avail. This would help me a lot on my current project. I've thought up my own way of doing it, but it seems messy and overcomplicated(It involves rotating the triangle multiple times). Any help would be appreciated.
Zakwayda
Zakwayda
You might have better luck googling 'ray triangle intersection' or 'triangle raytracing'. With the right search terms you should have no trouble finding references; ray-triangle intersection is well documented online.

Not all ray-triangle intersection algorithms are equally robust, but whether these issues are a factor can depend on in what context you're using the test.
Lollyn00b
Lollyn00b
Thanks for that link Kwak; It seems like it'll work great, but I have a question about it. What would VECTOR3::subs() be?
martin_bfg10k
martin_bfg10k
Some time ago I needed an algorithm like that too, and I found a very nice and fast triangle collision algorithm in the Irrlicht source code. Take a look at triangle3d.h in the Irrlicht /include
Kwak
Kwak
Quote:

Thanks for that link Kwak; It seems like it'll work great, but I have a question about it. What would VECTOR3::subs() be?
Simple vector subtraction (always thought it was named subStraction so i named it subs, should be sub then)

subs(v1, v2) = v1-v2

EDIT: I have changed the post in the link and added the sub code ;)
Lollyn00b
Lollyn00b
Thanks Kwak, that was really helpful, and with a few modifications, it worked perfectly. Rate++ :D
Kwak
Kwak
Glad to hear it helped.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.