Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Simple explanation for ray - AABB intersection?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Angus Hollands   Members   -  Reputation: 722

Like
0Likes
Like

Posted 18 December 2012 - 02:34 PM

Hey everyone,
I've no doubt that this question has been asked countless times (and in fact the search tool confirms my suspicions) yet I ask this question because either the results never truly made sense to me, or that I was looking for a slightly different answer.

Firstly, I've taken a look at this ray-aabb slab method; http://www.cs.utah.edu/~awilliam/box/box.pdf
I suffer two problems here;
  • What is the purpose of t1 and t2? (optimised method) - How would I derive them from an origin and target of a ray?
  • How can I get the hitpoint from this boolean output?
I hate to ask so expectantly, but many thanks in advance,
Angus Hollands

Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2501

Like
0Likes
Like

Posted 18 December 2012 - 02:48 PM

My guess is that t1 is the distance in units from the ray origin before ray collisions can occur. You could use it to ignore any collisions if they occur too close to your ray origin - I'm having trouble seeing why you'd ever want to set anything other than zero for it. t2 seems to be the distance in units from the ray origin before ray collisions stop - assuming t1 is zero, then it's the length of the ray.

There are two intersection positions detected, usually you're interested only in the first which is occurs at tmin. To convert that into a position you'd use something like vCollisionPos = r.origin + r.direction * tmin;

#3 Glass_Knife   Moderators   -  Reputation: 5056

Like
0Likes
Like

Posted 18 December 2012 - 04:59 PM

http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtinter3.htm
I think, therefore I am. I think? - "George Carlin"
Indie Game Programming

#4 Glass_Knife   Moderators   -  Reputation: 5056

Like
0Likes
Like

Posted 19 December 2012 - 01:33 PM

http://www.siggraph....ce/rtinter3.htm


F.Y.I. I looked more closely at the paper today, and I think I had the same reaction you had. WTF?!?

So don't feel bad. I've been reviewing the bibliography for more info, so if you figure it out, please let us know.
I think, therefore I am. I think? - "George Carlin"
Indie Game Programming

#5 Glass_Knife   Moderators   -  Reputation: 5056

Like
0Likes
Like

Posted 21 December 2012 - 09:33 AM

To answer your questions, the t0 and t1 are the starting and ending points of the line segment on the ray.  There is no way to get the hit point from this algorithm.  The point of this is to quickly determine if the ray hits the AABB cube, so that most of the geometry can be rejected.  This isn't what you would use to determine the intersection point, this is what you use to figure out which geometry needs further testing.


I think, therefore I am. I think? - "George Carlin"
Indie Game Programming

#6 Angus Hollands   Members   -  Reputation: 722

Like
0Likes
Like

Posted 03 January 2013 - 02:43 PM

Thank you for your reply!

Are you sure this is the case? I was told perhaps I could use the cropped values ... Alas, I am going to have to revisit this at a later date! 



#7 Glass_Knife   Moderators   -  Reputation: 5056

Like
0Likes
Like

Posted 03 January 2013 - 03:17 PM

The way the algorithm is presented in the paper, no. Can you use the local variables to calculate the intersection? I don't know. I didn't spend a lot of time looking at it. I have done this calculation before, but I did it by finding the intersections with all the slabs and then determining if any of the those intersection points are on the cube.

I would need to look at it further. If anyone else knows, please chime in. I will take a guess that the values will give you a point on the ray, but won't tell you which plane of the box was hit or where, which won't be useful because without the plane of the box that was hit you can't calculate a reflection.

Also, I remember the author commenting that this test could give false positives. Maybe that's what this optimized solution is addressing. It is not obvious to me.

Edited by Glass_Knife, 03 January 2013 - 03:19 PM.

I think, therefore I am. I think? - "George Carlin"
Indie Game Programming




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS