Skip to main content
gamedev.net
🔒 Locked

Another how intersect works?

Started by pedorro77 Jan 28, 2004 at 5:01 PM 2 replies 400+ views
Original Post
pedorro77
pedorro77
I have a ball (mesh1) that it move between two circles (mesh2 and mesh3) I do the test with if ( mesh1.mesh.Intersect(vRayPosition, mesh1.direction, ref closestHit, ref closestHita) ) but never is true. I''d drawed a line from the center of the ball pointing to the direction vector (-1,0,0 when go left and 1,0,0 when go right) The line is drawed from the center of the ball as i expected (and change the direction when collide with a circle) The move of the ball is a ping - pong. I *see* the line moving with the ball, (vRayPosition are the ball & line position) First i draw all the object, later i do the test. Some questions.. 1. I need to draw all the objects first ? (I think that it need to be *into* the world in order to do some intersect test) 2. When a ray start (ie) x=+500 and it go to the left (-1,0,0),, it stop in 0? (if it true and i have a mesh in x=-500 it never work) 3. I need to set up some other matrix before to do the test? (World Inverted, camera matrix,,) 4. Any aditional info?
pedorro77
pedorro77
still don''t work
pedorro77
pedorro77
Thanks neneboricua19 it works!
neneboricua19
neneboricua19
Your post is confusing (at least to me). From the code you posted, I *think* that you''re trying to see if there is an intersection between "mesh1" and mesh1''s direction??? This makes no sense.

Conceptually, you are trying to do a Pong type of game. So you''re trying to see if two meshes collide. The 2D case is trivial so I''ll assume you''re doing 3D. To check to see if your ball collides with your "two circles" (I assume these are 3D spheres), you just have to compare the distances between their centers. If that distance is less than or equal to the sum of the radii of the spheres, then there is a collision. Otherwise, there is not.

You don''t have to mess with the Intersect method. That method is there to see if a ray intersects a given mesh, not to see if two meshes have collided.

neneboricua

Topic Locked

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

Sign in to reply to this topic.