[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Ray OBB intersection not working.  Ray not transformed into OBB space correctly?

Asked by Dr_Spankenstein in 3D Game Programming, Physics & Artificial Intelligence in Game Programming, Algorithms

Tags: Ray OBB Intersection 3D

I am trying to get a ray to return true when intersecting with an OBB.  My method works sound with an AABB but when I try it with an OBB then no intersection is ever returned.

I think that I have not transformed the ray into OBB space correctly and I have attached the code to show what I have so far:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
            float t_Min = 0.0f;
 
            // Maximum distance ray can travel (makes it a segment, otherwise it would be infinite)
            float t_Max = float.MaxValue;
 
            float ood = 0.0f;
            float t1 = 0.0f;
            float t2 = 0.0f;
 
            // Translate ray to OBB space
            Vector3 min_Local = Origin - oBB.Position;      // (P - C)
            Vector3 max_Local = Origin - oBB.Position;      // (P - C)
 
            float min_X = Vector3.Dot(min_Local, oBB.Axis_X);
            float max_X = Vector3.Dot(max_Local, oBB.Axis_X);
            float min_Y = Vector3.Dot(min_Local, oBB.Axis_Y);
            float max_Y = Vector3.Dot(max_Local, oBB.Axis_Y);
            float min_Z = Vector3.Dot(min_Local, oBB.Axis_Z);
            float max_Z = Vector3.Dot(max_Local, oBB.Axis_Z);
 
            // For all 3 slabs
            if (Math.Abs(Direction.X) < float.Epsilon)
            {
                // Ray is parallel to slab.  No hit if origin (p in book) not within slab
                if (Origin.X < min_X || Origin.X > max_X)
                {
                    return false;
                }
            }
            else
            {
                // Compute intersection t value of ray with near and far plane of slab
                ood = 1.0f / Direction.X;
                t1 = (min_X - Origin.X) * ood;
                t2 = (max_X - Origin.X) * ood;
 
                // Make (t1) be intersection with near plane, (t2) with far plane
                if (t1 > t2)
                {
                    Swap(ref t1, ref t2);
                }
 
                // Compute the intersection of slab intersection intervals
                t_Min = Math.Max(t_Min, t1);
                t_Max = Math.Min(t_Max, t2);
 
                // Exit with no collision as soon as slab intersection becomes empty
                if (t_Min > t_Max)
                {
                    return false;
                }
            }
            if (Math.Abs(Direction.Y) < float.Epsilon)
            {
                // Ray is parallel to slab.  No hit if origin (p in book) not within slab
                if (Origin.Y < min_Y || Origin.Y > max_Y)
                {
                    return false;
                }
            }
            else
            {
                // Compute intersection t value of ray with near and far plane of slab
                ood = 1.0f / Direction.Y;
                t1 = (min_Y - Origin.Y) * ood;
                t2 = (max_Y - Origin.Y) * ood;
 
                // Make (t1) be intersection with near plane, (t2) with far plane
                if (t1 > t2)
                {
                    Swap(ref t1, ref t2);
                }
 
                // Compute the intersection of slab intersection intervals
                t_Min = Math.Max(t_Min, t1);
                t_Max = Math.Min(t_Max, t2);
 
                // Exit with no collision as soon as slab intersection becomes empty
                if (t_Min > t_Max)
                {
                    return false;
                }
            }
            if (Math.Abs(Direction.Z) < float.Epsilon)
            {
                // Ray is parallel to slab.  No hit if origin (p in book) not within slab
                if (Origin.Z < min_Z || Origin.Z > max_Z)
                {
                    return false;
                }
            }
            else
            {
                // Compute intersection t value of ray with near and far plane of slab
                ood = 1.0f / Direction.Z;
                t1 = (min_Z - Origin.Z) * ood;
                t2 = (max_Z - Origin.Z) * ood;
 
                // Make (t1) be intersection with near plane, (t2) with far plane
                if (t1 > t2)
                {
                    Swap(ref t1, ref t2);
                }
 
                // Compute the intersection of slab intersection intervals
                t_Min = Math.Max(t_Min, t1);
                t_Max = Math.Min(t_Max, t2);
 
                // Exit with no collision as soon as slab intersection becomes empty
                if (t_Min > t_Max)
                {
                    return false;
                }
            }
 
            return true;
 
Related Solutions
Keywords: Ray OBB intersection not working. R…
 
Loading Advertisement...
 
[+][-]11/01/09 04:44 AM, ID: 25713531Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: 3D Game Programming, Physics & Artificial Intelligence in Game Programming, Algorithms
Tags: Ray OBB Intersection 3D
Sign Up Now!
Solution Provided By: ikework
Participating Experts: 1
Solution Grade: A
 
[+][-]11/01/09 05:25 AM, ID: 25713628Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 05:48 AM, ID: 25713685Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 06:19 AM, ID: 25713753Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 06:36 AM, ID: 25713800Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 06:55 AM, ID: 25713846Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 07:34 AM, ID: 25714004Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 07:43 AM, ID: 25714035Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 08:06 AM, ID: 25714145Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 08:09 AM, ID: 25714158Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 08:12 AM, ID: 25714170Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 08:47 AM, ID: 25714298Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 08:48 AM, ID: 25714306Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 08:52 AM, ID: 25714319Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 10:43 AM, ID: 25714814Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 02:09 PM, ID: 25715819Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 02:13 PM, ID: 25715840Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 02:35 PM, ID: 25715936Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 03:20 PM, ID: 25716145Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 03:29 PM, ID: 25716180Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 03:32 PM, ID: 25716188Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 03:39 PM, ID: 25716206Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/01/09 03:43 PM, ID: 25716221Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/01/09 03:56 PM, ID: 25716266Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/02/09 03:24 AM, ID: 25718480Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 08:44 AM, ID: 25730816Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/03/09 09:08 AM, ID: 25731088Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/03/09 01:24 PM, ID: 25733889Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/03/09 10:46 PM, ID: 25736981Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 03:34 AM, ID: 25738260Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 03:35 AM, ID: 25738269Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 04:48 AM, ID: 25738728Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:49 AM, ID: 25738736Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 05:48 AM, ID: 25739219Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 08:42 AM, ID: 25741180Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 08:44 AM, ID: 25741206Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 08:56 AM, ID: 25741328Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/10/09 05:50 AM, ID: 25785280Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625