Jump to content
  • Advertisement
Sign in to follow this  
eGamer

ray vs OBB

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have made algorithm for intersecting 3d ray ( p0 + t.K ) with an OBB and it didn't work well here is the code: bool intersect(SOBB& b,SRay3D& s,SVector3D& p) { SRay3D convS; // the ray in b coordinates SVector3D c_c = s.p0 - c; // translate vector // converting the ray elements into ray frame convS.p0.set( c_c.Dot(b.u[0]) , c_c.Dot(b.u[1]) ,c_c.Dot(b.u[2]) ); convS.d.set( s.d.Dot(b.u[0] ) , s.d.Dot(b.u[1]) ,s.d.Dot(b.u[2]) ); // now the converted ray with aabb ( obb is now aabb for new ray ) SAABB ab; ab.min.set(-b.e[0],-b.e[1],-b.e[2]); ab.max.set( b.e[0], b.e[1], b.e[2]); float t; if( ab.intersect(convS,t,p) ) { // re-write the intersection point in world coordinates float x = b.c.x + p.Dot(xAxis); float y = b.c.y + p.Dot(yAxis); float z = b.c.z + p.Dot(zAxis); p.set(x,y,z); return true; } return false; } please help me what is the mistake in my code???

Share this post


Link to post
Share on other sites
Advertisement
Assuming ab.intersect() works correctly, I would then try replacing these lines:

float x = b.c.x + p.Dot(xAxis);
float y = b.c.y + p.Dot(yAxis);
float z = b.c.z + p.Dot(zAxis);

p.set(x,y,z);

With this:

p = b.c + p.x * b.u[0] + p.y * b.u[1] + p.z * b.u[2];

And see if that doesn't fix the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!