Skip to main content
GameDev.net gamedev.net
🔒 Locked

Ray/Sphere collision detection

Started by Blue*Omega Apr 24, 2001 at 7:41 PM 1 replies 450+ views
Original Post
Blue*Omega
Blue*Omega
Okay, don''t think I''ve seen this one out here before. Hope someone can help me. First of all: the question. Given a ray and a sphere, how can I tell if they are intersecting? "Ray" is a vector with a normal showing direction, "Sphere" is a vector and a radius. Now, to clarify, the problem: In my litle engine (if you could call it that) I have a fairly nice landscaping techniqe set up for what I hope will end up being a turn based RPG (think FF Tactics for the computer on hexagon shaped maps). Anyways, this routine dose a great job of rendering the land but now I need some way of telling my guys where to go. The most obvious answer is click on a point and have the character move there. I can handle pathfinding and such but I need to know what point the user is clicking on first. My idea was for each point on the map make a sphere around it with a radius of 10 or so. I calculate a ray going straight "into" the world from the screens current rotation and mouse position (which I''m pretty sure I can do). Then I see if the ray is intersecting any of the points "spheres" and move my little guy to that point. I just need to know if the sphere and ray are intersecting and I can do the rest. Anyone happen to have a good equation lying around? ----------------------------- Blue*Omega (Insert Witty Quote Here)
gimp
gimp
Source is available at http:\\www.magic-software.com
Chris Brodie
Blue*Omega
Blue*Omega
Thanks, I''ll check it out.

-----------------------------

Blue*Omega

(Insert Witty Quote Here)

Topic Locked

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

Sign in to reply to this topic.