General Category > General Anim8or Forum
WEEHEEEE oh, oh wait its dead, I thought it was dancing (CRE8OR NOTICE)
Thanos:
Sorry for the late reply. I can give some help if I find time.
Tell me what exactly you mean "That page didn't give me any good results and it never worked."? What is the point that stops working correctly?
Also, how is a triangle defined in your code - to allow me write some compatible code? Like, ((x1,y1,z1),(x2,y2,z2),(x3,y3,z3)) (ie. is there a 'point' class? or maybe a 'triangle' class too?) Or raw data, like, (x1,y1,z1,x2,y2,z2,x3,y3,z3)?
EDIT: Oh also, how is the ray line defined? Point-and-direction or two-points-on-line? (Is there a 'ray' class or 'line' class? Show me.)
cooldude234:
Triangles and their vertices are always defined the same way (if being traditional geometry), just by 3 points with a position for each dimensions, which in this case is three (3D). No matter if the vertecies are in a class, namespace, or structure of some sort, you can always get the floating point values form these vertices.
However the ray is a little different because you can define it by a point and direction, or by two points. In my case its by two points.
Now I've searched many many sites, and went though about 40 (search)pages on google.
I've got line-plane intersections to work. But that's only good if the plane is an infinite plane, so I need to detect whether the point is inside the triangle or not.
Also the method I'm using is probably not the fastest (A LOT of conversion and abstract math, it could be simplified).
I'm trying to look through the glm source code for some answers.
Thanos:
Here you are. ;)
I think the code I once sent you for line plane intersection might have a bug. I tried avoiding it this time, do a test if you want.
EDIT: Oh my, where are my manners?
Return values: x, y, z: collision point.
Return value is a boolean indicating whether the point belongs in the triangle or not.
EDIT 2, 16/2/2013: This version had a bug, so I removed the attachment. See version 3 for an update.
cooldude234:
Yea in my code I have setup the functions for plane intersection to return true if intersected and I use pointers to cast the collision point to the variable I wan't to store it in.
But anyways thanks I'll try in my code when I have time tonight.
Though I must ask what is with the Boolean variable rti? It's defined just to define floating point values. Why not just define the floating point values?
EDIT: I lied, I spent an hour and a half playing lone survivor, but I'm working on the code now so it counts I guess :P
cooldude234:
I tried the code and it still doesn't work.
Everything is fine up until I try to get it to find if the point is inside the triangle.
its making me really mad >:(
EDIT:some debugging led me to find out that (x-a)*a+(y-b)*b+(z-c)*c >= 0 is outputting values like -33 and -40 when the others are outputting stuff like 0.456 and -0.2357
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version