Collision Detection using Meshes

ThePentiumGuy

Senior Contributor
Joined
May 21, 2003
Messages
1,113
Location
Boston, Massachusetts
hey,
when i try to do collision detection with meshes using mesh.intersect-
when you provide the ray position and direction,
where does the ray originate from? the center of the mesh? or does it protrude from the entire surface?

thanks,
pent
 
When using mesh.intersect try to imagine it as a line test against a mesh. So you can have your ray start anywhere you want. It is usually used to test if a mouse is over a mesh. Your mouse defines the ray and you're interested if the ray intersects the mesh. You could also use it for other purposes like collision detection but have in mind that it's performance is not very good. So it will only be good for very small games, otherwise try to get some other technique for collision detection.
 
Kavan said:
When using mesh.intersect try to imagine it as a line test against a mesh. So you can have your ray start anywhere you want. It is usually used to test if a mouse is over a mesh. Your mouse defines the ray and you're interested if the ray intersects the mesh. You could also use it for other purposes like collision detection but have in mind that it's performance is not very good. So it will only be good for very small games, otherwise try to get some other technique for collision detection.
i had no idae mesh.intersct woudl be slow lol
-but im only using it for htis purpose: checking whetehr the car is on the platform by drawing a ray from the platform to above the platform and seeing whether it intersects the car

(if platform.intersect(car.position,belowthecar.position)

however, yopu said that you can specify where the ray starts - how would you do this,

pent
 
It's Mesh.Intersect(rayStart, rayDirection). So your one should be like
platform.intersect(car.position,vector3.subtract(belowthecar.position,car.position))
 
found some stuff regarding Vertex.Subtratcion:
A subtracted vertex results in a vertex with its head(where it starts) originating from the tail of the first vertex, and its "direction" heading towards the head of the other vertex..
o_O
what's that gotta do with the platform thing,
im trying to draw this out in Paint bnut i cant see how it relates?

pent
 
It looks like you're in need of a course in linear algebra.

What does it have to do with your problem? Mesh.Intersect takes start of the ray and ray direction as its parameters. You only have start of the ray and another point on the ray. So you have to compute ray direction. You do this with Vector.Subtract. Of course you can always just take (0,-1,0) for your ray direction if I understand how you want to use it.
 
ohh, i see :)
yeah you're right, (0,-1,0) would work -> earlier, i had it in mind that the direction is when direct3d takes the 2 arguments and finds the direction,
now i see direction means.. like literally direction.. very vague explanation on my part :)_

but tahnks a lot, i understand it now - im gonna test it out
 
Back
Top